Преглед изворни кода

[支付][修改]:调试分账接收方的添加和更新

release_toaliyun_real
hupeng пре 7 година
родитељ
комит
5f565f1446
4 измењених фајлова са 70 додато и 8 уклоњено
  1. +16
    -1
      mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java
  2. +1
    -1
      mallinkAdmin/src/main/java/com/simple/controller/WxProfitSharingReceiverController.java
  3. +3
    -2
      mallinkService/src/main/java/com/simple/service/WxProfitSharingReceiverService.java
  4. +50
    -4
      mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingReceiverServiceImpl.java

+ 16
- 1
mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java Прегледај датотеку

@@ -4,7 +4,9 @@ import com.github.pagehelper.PageInfo;
import com.simple.common.Result; import com.simple.common.Result;
import com.simple.common.ResultData; import com.simple.common.ResultData;
import com.simple.domain.po.WxMerchant; import com.simple.domain.po.WxMerchant;
import com.simple.domain.po.WxProfitSharingReceiver;
import com.simple.service.WxMerchantService; import com.simple.service.WxMerchantService;
import com.simple.service.WxProfitSharingReceiverService;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -23,6 +25,9 @@ public class WxMerchantController extends BaseController {
@Autowired @Autowired
private WxMerchantService wxMerchantService; private WxMerchantService wxMerchantService;


@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@ApiOperation("分页列表接口") @ApiOperation("分页列表接口")
@GetMapping("list") @GetMapping("list")
@ApiImplicitParams({ @ApiImplicitParams({
@@ -74,7 +79,17 @@ public class WxMerchantController extends BaseController {
@GetMapping("/findById") @GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
public ResultData findById(Long id) { public ResultData findById(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxMerchantService.getById(id));
WxMerchant wxMerchant = new WxMerchant();
wxMerchant = wxMerchantService.getById(id);
if (wxMerchant != null) {
WxProfitSharingReceiver receiver = wxProfitSharingReceiverService.findReceiver(wxMerchant);
if (receiver != null){
wxMerchant.setAccountId(receiver.getReceiverAccount());
wxMerchant.setAccountName(receiver.getTrueName());
wxMerchant.setAccountTypeValue(receiver.getReceiverType());
}
}
return new ResultData(wxMerchant);
} }


@ApiOperation("停用") @ApiOperation("停用")


+ 1
- 1
mallinkAdmin/src/main/java/com/simple/controller/WxProfitSharingReceiverController.java Прегледај датотеку

@@ -81,7 +81,7 @@ public class WxProfitSharingReceiverController extends BaseController {
if (merchant == null) if (merchant == null)
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);


return wxProfitSharingReceiverService.delReceiver(merchant, receiver);
return wxProfitSharingReceiverService.delReceiver(merchant);
} }






+ 3
- 2
mallinkService/src/main/java/com/simple/service/WxProfitSharingReceiverService.java Прегледај датотеку

@@ -40,10 +40,11 @@ public interface WxProfitSharingReceiverService {
*/ */
void deleteById(Long id); void deleteById(Long id);


WxProfitSharingReceiver findReceiver(WxMerchant merchant);


ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver); ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver);


ResultData delReceiver(WxMerchant merchant);


ResultData delReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver);
ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver);
} }

+ 50
- 4
mallinkService/src/main/java/com/simple/service/impl/WxProfitSharingReceiverServiceImpl.java Прегледај датотеку

@@ -23,6 +23,7 @@ import com.simple.pay.WxProfitSharingReceiverP;
import com.simple.service.WxProfitSharingReceiverService; import com.simple.service.WxProfitSharingReceiverService;
import com.simple.utils.BeanUtils; import com.simple.utils.BeanUtils;
import com.simple.utils.Utility; import com.simple.utils.Utility;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.simple.common.IdWorker; import com.simple.common.IdWorker;
@@ -32,6 +33,8 @@ import com.simple.common.IdWorker;
@Service @Service
public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiverService { public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiverService {


private Logger logger = Logger.getLogger(WxCouponOrderServiceImpl.class);

final JSONObject errorMap = JSON.parseObject("{" + final JSONObject errorMap = JSON.parseObject("{" +
"\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," + "\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," +
"\"PARAM_ERROR\":{\"detail\":\"参数错误\\t\",\"reason\":\"请求参数未按指引进行填写\",\"resolution\":\"请求参数错误,请重新检查再调用分账接口\"}," + "\"PARAM_ERROR\":{\"detail\":\"参数错误\\t\",\"reason\":\"请求参数未按指引进行填写\",\"resolution\":\"请求参数错误,请重新检查再调用分账接口\"}," +
@@ -78,6 +81,16 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
} }




@Override
public WxProfitSharingReceiver findReceiver(WxMerchant merchant) {
WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.setMerchantId(merchant.getId());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());

return wxProfitSharingReceiverMapper.selectOne(receiver);
}



@Override @Override
public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) { public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) {
@@ -123,20 +136,24 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}catch (Exception e) { }catch (Exception e) {
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + e.getMessage());
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage()); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED, e.getMessage());
} }
Map<String, String> returnMap = WxPayment.xmlToMap(response); Map<String, String> returnMap = WxPayment.xmlToMap(response);
String return_code = returnMap.get("return_code"); String return_code = returnMap.get("return_code");
if (!"SUCCESS".equals(return_code)) { if (!"SUCCESS".equals(return_code)) {
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + returnMap.get("return_msg"));
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg")); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg"));
} }


String result_code = returnMap.get("result_code"); String result_code = returnMap.get("result_code");
if (!"SUCCESS".equals(result_code)) { if (!"SUCCESS".equals(result_code)) {
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + returnMap.get("err_code_des"));
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("err_code_des")); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("err_code_des"));
} }


if (!WxPayment.verifyNotifyHMAC(returnMap,payAccount.getApiKey())){ if (!WxPayment.verifyNotifyHMAC(returnMap,payAccount.getApiKey())){
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + "verifyNotifyHMAC");
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage()); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage());
} }


@@ -145,7 +162,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
} }


@Override @Override
public ResultData delReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) {
public ResultData delReceiver(WxMerchant merchant) {
WxAppinfo appInfo = new WxAppinfo(); WxAppinfo appInfo = new WxAppinfo();
appInfo.setTenantId(merchant.getTenantId()); appInfo.setTenantId(merchant.getTenantId());
appInfo.setType(EnumAppType.C.getCode()); appInfo.setType(EnumAppType.C.getCode());
@@ -153,6 +170,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
appInfo = wxAppinfoMapper.findList(appInfo).get(0); appInfo = wxAppinfoMapper.findList(appInfo).get(0);
WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId());


WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.setMerchantId(merchant.getId()); receiver.setMerchantId(merchant.getId());
receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode()); receiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
@@ -181,28 +199,56 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
String response; String response;
try { try {
wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
response = WxProfitSharing.delReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}catch (Exception e) { }catch (Exception e) {
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + e.getMessage());
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage()); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED, e.getMessage());
} }
Map<String, String> returnMap = WxPayment.xmlToMap(response); Map<String, String> returnMap = WxPayment.xmlToMap(response);
String return_code = returnMap.get("return_code"); String return_code = returnMap.get("return_code");
if (!"SUCCESS".equals(return_code)) { if (!"SUCCESS".equals(return_code)) {
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("return_msg"));
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg")); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg"));
} }


String result_code = returnMap.get("result_code"); String result_code = returnMap.get("result_code");
if (!"SUCCESS".equals(result_code)) { if (!"SUCCESS".equals(result_code)) {

if (returnMap.get("err_code").contains("USER_NOT_EXIST")) {
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode());
wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver);
}
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("result_msg"));
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("result_msg")); return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("result_msg"));
} }


if (!WxPayment.verifyNotifyHMAC(returnMap,payAccount.getApiKey())){ if (!WxPayment.verifyNotifyHMAC(returnMap,payAccount.getApiKey())){
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage());
logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage());
return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), "verifyNotifyHMAC");
} }
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode());
wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver); wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver);
return new ResultData(returnMap); return new ResultData(returnMap);
} }


@Override
public ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) {

WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver();
oldReceiver.setMerchantId(merchant.getId());
oldReceiver.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
oldReceiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
oldReceiver.setReceiverAccount(receiver.getReceiverAccount());
oldReceiver.setReceiverType(receiver.getReceiverType());
oldReceiver.setTrueName(receiver.getTrueName());

oldReceiver = wxProfitSharingReceiverMapper.selectOne(oldReceiver);

if (oldReceiver == null) {
delReceiver(merchant);
return addReceiver(merchant, receiver);
}

return new ResultData();
}
} }

Loading…
Откажи
Сачувај