Просмотр исходного кода

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

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
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.ResultData;
import com.simple.domain.po.WxMerchant;
import com.simple.domain.po.WxProfitSharingReceiver;
import com.simple.service.WxMerchantService;
import com.simple.service.WxProfitSharingReceiverService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@@ -23,6 +25,9 @@ public class WxMerchantController extends BaseController {
@Autowired
private WxMerchantService wxMerchantService;

@Autowired
private WxProfitSharingReceiverService wxProfitSharingReceiverService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@@ -74,7 +79,17 @@ public class WxMerchantController extends BaseController {
@GetMapping("/findById")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
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("停用")


+ 1
- 1
mallinkAdmin/src/main/java/com/simple/controller/WxProfitSharingReceiverController.java Просмотреть файл

@@ -81,7 +81,7 @@ public class WxProfitSharingReceiverController extends BaseController {
if (merchant == null)
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);

WxProfitSharingReceiver findReceiver(WxMerchant merchant);

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.utils.BeanUtils;
import com.simple.utils.Utility;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.simple.common.IdWorker;
@@ -32,6 +33,8 @@ import com.simple.common.IdWorker;
@Service
public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiverService {

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

final JSONObject errorMap = JSON.parseObject("{" +
"\"SYSTEMERROR\":{\"detail\":\"接口返回错误\",\"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
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()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}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());
}
Map<String, String> returnMap = WxPayment.xmlToMap(response);
String return_code = returnMap.get("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"));
}

String result_code = returnMap.get("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"));
}

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());
}

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

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

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());
@@ -181,28 +199,56 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
String response;
try {
wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey()));
response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
response = WxProfitSharing.delReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP));
}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());
}
Map<String, String> returnMap = WxPayment.xmlToMap(response);
String return_code = returnMap.get("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"));
}

String result_code = returnMap.get("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"));
}

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());
wxProfitSharingReceiverMapper.updateByPrimaryKeySelective(receiver);
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();
}
}

Загрузка…
Отмена
Сохранить