| @@ -86,7 +86,7 @@ public class WxPayOrder implements Serializable { | |||
| private Integer payOrderStatus; | |||
| /*分账状态: 0-未分账;1-分账**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="分账状态: 0-未分账;1-分账",name="payOrderStatus") | |||
| private boolean share; | |||
| private Integer share; | |||
| /*支付失败原因**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason") | |||
| private String failReason; | |||
| @@ -114,12 +114,15 @@ public class WxPayOrder implements Serializable { | |||
| public void setOrderId(Long _orderId) { | |||
| orderId = _orderId; | |||
| } | |||
| public Long getCUserId() { | |||
| public Long getcUserId() { | |||
| return cUserId; | |||
| } | |||
| public void setCUserId(Long _cUserId) { | |||
| cUserId = _cUserId; | |||
| public void setcUserId(Long cUserId) { | |||
| this.cUserId = cUserId; | |||
| } | |||
| public String getIp() { | |||
| return ip; | |||
| } | |||
| @@ -178,11 +181,11 @@ public class WxPayOrder implements Serializable { | |||
| payOrderStatus = _payOrderStatus; | |||
| } | |||
| public boolean isShare() { | |||
| public Integer getShare() { | |||
| return share; | |||
| } | |||
| public void setShare(boolean share) { | |||
| public void setShare(Integer share) { | |||
| this.share = share; | |||
| } | |||
| @@ -0,0 +1,38 @@ | |||
| package com.simple.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumPayShare { | |||
| // 0-未启用分账, 1-启用分账 | |||
| NO(0, "未启用分账"), | |||
| YES(1, "启用分账") | |||
| ; | |||
| public static EnumPayShare getEnum(Integer code) { | |||
| for (EnumPayShare value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumPayShare(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -22,6 +22,7 @@ import com.simple.pay.*; | |||
| import com.simple.service.WxOrderService; | |||
| import com.simple.service.WxPayOrderService; | |||
| import com.simple.utils.*; | |||
| import io.swagger.models.auth.In; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| @@ -99,7 +100,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| public ResultData createPayOrder(boolean isReal, WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay) { | |||
| final IdWorker idworker = IdWorker.get(); | |||
| boolean isShare = false; | |||
| EnumPayShare isShare = EnumPayShare.NO; | |||
| try { | |||
| // 1. check 订单 | |||
| @@ -117,17 +118,17 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); | |||
| if (payAccount.isShare()) { | |||
| isShare = true; | |||
| isShare = EnumPayShare.YES; | |||
| } | |||
| // 1.5 check 分账 receive | |||
| if (isShare) { | |||
| if (isShare == EnumPayShare.YES) { | |||
| WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); | |||
| receiver.setMerchantId(order.getMerchantId()); | |||
| List<WxProfitSharingReceiver> merList = wxProfitSharingReceiverMapper.findList(receiver); | |||
| if (merList.size() > 0) { | |||
| isShare = true; | |||
| isShare = EnumPayShare.YES; | |||
| } else { | |||
| isShare = false; | |||
| isShare = EnumPayShare.NO; | |||
| } | |||
| } | |||
| // 2. check 是否有支付订单 | |||
| @@ -140,7 +141,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| payOrderNo = String.valueOf(id); | |||
| record.setId(id); | |||
| record.setTenantId(user.getTenantId()); | |||
| record.setCUserId(user.getId()); | |||
| record.setcUserId(user.getId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| record.setPayTimeStart(currentDate); | |||
| @@ -150,7 +151,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| record.setPayAmount(order.getPayment()); | |||
| record.setPayVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); | |||
| record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); | |||
| record.setShare(isShare); | |||
| record.setShare(isShare.getCode()); | |||
| int sqlRow = wxPayOrderMapper.insertSelective(record); | |||
| if (sqlRow != 1) { | |||
| @@ -159,7 +160,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| } else { | |||
| record = list.get(0); | |||
| record.setShare(isShare); | |||
| record.setShare(isShare.getCode()); | |||
| payOrderNo = String.valueOf(record.getId()); | |||
| } | |||
| @@ -244,7 +245,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| futureDate.setTime(currentDate.getTime() + 15*60*1000); | |||
| wxPayOrderSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| wxPayOrderSP.setSign_type("HMAC-SHA256"); | |||
| if(isShare) { | |||
| if(isShare == EnumPayShare.YES) { | |||
| wxPayOrderSP.setProfit_sharing("Y"); | |||
| } | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderSP); | |||
| @@ -126,7 +126,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| private WxAppinfo getAppinfo(WxPayOrder wxPayOrder) { | |||
| WxAppinfo wxAppinfo; | |||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(wxPayOrder.getCUserId()); | |||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(wxPayOrder.getcUserId()); | |||
| if (wxCUser == null) | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), ErrorCode.USER_IS_EMPTY.getMessage()); | |||
| wxAppinfo = wxAppinfoMapper.selectByPrimaryKey(wxCUser.getAppId()); | |||
| @@ -334,7 +334,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(appInfo.getTenantId()); | |||
| payOrderQ.setCUserId(wxOrder.getCUserId()); | |||
| payOrderQ.setcUserId(wxOrder.getCUserId()); | |||
| payOrderQ.setOrderId(wxOrder.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| @@ -365,7 +365,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| record.setUpdateTime(currentDate); | |||
| // 微信内部订单号 | |||
| record.setTransactionId(payOrder.getTransactionId()); | |||
| record.setCUserId(payOrder.getCUserId()); | |||
| record.setCUserId(payOrder.getcUserId()); | |||
| record.setTotalFee(payOrder.getPayAmount()); | |||
| record.setRefundFee(payOrder.getPayAmount()); | |||
| record.setRefundTimeStart(currentDate); | |||