Sfoglia il codice sorgente

//coupon

release_toaliyun_real
xhxu 3 anni fa
parent
commit
22d04a2f4a
9 ha cambiato i file con 136 aggiunte e 174 eliminazioni
  1. +37
    -50
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java
  2. +39
    -12
      mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java
  3. +4
    -22
      mallinkService/src/main/java/com/iformall/service/order/impl/batch/BaseBatchOrderAdapterService.java
  4. +10
    -11
      mallinkService/src/main/java/com/iformall/service/pay/service/pay/douyin/v1/miniApp/TtMiniAppPayAdapterService.java
  5. +3
    -2
      mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareBaseAdapterService.java
  6. +19
    -35
      mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java
  7. +10
    -27
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java
  8. +13
    -15
      mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java
  9. +1
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java

+ 37
- 50
mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java Vedi File

@@ -70,7 +70,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
WxCUserService wxCUserService; WxCUserService wxCUserService;


@Autowired @Autowired
WxPayAccountMapper wxPayAccountMapper;
WxPayAccountService wxPayAccountService;


@Autowired @Autowired
WxOrderMapper wxOrderMapper; WxOrderMapper wxOrderMapper;
@@ -269,12 +269,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
} }
List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId());
WxCoupon lastCoupon = null;
List<String> productNames = new ArrayList<>();
for (WxOrder o : orderList) { for (WxOrder o : orderList) {
lastCoupon = checkSinglePayOrder(o, user, payWay);
productNames.add(o.getProductName());
checkSinglePayOrder(o, user, payWay);
} }
String productName = orderAdapterService.getPayProductName(lastCoupon);
PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder,orderList,productName, payWay, params,isCreatePay);
PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder,orderList,JSON.toJSONString(productNames), payWay, params,isCreatePay);
if (payResult.isSuccess()) { if (payResult.isSuccess()) {
// wxOrderService.sendInsideOrderPushMsg(composeOrder,composeOrder.getMainOrderId()); // wxOrderService.sendInsideOrderPushMsg(composeOrder,composeOrder.getMainOrderId());
return new ResultData(Result.SUCCESS,"创建支付单成功",payResult.getData()); return new ResultData(Result.SUCCESS,"创建支付单成功",payResult.getData());
@@ -284,8 +284,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
} }
private WxCoupon checkSinglePayOrder(WxOrder order,WxCUserBasicInfo user,EnumPayWay payWay) {
if (!order.getOrderGroupId().equals(0L)) {
private void checkSinglePayOrder(WxOrder order,WxCUserBasicInfo user,EnumPayWay payWay) {
if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) {
throw new MallinkException(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT);
}
if (order.getOrderGroupId() !=null && !order.getOrderGroupId().equals(0L)) {
if (order.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode())) { if (order.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode())) {
logger.error("支付时拼团已满>>" + order.getOrderGroupId()); logger.error("支付时拼团已满>>" + order.getOrderGroupId());
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED); throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FINISHED);
@@ -311,17 +314,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
if (orderq.getOrderStatus()==EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode()) { if (orderq.getOrderStatus()==EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode()) {
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_ATTEND.getCode(),"不能重复参团订单[user:"+user.getId()+",groupId:"+order.getOrderGroupId()+"]"); throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_ATTEND.getCode(),"不能重复参团订单[user:"+user.getId()+",groupId:"+order.getOrderGroupId()+"]");
} }
}

WxCoupon wxCoupon = wxCouponMapper.selectById(order.getProductId(),order.getTenantId());
if (wxCoupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode()) &&
wxCoupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) {
logger.error("券已经下架了>>>" + order.getProductId());
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF);
}

if (!wxCoupon.getType().equals(EnumCouponType.COUPON_GROUP.getCode()) && order.getPressEndDate() == null) {
// 非砍价券且非拼团券
}else if(order.getPressEndDate() != null){
if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_PRESS_OVERTIME.getCode()) {
logger.error("砍价已过期: " + order.toString() + " , payWay: " + payWay.toString());
throw new MallinkException(ErrorCode.ORDER_PRESS_IS_OVERTIME);
}
}else{
if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()) { if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()) {
logger.error("订单已支付: " + order.toString() + " , payWay: " + payWay.toString()); logger.error("订单已支付: " + order.toString() + " , payWay: " + payWay.toString());
throw new MallinkException(ErrorCode.ORDER_HAD_PAY); throw new MallinkException(ErrorCode.ORDER_HAD_PAY);
@@ -334,20 +332,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
throw new MallinkException(ErrorCode.ORDER_IS_NOT_PAY); throw new MallinkException(ErrorCode.ORDER_IS_NOT_PAY);
} }
} }
} else if (order.getPressEndDate() != null) {
// 砍价券,只有在过期时无法支付
// 砍价中,原价购买
// 砍价完成,低价购买
if (order.getOrderStatus() == EnumOrderStatus.ORDER_STATUS_PRESS_OVERTIME.getCode()) {
logger.error("砍价已过期: " + order.toString() + " , payWay: " + payWay.toString());
throw new MallinkException(ErrorCode.ORDER_PRESS_IS_OVERTIME);
}
} }
if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) {
throw new MallinkException(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT);
}
return wxCoupon;
} }

@Override @Override
public PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, public PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders,
String productName,EnumPayWay payWay,PayExtraParam params,boolean isCreatePay) { String productName,EnumPayWay payWay,PayExtraParam params,boolean isCreatePay) {
@@ -356,13 +343,13 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
EnumPayShare isShare = EnumPayShare.NO; EnumPayShare isShare = EnumPayShare.NO;


try { try {
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion());
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
EnumPayMchType payMchTypeEnum = EnumPayMchType.getEnum(payAccount.getMchType()); EnumPayMchType payMchTypeEnum = EnumPayMchType.getEnum(payAccount.getMchType());
if(payMchTypeEnum != null){ if(payMchTypeEnum != null){
payMchType = payMchTypeEnum; payMchType = payMchTypeEnum;
} }
if(EnumAppPlat.TOUTIAO.equals(payWay.getPlat()) && EnumPayMchType.DIRECT.equals(payMchTypeEnum)){
if(EnumPayMchType.DIRECT.equals(payMchTypeEnum)){
isShare = EnumPayShare.YES; isShare = EnumPayShare.YES;
}else{ }else{
EnumPayShare paySHareEnum = EnumPayShare.getEnum(payAccount.getShare()); EnumPayShare paySHareEnum = EnumPayShare.getEnum(payAccount.getShare());
@@ -429,11 +416,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
//设置子订单分账金额 //设置子订单分账金额
Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>();
for (WxOrder o : childOrders) { for (WxOrder o : childOrders) {
Long merchant_id = null;
Long merchant_id = 0L;
String merchant_uid = ""; String merchant_uid = "";
if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户
//TODO 加缓存
merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId());
merchant_id = o.getMakeMerchantId();
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion());
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode());
if(receiver == null){ if(receiver == null){
throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR);
@@ -488,7 +475,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
public ResultData createMicroPayOrder(WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay,PayExtraParam params) { public ResultData createMicroPayOrder(WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay,PayExtraParam params) {
final IdWorker idworker = IdWorker.get(); final IdWorker idworker = IdWorker.get();


WxAppinfo appInfo = wxAppinfoService.getCAppInfo(user,payWay.getPlat());
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(user.getTenantId(),payWay.getPlat());
if (null == params) { if (null == params) {
params = new PayExtraParam(); params = new PayExtraParam();
} }
@@ -499,7 +486,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
// 1. check 订单 // 1. check 订单
OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(EnumComposeOrder.SINGLE.getCode()); OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(EnumComposeOrder.SINGLE.getCode());
WxComposeOrder composeOrder = orderAdapterService.getComposeOrder(record.getOrderId(), appInfo.getTenantId()); WxComposeOrder composeOrder = orderAdapterService.getComposeOrder(record.getOrderId(), appInfo.getTenantId());
if (composeOrder == null) {
WxOrder singleOrder = composeOrder.getSingleOrder();
if (composeOrder == null) {
logger.error("pay order, order not allow, repaymentReq: " + record.toString() + ", payWay: " + payWay.toString()); logger.error("pay order, order not allow, repaymentReq: " + record.toString() + ", payWay: " + payWay.toString());
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND);
} }
@@ -515,7 +503,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) { if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) {
return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT);
} }
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion());
EnumPayShare paySHareEnum = EnumPayShare.getEnum(payAccount.getShare()); EnumPayShare paySHareEnum = EnumPayShare.getEnum(payAccount.getShare());
if (paySHareEnum != null) { if (paySHareEnum != null) {
@@ -551,10 +539,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
record.setComposeOrder(EnumComposeOrder.SINGLE.getCode()); record.setComposeOrder(EnumComposeOrder.SINGLE.getCode());


Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>(); Map<String,WxComposeChildOrderShare> childShares = new HashMap<String,WxComposeChildOrderShare>();
Long merchant_id = null;
Long merchant_id = 0L;
String merchant_uid = ""; String merchant_uid = "";
if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户 if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户
//todo 缓存
merchant_id = user.getMerchantId(); merchant_id = user.getMerchantId();
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType()); WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType());
if(receiver == null){ if(receiver == null){
@@ -640,8 +627,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), "payOrder not found"); return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), "payOrder not found");
} }


WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record,payWay.getPlat());
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(record.getTenantId(),payWay.getPlat());
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
PayAdapterService payService = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()); PayAdapterService payService = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion());
PayQueryAdapterResult apiResult = payService.queryPayStatus(record, appInfo, payAccount); PayQueryAdapterResult apiResult = payService.queryPayStatus(record, appInfo, payAccount);
int status = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()).queryPayStatus(apiResult, record.getPayOrderNo()); int status = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()).queryPayStatus(apiResult, record.getPayOrderNo());
@@ -711,7 +698,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
*/ */
@Override @Override
public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) { public ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record) {
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
try { try {
PayAdapterResult result = payServiceFactory.getPayAdapterService(record.getPayVendor(),record.getPayVersion()).payOrderClose(appInfo, record, payAccount); PayAdapterResult result = payServiceFactory.getPayAdapterService(record.getPayVendor(),record.getPayVersion()).payOrderClose(appInfo, record, payAccount);
if (result.isSuccess()) { if (result.isSuccess()) {
@@ -747,8 +734,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
@Override @Override
public ResultData payOrderReverse(WxPayOrder record) { public ResultData payOrderReverse(WxPayOrder record) {


WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record,EnumPayWay.getEnum(record.getPayVendor()).getPlat());
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(record.getTenantId(),EnumPayWay.getEnum(record.getPayVendor()).getPlat());
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
try { try {
PayAdapterResult result = payServiceFactory.getPayAdapterService(record.getPayVendor(),record.getPayVersion()).payOrderReverse(appInfo, record, payAccount); PayAdapterResult result = payServiceFactory.getPayAdapterService(record.getPayVendor(),record.getPayVersion()).payOrderReverse(appInfo, record, payAccount);
if (result.isSuccess()) { if (result.isSuccess()) {
@@ -1020,8 +1007,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {


@Override @Override
public PayQueryAdapterResult ttorderQuery(TenantEntity tenantInfo, Long id) { public PayQueryAdapterResult ttorderQuery(TenantEntity tenantInfo, Long id) {
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantInfo,EnumAppPlat.TOUTIAO);
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(tenantInfo.getTenantId(),EnumAppPlat.TOUTIAO);
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
WxPayOrder payOrder = new WxPayOrder(); WxPayOrder payOrder = new WxPayOrder();
payOrder.setPayOrderNo(id.toString()); payOrder.setPayOrderNo(id.toString());
try { try {
@@ -1311,11 +1298,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
// 有价券 // 有价券
if (EnumPayStatus.PAY_STATUS_FAIL.getCode() == status) { if (EnumPayStatus.PAY_STATUS_FAIL.getCode() == status) {
// 1. get appinfo // 1. get appinfo
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(record,EnumPayWay.getEnum(record.getPayVendor()).getPlat());
WxAppinfo appInfo = wxAppinfoService.getCAppInfoFromRedis(record.getTenantId(),EnumPayWay.getEnum(record.getPayVendor()).getPlat());
// 前端支付取消, // 前端支付取消,
// 回调未返回,主动检查支付订单状态 // 回调未返回,主动检查支付订单状态
try { try {
WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId());
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId());
int payStatus = payServiceFactory.getPayAdapterService(record.getPayVendor(),payAccount.getPayVersion()).queryPayStatusCode(record, appInfo, payAccount); int payStatus = payServiceFactory.getPayAdapterService(record.getPayVendor(),payAccount.getPayVersion()).queryPayStatusCode(record, appInfo, payAccount);
if (payStatus!=EnumPayStatus.PAY_STATUS_SUCCESS.getCode().intValue() && payStatus!=EnumPayStatus.PAY_STATUS_WAIT.getCode().intValue()) { if (payStatus!=EnumPayStatus.PAY_STATUS_SUCCESS.getCode().intValue() && payStatus!=EnumPayStatus.PAY_STATUS_WAIT.getCode().intValue()) {
// 支付订单未成功,返回异常 // 支付订单未成功,返回异常


+ 39
- 12
mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingReceiverServiceImpl.java Vedi File

@@ -37,15 +37,15 @@ import com.iformall.service.WxPayAccountService;
import com.iformall.service.WxProfitSharingReceiverService; import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.service.pay.PayServiceFactory; import com.iformall.service.pay.PayServiceFactory;
import com.iformall.service.pay.service.share.entity.ShareAccountResult; import com.iformall.service.pay.service.share.entity.ShareAccountResult;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.DateUtils;
import com.iformall.utils.Utility;
import com.iformall.utils.*;
import net.sf.saxon.trans.Err; import net.sf.saxon.trans.Err;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.Date; import java.util.Date;
@@ -85,6 +85,10 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
@Autowired @Autowired
PayServiceFactory payServiceFactory; PayServiceFactory payServiceFactory;


@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> sharingReceicerRedisTemplate;

@Override @Override
public PageInfo<WxProfitSharingReceiver> listAsPage(WxProfitSharingReceiver record, Integer pageIndex, Integer pageSize) { public PageInfo<WxProfitSharingReceiver> listAsPage(WxProfitSharingReceiver record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingReceiverMapper.findList(record)); return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingReceiverMapper.findList(record));
@@ -108,6 +112,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
} else { } else {
record.setUpdateTime(date); record.setUpdateTime(date);
wxProfitSharingReceiverMapper.updateById(record); wxProfitSharingReceiverMapper.updateById(record);
this.deleteRedis(record.getId());
} }
} }


@@ -120,13 +125,25 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv


@Override @Override
public WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitSharingType sharingType) { public WxProfitSharingReceiver findReceiver(TenantEntity tenantEntity,Long merchantId, EnumAppPlat plat,EnumProfitSharingType sharingType) {
WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.updateTenantInfo(tenantEntity);
receiver.setMerchantId(merchantId);
receiver.setPlat(plat.getCode());
receiver.setSharingType(sharingType.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
return wxProfitSharingReceiverMapper.findOne(receiver);
WxProfitSharingReceiver record = null;
String key = Constant.sharingReceicerPrev + tenantEntity.getTenantId()
+ ":" + merchantId
+ ":" + plat.getCode() + "a" + sharingType.getCode();
record = RedisCacheUtils.getCacheObject(sharingReceicerRedisTemplate, key, WxProfitSharingReceiver.class);
if(record == null){
WxProfitSharingReceiver receiver = new WxProfitSharingReceiver();
receiver.updateTenantInfo(tenantEntity);
receiver.setMerchantId(merchantId);
receiver.setPlat(plat.getCode());
receiver.setSharingType(sharingType.getCode());
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
record = wxProfitSharingReceiverMapper.findOne(receiver);
if(record != null){
RedisCacheUtils.cache(sharingReceicerRedisTemplate, key, record, 3600*24*7);
}
}
return record;

} }
@Override @Override
@@ -405,7 +422,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv


receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode());
receiver.setUpdateTime(new Date()); receiver.setUpdateTime(new Date());
wxProfitSharingReceiverMapper.updateById(receiver);
this.saveOrUpdate(receiver);


//发送短信 //发送短信
if (send.equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) { if (send.equals(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode())) {
@@ -435,9 +452,19 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv
} else { } else {
oldReceiver.setParameter(receiver.getParameter()); oldReceiver.setParameter(receiver.getParameter());
oldReceiver.setUpdateTime(new Date()); oldReceiver.setUpdateTime(new Date());
wxProfitSharingReceiverMapper.updateById(oldReceiver);
this.saveOrUpdate(oldReceiver);
} }


return new ResultData(); return new ResultData();
} }

private void deleteRedis(Long id){
WxProfitSharingReceiver receiver = wxProfitSharingReceiverMapper.selectById(id);
if(receiver != null){
String key = Constant.sharingReceicerPrev + receiver.getTenantId()
+ ":" + receiver.getMerchantId()
+ ":" + receiver.getPlat() + "a" + receiver.getReceiverType();
RedisCacheUtils.removeCache(sharingReceicerRedisTemplate, key);
}
}
} }

+ 4
- 22
mallinkService/src/main/java/com/iformall/service/order/impl/batch/BaseBatchOrderAdapterService.java Vedi File

@@ -94,14 +94,6 @@ public abstract class BaseBatchOrderAdapterService implements OrderAdapterServic
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
protected WxComposeOrder createDBMainOrder(TenantEntity tenantEntity,WxCUserBasicInfo user,int payment,String allExtParam,EnumPayWay payWay,EnumPayVersion payVersion, protected WxComposeOrder createDBMainOrder(TenantEntity tenantEntity,WxCUserBasicInfo user,int payment,String allExtParam,EnumPayWay payWay,EnumPayVersion payVersion,
EnumComposeOrder composeOrderType) { EnumComposeOrder composeOrderType) {
//判断是否poi订单
// Integer isTtPoiOrder = null;
// try{
// if(EnumPayWay.PAY_WAY_TT.equals(payWay) && isTtPoiOrder(tenantEntity,couponChannelMap)){
// isTtPoiOrder = EnumYesOrNo.YES.getCode();
// }
// }catch(Exception e){
// }


WxBatchOrder order =new WxBatchOrder(); WxBatchOrder order =new WxBatchOrder();
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
@@ -112,7 +104,10 @@ public abstract class BaseBatchOrderAdapterService implements OrderAdapterServic
order.setPayVendor(payWay.getCode()); order.setPayVendor(payWay.getCode());
order.setPayVersion(payVersion.getCode()); order.setPayVersion(payVersion.getCode());
order.setOrderType(composeOrderType.getCode()); order.setOrderType(composeOrderType.getCode());
// order.setIsTtPoiOrder(isTtPoiOrder);
if(EnumPayWay.PAY_WAY_TT.equals(payWay)){
order.setIsTtPoiOrder(EnumYesOrNo.YES.getCode());
}

order.setCreateDate(new Date()); order.setCreateDate(new Date());
order.setExtParam(allExtParam); order.setExtParam(allExtParam);
wxBatchOrderMapper.insert(order); wxBatchOrderMapper.insert(order);
@@ -122,19 +117,6 @@ public abstract class BaseBatchOrderAdapterService implements OrderAdapterServic
return composeOrder; return composeOrder;
} }


//判断是否poi订单
private boolean isTtPoiOrder(TenantEntity tenantEntity,Map<Long,WxCouponChannel> couponChannelMap){
boolean isTtPoiOrder = false;
if(null != couponChannelMap){
List<Long> couponChannelIds = new ArrayList<>(couponChannelMap.keySet());
Integer poiCount = ttCouponChannelPoiMapper.getPoiPutOnCount(tenantEntity.getTenantId(),couponChannelIds);
if(couponChannelIds.size() == poiCount.intValue()){
isTtPoiOrder = true;
}
}
return isTtPoiOrder;
}

protected WxComposeOrder getComposeOrder(Long mainOrderId, String tenantId,EnumComposeOrder composeOrderType) { protected WxComposeOrder getComposeOrder(Long mainOrderId, String tenantId,EnumComposeOrder composeOrderType) {
WxBatchOrder order = wxBatchOrderMapper.selectById(mainOrderId, tenantId); WxBatchOrder order = wxBatchOrderMapper.selectById(mainOrderId, tenantId);
WxComposeOrder corder = new WxComposeOrder(order.getId(),composeOrderType.getCode(),order.getPayment()); WxComposeOrder corder = new WxComposeOrder(order.getId(),composeOrderType.getCode(),order.getPayment());


+ 10
- 11
mallinkService/src/main/java/com/iformall/service/pay/service/pay/douyin/v1/miniApp/TtMiniAppPayAdapterService.java Vedi File

@@ -17,6 +17,7 @@ import com.iformall.douyin.payv2.result.TtPayUnifiedOrderV2Result;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.mapper.*; import com.iformall.mapper.*;
import com.iformall.service.WxCouponService;
import com.iformall.service.order.OrderAdapterService; import com.iformall.service.order.OrderAdapterService;
import com.iformall.service.order.OrderFactory; import com.iformall.service.order.OrderFactory;
import com.iformall.service.order.entity.WxComposeOrder; import com.iformall.service.order.entity.WxComposeOrder;
@@ -62,6 +63,9 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen
@Autowired @Autowired
private WxCouponMapper wxCouponMapper; private WxCouponMapper wxCouponMapper;


@Autowired
private WxCouponService wxCouponService;

@Autowired @Autowired
private WxOrderMapper wxOrderMapper; private WxOrderMapper wxOrderMapper;


@@ -452,20 +456,15 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen
payment.put("totalAmount",composeOrder.getPayment()); payment.put("totalAmount",composeOrder.getPayment());
map.put("payment",payment); map.put("payment",payment);
List<Map<String,Object>> goodsList = new ArrayList<>(); List<Map<String,Object>> goodsList = new ArrayList<>();
Map<Long, List<WxOrder>> collect = childOrders.stream().collect(groupingBy(WxOrder::getCouponChannelId));
for (Long key: collect.keySet()) {
for (WxOrder o: childOrders) {
WxCoupon wxCoupon = wxCouponService.getById(o.getProductId(), record.getTenantId());
Map<String,Object> good = new HashMap<>(); Map<String,Object> good = new HashMap<>();
Long couponId = wxCouponChannelMapper.findCouponIdById(key, record.getTenantId());
WxCoupon wxCoupon = wxCouponMapper.selectById(couponId, record.getTenantId());
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(record.getTenantId(), couponId);
int quantity = collect.get(key).size();
good.put("quantity",quantity);
good.put("price",wxCoupon.getSalePrice()*quantity);
good.put("quantity",o.getCouponNumber());
good.put("price",o.getPayment());
good.put("goodsName",wxCoupon.getTitle()); good.put("goodsName",wxCoupon.getTitle());
good.put("goodsPhoto",wxCoupon.getCoverImg()); good.put("goodsPhoto",wxCoupon.getCoverImg());
good.put("goodsId",ttCouponChannelPoi.getSpuId());
// good.put("goodsId",wxCoupon.getId().toString());
good.put("goodsType",1);
good.put("goodsId",wxCoupon.getGoodsId());
good.put("goodsType",composeOrder.getMainOrder().getIsTtPoiOrder());
goodsList.add(good); goodsList.add(good);
} }
map.put("goodsList",goodsList); map.put("goodsList",goodsList);


+ 3
- 2
mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareBaseAdapterService.java Vedi File

@@ -21,6 +21,7 @@ import com.iformall.mapper.WxProfitSharingReceiverMapper;
import com.iformall.pay.WxPayment; import com.iformall.pay.WxPayment;
import com.iformall.pay.WxProfitSharing; import com.iformall.pay.WxProfitSharing;
import com.iformall.pay.WxProfitSharingReceiverP; import com.iformall.pay.WxProfitSharingReceiverP;
import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.service.pay.service.share.entity.PayShareQueryResultReceivers; import com.iformall.service.pay.service.share.entity.PayShareQueryResultReceivers;
import com.iformall.service.pay.service.share.entity.ShareAccountResult; import com.iformall.service.pay.service.share.entity.ShareAccountResult;
import com.iformall.service.pay.service.share.wx.v2.WxPayShareService; import com.iformall.service.pay.service.share.wx.v2.WxPayShareService;
@@ -186,7 +187,7 @@ public abstract class PayShareBaseAdapterService implements PayShareAdapterServi
return new ShareAccountResult(true, null, "success", returnMap); return new ShareAccountResult(true, null, "success", returnMap);
} }
protected ShareAccountResult _deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount,WxProfitSharingReceiver receiver,WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper) {
protected ShareAccountResult _deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount, WxProfitSharingReceiver receiver, WxProfitSharingReceiverService wxProfitSharingReceiverService) {
//删除分账账户从微信服务器 //删除分账账户从微信服务器
WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP();
if (StringUtils.isNotBlank(appInfo.getParentAppId())) { if (StringUtils.isNotBlank(appInfo.getParentAppId())) {
@@ -227,7 +228,7 @@ public abstract class PayShareBaseAdapterService implements PayShareAdapterServi
if (returnMap.get("err_code").contains("USER_NOT_EXIST")) { if (returnMap.get("err_code").contains("USER_NOT_EXIST")) {
receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode());
receiver.setUpdateTime(new Date()); receiver.setUpdateTime(new Date());
wxProfitSharingReceiverMapper.updateById(receiver);
wxProfitSharingReceiverService.saveOrUpdate(receiver);
} }
log.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("err_code_des")+":"+JSON.toJSONString(returnMap)); log.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("err_code_des")+":"+JSON.toJSONString(returnMap));
return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("err_code_des"), null); return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("err_code_des"), null);


+ 19
- 35
mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java Vedi File

@@ -32,12 +32,12 @@ import com.iformall.service.pay.service.share.entity.PayShareQueryResult;
import com.iformall.service.pay.service.share.entity.PayShareResult; import com.iformall.service.pay.service.share.entity.PayShareResult;
import com.iformall.service.pay.service.share.entity.ShareAccountResult; import com.iformall.service.pay.service.share.entity.ShareAccountResult;
import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult;
import com.iformall.utils.DateUtils;
import com.iformall.utils.MaUtil;
import com.iformall.utils.PayUtils;
import com.iformall.utils.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.*; import java.util.*;
@@ -68,9 +68,6 @@ public class TtPayShareService extends PayShareBaseAdapterService{
@Autowired @Autowired
WxProfitSharingOrderMapper wxProfitSharingOrderMapper; WxProfitSharingOrderMapper wxProfitSharingOrderMapper;


@Autowired
WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper;

@Autowired @Autowired
TtGoodsCategoryMapper ttGoodsCategoryMapper; TtGoodsCategoryMapper ttGoodsCategoryMapper;


@@ -281,8 +278,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{
if(!EnumOrderType.COUPON.getCode().equals(o.getType())){ if(!EnumOrderType.COUPON.getCode().equals(o.getType())){
return 0; return 0;
} }
Long couponId = wxCouponChannelMapper.findCouponIdById(o.getCouponChannelId(), o.getTenantId());
Integer categoryId = wxCouponMapper.findCategoryIdById(couponId,o.getTenantId());
Integer categoryId = wxCouponMapper.findCategoryIdById(o.getProductId(),o.getTenantId());
if(categoryId != null){ if(categoryId != null){
TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(categoryId); TtGoodsCategory ttGoodsCategory = ttGoodsCategoryMapper.selectById(categoryId);
if(ttGoodsCategory != null && ttGoodsCategory.getServiceFee() != null){ if(ttGoodsCategory != null && ttGoodsCategory.getServiceFee() != null){
@@ -304,38 +300,26 @@ public class TtPayShareService extends PayShareBaseAdapterService{
if(merchantId == null || merchantId.equals(0L)){ if(merchantId == null || merchantId.equals(0L)){
return null; return null;
} }
WxProfitSharingReceiver record = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.TOUTIAO,EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN);


WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver();
psReceiverQ.updateTenantInfo(tenantEntity);
psReceiverQ.setMerchantId(merchantId);
psReceiverQ.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_DOUYIN.getCode());
psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
psReceiverQ.setPlat(EnumAppPlat.TOUTIAO.getCode());
String payMsg = "";
if(ttPayWay != null){ if(ttPayWay != null){
if(EnumTtPayChannel.WX_PAY.getCode().equals(ttPayWay)){
payMsg = EnumTtPayChannel.WX_PAY.getMessage();
psReceiverQ.setWxImportStatus(MerchantImportStatus.improt_success.getCode());
}else if(EnumTtPayChannel.ALI_PAY.getCode().equals(ttPayWay)){
payMsg = EnumTtPayChannel.ALI_PAY.getMessage();
psReceiverQ.setAlipayImportStatus(MerchantImportStatus.improt_success.getCode());
}else if(EnumTtPayChannel.HZ_PAY.getCode().equals(ttPayWay)){
payMsg = EnumTtPayChannel.HZ_PAY.getMessage();
psReceiverQ.setHzImportStatus(MerchantImportStatus.improt_success.getCode());
}else{
log.error("该订单支付方式异常{}");
if(EnumTtPayChannel.WX_PAY.getCode().equals(ttPayWay)
&& !MerchantImportStatus.improt_success.getCode().equals(record.getWxImportStatus())){
log.error("支付方式【"+EnumTtPayChannel.WX_PAY.getMessage()+"】未开通");
return null;
}else if(EnumTtPayChannel.ALI_PAY.getCode().equals(ttPayWay)
&& !MerchantImportStatus.improt_success.getCode().equals(record.getAlipayImportStatus())){
log.error("支付方式【"+EnumTtPayChannel.ALI_PAY.getMessage()+"】未开通");
return null;
}else if(EnumTtPayChannel.HZ_PAY.getCode().equals(ttPayWay)
&& !MerchantImportStatus.improt_success.getCode().equals(record.getHzImportStatus())){
log.error("支付方式【"+EnumTtPayChannel.HZ_PAY.getMessage()+"】未开通");
return null;
} }
} }
return record;


List<WxProfitSharingReceiver> list = wxProfitSharingReceiverMapper.findList(psReceiverQ);
if(list == null || list.isEmpty()){
return null;
// throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未未进件."+payMsg);
}
if(list.size() > 1){
throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_UNKNOWN.getCode(),"该商户分账帐号异常.");
}
return list.get(0);
} }


} }

+ 10
- 27
mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java Vedi File

@@ -12,9 +12,13 @@ import com.iformall.douyin.pay.enums.MerchantImportStatus;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.mapper.*; import com.iformall.mapper.*;


import com.iformall.service.WxProfitSharingReceiverService;
import com.iformall.utils.*;
import net.sf.saxon.trans.Err; import net.sf.saxon.trans.Err;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@@ -38,9 +42,6 @@ import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount;
import com.iformall.service.pay.service.share.entity.PayShareQueryResult; import com.iformall.service.pay.service.share.entity.PayShareQueryResult;
import com.iformall.service.pay.service.share.entity.PayShareResult; import com.iformall.service.pay.service.share.entity.PayShareResult;
import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;


import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;


@@ -49,7 +50,7 @@ import lombok.extern.slf4j.Slf4j;
public class WxPayShareService extends PayShareBaseAdapterService{ public class WxPayShareService extends PayShareBaseAdapterService{


@Autowired @Autowired
WxProfitSharingOrderMapper wxProfitSharingOrderMapper;
WxProfitSharingReceiverService wxProfitSharingReceiverService;


final JSONObject statusMap = JSON.parseObject( final JSONObject statusMap = JSON.parseObject(
"{\"ACCEPTED\":3," + "{\"ACCEPTED\":3," +
@@ -338,13 +339,10 @@ public class WxPayShareService extends PayShareBaseAdapterService{
public ShareAccountResult createShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver) { public ShareAccountResult createShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver) {
return super._createShareAccount(appInfo, payAccount, receiver); return super._createShareAccount(appInfo, payAccount, receiver);
} }

@Autowired
WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper;
@Override @Override
public ShareAccountResult deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount,WxProfitSharingReceiver receiver) { public ShareAccountResult deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount,WxProfitSharingReceiver receiver) {
return super._deleteShareAccount(appInfo, payAccount, receiver,wxProfitSharingReceiverMapper);
return super._deleteShareAccount(appInfo, payAccount, receiver,wxProfitSharingReceiverService);
} }


@Override @Override
@@ -357,31 +355,16 @@ public class WxPayShareService extends PayShareBaseAdapterService{
return 0; return 0;
} }



@Override @Override
public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) { public WxProfitSharingReceiver getReceiver(TenantEntity tenantEntity, Long merchantId, Integer ttPayWay,Integer mchType) {
if(merchantId == null || merchantId.equals(0L)){ if(merchantId == null || merchantId.equals(0L)){
return null; return null;
} }
WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver();
psReceiverQ.updateTenantInfo(tenantEntity);
psReceiverQ.setMerchantId(merchantId);
psReceiverQ.setSharingType(EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT.getCode());
psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode());
psReceiverQ.setPlat(EnumAppPlat.WX.getCode());
List<WxProfitSharingReceiver> psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ);
if (null == psReceiverList || psReceiverList.size() == 0) {
return null;
// throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号.");
}else {
for (WxProfitSharingReceiver receiver:psReceiverList) {
if (EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().intValue()
== receiver.getReceiverType().intValue()) {
throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置.");
}
}
WxProfitSharingReceiver record = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT);
if(record != null && EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().equals(record.getReceiverType())){
throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置.");
} }
return psReceiverList.get(0);
return record;
} }


private static String queryOrderShareAmount(String mchId,String transcationId,String apiKey) { private static String queryOrderShareAmount(String mchId,String transcationId,String apiKey) {


+ 13
- 15
mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java Vedi File

@@ -14,9 +14,13 @@ import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.mapper.*; import com.iformall.mapper.*;
import com.iformall.utils.Constant;
import com.iformall.utils.RedisCacheUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@@ -44,9 +48,6 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@Service @Service
public class WxPayShareV3Service extends PayShareBaseAdapterService{ public class WxPayShareV3Service extends PayShareBaseAdapterService{

@Autowired
WxProfitSharingOrderMapper wxProfitSharingOrderMapper;
@Lazy @Lazy
@Autowired @Autowired
@@ -82,19 +83,19 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
if(merchantId == null || merchantId.equals(0L)){ if(merchantId == null || merchantId.equals(0L)){
return null; return null;
} }
WxProfitSharingReceiver receiver = null;
//直连,必须是特约商户号 //直连,必须是特约商户号
// if (EnumPayMchType.DIRECT.getCode() == mchType) {
receiver = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
//总分
// }else if (EnumPayMchType.TOTAL.getCode() == mchType) {
// receiver = wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT);
// }
if (EnumPayMchType.DIRECT.getCode() == mchType) {
return wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT_v2);
// 总分
}else if (EnumPayMchType.TOTAL.getCode() == mchType) {
return wxProfitSharingReceiverService.findReceiver(tenantEntity, merchantId,EnumAppPlat.WX,EnumProfitSharingType.PROFIT_SHARING_TYPE_WECHAT);
}


// if (null == receiver) { // if (null == receiver) {
// throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号."); // throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号.");
// } // }
return receiver;
return null;
} }


//无需分账,直接解冻 //无需分账,直接解冻
@@ -300,9 +301,6 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
return super._createShareAccount(appInfo, payAccount, receiver); return super._createShareAccount(appInfo, payAccount, receiver);
} }
} }

@Autowired
WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper;
@Override @Override
public ShareAccountResult deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount, public ShareAccountResult deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount,
@@ -312,7 +310,7 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{
return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), "微信支付3.0直连模式下不支持", null); return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), "微信支付3.0直连模式下不支持", null);
//总分 //总分
}else { }else {
return super._deleteShareAccount(appInfo, payAccount, receiver, wxProfitSharingReceiverMapper);
return super._deleteShareAccount(appInfo, payAccount, receiver, wxProfitSharingReceiverService);
} }
} }




+ 1
- 0
mallinkService/src/main/java/com/iformall/utils/Constant.java Vedi File

@@ -98,6 +98,7 @@ public class Constant {
//获取mall信息 //获取mall信息
public static final String appinfoPrev = "appinfo:"; public static final String appinfoPrev = "appinfo:";
public static final String payaccountPrev = "payaccount:"; public static final String payaccountPrev = "payaccount:";
public static final String sharingReceicerPrev = "sharingReceicer:";
public static final String mallinfoPrev = "mallinfo:"; public static final String mallinfoPrev = "mallinfo:";
public static final String subMallinfoPrev = "mallinfo:subMallinfo:"; public static final String subMallinfoPrev = "mallinfo:subMallinfo:";




Caricamento…
Annulla
Salva