|
|
|
@@ -4,18 +4,19 @@ import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.dto.WxSharingOrderDto; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.enums.EnumCouponMerchantStatus; |
|
|
|
import com.iformall.enums.EnumCouponType; |
|
|
|
import com.iformall.enums.EnumMerchantSubsidyStatus; |
|
|
|
import com.iformall.enums.EnumOrderType; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.mapper.*; |
|
|
|
import com.iformall.service.WxCardSpendService; |
|
|
|
import com.iformall.service.WxProfitSharingOrderService; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
@@ -33,12 +34,21 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
@Autowired |
|
|
|
WxCouponMapper wxCouponMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMerchantMapper wxMerchantMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponMerchantMapper wxCouponMerchantMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxPayAccountMapper payAccountMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxOrderMapper wxOrderMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxProfitSharingOrderService profitSharingOrderService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCUser user) { |
|
|
|
Date curDate = new Date(); |
|
|
|
@@ -141,6 +151,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
merchantSubsidy.setUpdateDate(curDate); |
|
|
|
// 9. 分账 |
|
|
|
|
|
|
|
|
|
|
|
return new ResultData(record); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -171,10 +182,58 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
public void deleteById(Long id) { |
|
|
|
wxCardSpendMapper.deleteByPrimaryKey(id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public void shareForCardPay(String tenantId, Long cardId, Long orderId, Long cardSpendId) { |
|
|
|
// 微信已分账检查次数 |
|
|
|
int psNum = 0; |
|
|
|
try { |
|
|
|
WxCardSpend cardSpendQ = new WxCardSpend(); |
|
|
|
cardSpendQ.setCardId(cardId); |
|
|
|
psNum = wxCardSpendMapper.selectCount(cardSpendQ); |
|
|
|
if (psNum >= 20) { |
|
|
|
logger.error("微信分账已超过限制次数-20次"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
} |
|
|
|
// 微信分账 |
|
|
|
try { |
|
|
|
WxCardSpend cardSpend = new WxCardSpend(); |
|
|
|
cardSpend.setTenantId(tenantId); |
|
|
|
cardSpend.setId(cardSpendId); |
|
|
|
cardSpend.setCardId(cardId); |
|
|
|
cardSpend.setOrderId(orderId); |
|
|
|
cardSpend = wxCardSpendMapper.selectOne(cardSpend); |
|
|
|
WxCardInfo cardInfo = wxCardInfoMapper.selectByPrimaryKey(cardSpend.getCardId()); |
|
|
|
WxOrder wxOrder = wxOrderMapper.selectByPrimaryKey(orderId); |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(cardSpend.getMerchantId()); |
|
|
|
|
|
|
|
if (cardSpend != null && cardInfo != null && merchant != null) { |
|
|
|
WxSharingOrderDto shareOrder = new WxSharingOrderDto(); |
|
|
|
shareOrder.setcUserId(cardSpend.getOwnerId()); |
|
|
|
shareOrder.setMerchantId(cardSpend.getMerchantId()); |
|
|
|
shareOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); |
|
|
|
shareOrder.setPayAmount(cardSpend.getRealPayment()); |
|
|
|
shareOrder.setOrderId(cardSpend.getOrderId()); |
|
|
|
shareOrder.setPayTimeStart(cardSpend.getCreateDate()); |
|
|
|
shareOrder.setPayTimeEnd(cardSpend.getUpdateDate()); |
|
|
|
shareOrder.setTenantId(tenantId); |
|
|
|
shareOrder.setTransactionId(cardInfo.getTransactionId()); |
|
|
|
shareOrder.setShareAmount(cardSpend.getRealPayment()); |
|
|
|
profitSharingOrderService.createSharingOrder(shareOrder); |
|
|
|
} else { |
|
|
|
logger.error("微信分账: 未找到payorder or merchant at orderid-" + orderId); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("微信分账: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|