| @@ -138,7 +138,7 @@ public class WxMerchantController extends BaseController { | |||
| WxMerchant merchant = new WxMerchant(); | |||
| merchant.setId(user.getMerchantId()); | |||
| WxMerchant wxMerchant = wxMerchantService.findOne(merchant); | |||
| return wxMerchant != null && buser.getPhone().equals(wxMerchant.getLinkPhone()); | |||
| return wxMerchant != null && wxMerchant.getLinkPhone().equals(buser.getPhone()); | |||
| } | |||
| } | |||
| @@ -209,6 +209,7 @@ public class CouponOrderExpiringSchedule { | |||
| wxPayOrder.setOrderId(orderId); | |||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| wxPayOrder = wxPayOrderMapper.selectOne(new QueryWrapper(wxPayOrder)); | |||
| if (wxPayOrder != null && wxPayOrder.getShare().equals(EnumPayShare.YES.getCode())) { | |||
| WxSharingOrderDto wxSharingOrderDto = new WxSharingOrderDto(); | |||
| wxSharingOrderDto.setCUserId(wxPayOrder.getCUserId()); | |||
| @@ -228,6 +229,8 @@ public class CouponOrderExpiringSchedule { | |||
| wxSharingOrderDto.setShareAmount(wxPayOrder.getChildOrderShare(co.getOrderId()).getShareAmount()); | |||
| } | |||
| wxProfitSharingOrderService.finishSharingOrder(wxSharingOrderDto,wxPayOrder.getPayVendor()); | |||
| }else if (wxPayOrder != null){ | |||
| wxProfitSharingOrderService.finishDouyinSharingOrder(wxPayOrder); | |||
| } | |||
| } catch (MallinkException e) { | |||
| @@ -90,6 +90,26 @@ public class SharingOrderRedoSchedule { | |||
| } | |||
| }); | |||
| } | |||
| wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_DOUYIN_SINGLE.getCode()); | |||
| wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); | |||
| list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); | |||
| if (null != list) { | |||
| list.stream().forEach(sharingOrder->{ | |||
| try { | |||
| ResultData result = wxProfitSharingOrderService.redoDouyinSharingOrder(sharingOrder); | |||
| if (result.code != ResultData.SUCCESS) { | |||
| logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_DOUYIN_SINGLE.getMessage() | |||
| + " ID:" +sharingOrder.getId() | |||
| + " RES:" + result.message); | |||
| } | |||
| } catch (Exception e){ | |||
| logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_DOUYIN_SINGLE.getMessage() | |||
| + " ID:" +sharingOrder.getId() | |||
| + " MSG:" + e.getMessage()); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| } | |||
| @@ -55,7 +55,9 @@ public class WxOrder extends TenantEntity { | |||
| private Long productId; | |||
| @io.swagger.annotations.ApiModelProperty(value="类型(0:券,1:B刷卡支付,2:C扫码支付,3:储值卡, 10:POS支付)",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value = "支付渠道EnumPayWay", name = "payVendor") | |||
| //历史数据可能为空 | |||
| private Integer payVendor; | |||
| @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") | |||
| private Integer paymentType; | |||
| @@ -8,6 +8,7 @@ public enum EnumProfitSharingOrderType { | |||
| PROFIT_SHARING_MULTI(1, "多次分账"), | |||
| PROFIT_SHARING_MULTI_FINISH(2, "多次分账完结"), | |||
| PROFIT_SHARING_SINGLE_FINISH(3, "单次分账完结"), | |||
| PROFIT_SHARING_DOUYIN_SINGLE(10, "抖音自主分账"),//不分账无法解冻资金 | |||
| ; | |||
| @@ -4,6 +4,7 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxSharingOrderDto; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.domain.po.WxProfitSharingOrder; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxProfitSharingOrderQueryVo; | |||
| @@ -26,6 +27,7 @@ public interface WxProfitSharingOrderService { | |||
| * 分账重试 | |||
| */ | |||
| ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder); | |||
| ResultData redoDouyinSharingOrder(WxProfitSharingOrder sharingOrder); | |||
| /** | |||
| * 查询分账订单 | |||
| @@ -36,6 +38,7 @@ public interface WxProfitSharingOrderService { | |||
| * 结束分账订单 | |||
| */ | |||
| ResultData finishSharingOrder(WxSharingOrderDto sharingOrderDto,Integer payway); | |||
| ResultData finishDouyinSharingOrder(WxPayOrder wxPayOrder); | |||
| PageInfo<WxProfitSharingOrderVo> listAsPage(WxProfitSharingOrderQueryVo order, Integer pageNum, Integer pageSize); | |||
| @@ -47,6 +50,5 @@ public interface WxProfitSharingOrderService { | |||
| ResultData findOrderDetails(Long id,String tenantId); | |||
| void updatetttttttttttttt(String tenantId); | |||
| } | |||
| @@ -681,7 +681,19 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| // 核销记账,并且往账户里面记帐 | |||
| if (couponOrder.getCouponPrice() > 0) { | |||
| recordAfterVerified(couponOrder, merchant.getId()); | |||
| WxPayOrder wxPayOrder = new WxPayOrder(); | |||
| Long orderId = couponOrder.getOrderId(); | |||
| if (!EnumComposeOrder.isSingle(couponOrder.getComposeOrderType())) { | |||
| orderId = couponOrder.getComposeOrderId(); | |||
| } | |||
| wxPayOrder.updateTenantInfo(couponOrder); | |||
| wxPayOrder.setOrderId(orderId); | |||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| wxPayOrder = wxPayOrderMapper.selectOne(new QueryWrapper(wxPayOrder)); | |||
| wxProfitSharingOrderService.finishDouyinSharingOrder(wxPayOrder); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("核销记账失败"+e.getMessage(),e); | |||
| } | |||
| @@ -133,7 +133,8 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| WxAppinfo appinfo; | |||
| Integer payWay; | |||
| if (wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()) | |||
| ||wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE_FINISH.getCode())){ | |||
| || wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE_FINISH.getCode()) | |||
| || wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_DOUYIN_SINGLE.getCode())){ | |||
| WxPayOrder wxPayOrder = wxPayOrderMapper.selectById(wxProfitSharingOrder.getOrderId(),wxProfitSharingOrder.getTenantId()); | |||
| if (wxPayOrder == null) | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(),"wxProfitSharingOrder["+wxProfitSharingOrder.getId()+"] 没有payOrder信息."); | |||
| @@ -223,6 +224,37 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return new ResultData(shareResult.getData()); | |||
| } | |||
| @Override | |||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public ResultData redoDouyinSharingOrder(WxProfitSharingOrder sharingOrder) { | |||
| if (!sharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_DOUYIN_SINGLE.getCode())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| WxProfitShareAppInoDto dto = getAppinfo(sharingOrder); | |||
| WxAppinfo appInfo = dto.getAppinfo(); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| PayShareResult shareResult = payServiceFactory.getPayShareAdapterService(dto.getPayWay()) | |||
| .noReciverShare(appInfo, payAccount,sharingOrder,sharingOrder.getTransactionId(),sharingOrder.getPayAmount()); | |||
| if (!shareResult.isSuccess()) { | |||
| sharingOrder.setSharingStatus(shareResult.getCode()); | |||
| sharingOrder.setErrorMsg("REDO:"+shareResult.getMsg()); | |||
| sharingOrder.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateById(sharingOrder); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),sharingOrder.getErrorMsg()); | |||
| } | |||
| sharingOrder.setSharingOrderNo(shareResult.getShareOrderNo()); | |||
| sharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode()); | |||
| sharingOrder.setErrorMsg("REDO:重试分账成功"); | |||
| sharingOrder.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateById(sharingOrder); | |||
| return new ResultData(shareResult.getData()); | |||
| } | |||
| @Override | |||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| @@ -507,6 +539,55 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return new ResultData(shareResult.getData()); | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData finishDouyinSharingOrder(WxPayOrder wxPayOrder) { | |||
| if(wxPayOrder == null || !EnumPayWay.PAY_WAY_TT.getCode().equals(wxPayOrder.getPayVendor())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| final IdWorker idworker = IdWorker.get(); | |||
| WxAppinfo appInfo = getAppinfo(wxPayOrder.getTenantId(),wxPayOrder.getPayVendor()); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| //分账检查是否已创建分账订单 | |||
| WxProfitSharingOrder record = new WxProfitSharingOrder(); | |||
| //创建分账订单 | |||
| Date currentDate = new Date(); | |||
| record.setId(idworker.nextId()); | |||
| record.updateTenantInfo(payAccount); | |||
| record.setTransactionId(wxPayOrder.getTransactionId()); | |||
| record.setPayAmount(wxPayOrder.getPayAmount()); | |||
| record.setMerchantId(0l); | |||
| record.setOrderId(wxPayOrder.getOrderId()); | |||
| record.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| record.setPayTimeStart(wxPayOrder.getPayTimeStart()); | |||
| record.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | |||
| record.setType(EnumProfitSharingOrderType.PROFIT_SHARING_DOUYIN_SINGLE.getCode()); | |||
| wxProfitSharingOrderMapper.insert(record); | |||
| //分账提交 | |||
| PayShareResult shareResult = payServiceFactory.getPayShareAdapterService(wxPayOrder.getPayVendor()).noReciverShare(appInfo,payAccount,record,wxPayOrder.getPayOrderNo(),wxPayOrder.getShareAmount()); | |||
| if (!shareResult.isSuccess()) { | |||
| record.setSharingStatus(shareResult.getCode()); | |||
| record.setErrorMsg(shareResult.getMsg()); | |||
| record.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateById(record); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),record.getErrorMsg()); | |||
| } | |||
| record.setSharingOrderNo(shareResult.getShareOrderNo()); | |||
| record.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_ACCEPTED.getCode()); | |||
| record.setUpdateTime(new Date()); | |||
| wxProfitSharingOrderMapper.updateById(record); | |||
| return new ResultData(shareResult.getData()); | |||
| } | |||
| @Override | |||
| public PageInfo<WxProfitSharingOrderVo> listAsPage(WxProfitSharingOrderQueryVo order, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingOrderMapper.findOrderList(order)); | |||
| @@ -60,7 +60,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||
| @Override | |||
| public PayShareResult haveReciversShare(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingOrder record,String transcationId,JSONArray receivers,EnumProfitSharingOrderType shareType ) throws MallinkException { | |||
| // TODO: 2021/11/27抖音分账暂时不支持 需要处理添加分账帐号和分账方式 | |||
| // TODO: 2021/11/27 需要处理添加分账帐号 | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_REQUEST_FAILED); | |||