|  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.annotation.ControllerEndpoint; | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.FebsResponse; | 
|---|
|  |  |  | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AdminAgentAmountDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AdminAgentDetailDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AdminIndexVideoDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.CashOutSettingDto; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.AppContants; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.*; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.ICommonService; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.ISystemService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.HeaderDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.WxFaPiaoService; | 
|---|
|  |  |  | import cn.hutool.core.util.ObjectUtil; | 
|---|
|  |  |  | import cn.hutool.json.JSONUtil; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import lombok.RequiredArgsConstructor; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.httpclient.HttpClient; | 
|---|
|  |  |  | import org.apache.commons.httpclient.methods.PostMethod; | 
|---|
|  |  |  | import org.apache.commons.httpclient.methods.RequestEntity; | 
|---|
|  |  |  | import org.apache.commons.httpclient.methods.StringRequestEntity; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.security.KeyPair; | 
|---|
|  |  |  | import java.security.NoSuchAlgorithmException; | 
|---|
|  |  |  | import java.security.PrivateKey; | 
|---|
|  |  |  | import java.util.Arrays; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final ICommonService commonService; | 
|---|
|  |  |  | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; | 
|---|
|  |  |  | private final WxFaPiaoService wxFaPiaoService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping(value = "/bonusSystemSetting") | 
|---|
|  |  |  | public FebsResponse bonusSystemSetting(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().message("操作成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping(value = "/faPiaoSet") | 
|---|
|  |  |  | public FebsResponse faPiaoSet(FaPiaoDto faPiaoDto) { | 
|---|
|  |  |  | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( | 
|---|
|  |  |  | DataDictionaryEnum.FP_CALLBACK_URL.getType(), | 
|---|
|  |  |  | DataDictionaryEnum.FP_CALLBACK_URL.getCode(), | 
|---|
|  |  |  | faPiaoDto.getCallbackUrl() | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | HeaderDto headerDto = new HeaderDto(); | 
|---|
|  |  |  | headerDto.setCallback_url("https://api.blnka.cn/api/xcxPay/fapiaoCallBack"); | 
|---|
|  |  |  | headerDto.setShow_fapiao_cell(false); | 
|---|
|  |  |  | String parseObj = JSONUtil.parseObj(headerDto).toString(); | 
|---|
|  |  |  | String baseUrl = "https://api.mch.weixin.qq.com"; | 
|---|
|  |  |  | String canonicalUrl = "/v3/new-tax-control-fapiao/merchant/development-config"; | 
|---|
|  |  |  | String postStr = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PrivateKey privateKey = wxFaPiaoService.getPrivateKeyV3(); | 
|---|
|  |  |  | postStr = wxFaPiaoService.createAuthorization( | 
|---|
|  |  |  | "PATCH", | 
|---|
|  |  |  | baseUrl+canonicalUrl, | 
|---|
|  |  |  | parseObj, | 
|---|
|  |  |  | privateKey | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } catch (NoSuchAlgorithmException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String token = AppContants.FP_TOKEN_HEADER_TYPE+postStr; | 
|---|
|  |  |  | System.out.println("WECHATPAY2-SHA256-RSA2048 "+postStr); | 
|---|
|  |  |  | String s = wxFaPiaoService.sendPatch(baseUrl + canonicalUrl, parseObj, token); | 
|---|
|  |  |  | log.info("配置开发选项:"+s); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().message(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping(value = "/agentDetail") | 
|---|
|  |  |  | public FebsResponse agentDetail(AdminAgentDetailDto adminAgentDetailDto) { | 
|---|
|  |  |  | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( | 
|---|