| @@ -12,6 +12,7 @@ import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.domain.vo.WxMerchantTradeDetailVo; | |||
| import com.iformall.domain.vo.WxMerchantTradeVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.QrCodeService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.utils.Constant; | |||
| @@ -155,7 +156,7 @@ public class WxMerchantController extends BaseController { | |||
| public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); | |||
| } | |||
| @ApiOperation("更新管理员接口") | |||
| @@ -6,9 +6,11 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.vo.WxCouponOrderBVo; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumPayType; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCouponOrderService; | |||
| @@ -93,8 +95,15 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId); | |||
| if (wxCouponOrder == null) { | |||
| logger.error("券ID不存在:" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.updateTenantInfo(getTenantInfo()); | |||
| appinfoQ.setPlat(EnumPayWay.getEnum(wxCouponOrder.getPayVendor()).getPlat().getCode()); | |||
| appinfoQ.setType(EnumAppType.B.getCode()); | |||
| PageInfo<WxAppinfo> appinfoPageInfo = wxAppinfoService.listAsPage(appinfoQ, 1, 1); | |||
| if (appinfoPageInfo.getList().size() > 0) { | |||
| @@ -33,3 +33,11 @@ UPDATE wx_coupon_order o INNER JOIN wx_pay_order po ON po.order_id = o.`id` SET | |||
| ALTER TABLE `wx_card_spend` | |||
| ADD COLUMN `remark` VARCHAR(30) DEFAULT NULL COMMENT '备注'; | |||
| ALTER TABLE `wx_appinfo` | |||
| ADD COLUMN `plat` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT 'app平台 1:微信 2:阿里 3:头条'; | |||
| ALTER TABLE `wx_profit_sharing_receiver` | |||
| ADD COLUMN `plat` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT '平台 1:微信 2:阿里 3:头条'; | |||
| @@ -4,6 +4,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumMsgSend; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| @@ -72,7 +73,7 @@ public class WxMerchantController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "账号名称不能为空"); | |||
| } | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); | |||
| } | |||
| @ApiOperation("删除分账账户") | |||
| @@ -116,6 +116,7 @@ public class CouponOrderExpiringSchedule { | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.updateTenantInfo(co); | |||
| //appinfo.setType(EnumAppType.B.getCode()); | |||
| appinfo.setPlat(EnumPayWay.getEnum(co.getPayVendor()).getPlat().getCode()); | |||
| appinfo.setType(EnumAppType.C.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| @@ -18,10 +18,12 @@ import org.springframework.transaction.annotation.Transactional; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.enums.EnumPayStatus; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumRefundStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxAppinfoService; | |||
| @@ -324,9 +326,32 @@ public class OrderExpiringSchedule { | |||
| if (!wxPaySuccess(order,false)) { | |||
| return; | |||
| } | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.updateTenantInfo(order); | |||
| payOrderQ.setCUserId(order.getCUserId()); | |||
| payOrderQ.setOrderId(order.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| WxPayOrder payOrder = null; | |||
| List<WxPayOrder> list = wxPayOrderMapper.findList(payOrderQ); | |||
| if (list.size() > 0) { | |||
| if (list.size() > 1) { | |||
| logger.error("TODO: payOrder成功记录应该只有一条????!!!"); | |||
| } | |||
| logger.warn(""); | |||
| payOrder = list.get(0); | |||
| } | |||
| if (payOrder == null) { | |||
| logger.error("支付订单不存在(payOrder不存在)"); | |||
| return ; | |||
| } | |||
| //获取APP信息 | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.updateTenantInfo(order); | |||
| appinfo.setPlat(EnumPayWay.getEnum(payOrder.getPayVendor()).getPlat().getCode()); | |||
| appinfo.setType(EnumAppType.C.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| Date limitDate = DateUtils.getTimeAfterDays(360, order.getCreateDate()); | |||
| @@ -22,6 +22,7 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxUserVisit; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxUserVisitService; | |||
| @@ -44,5 +44,7 @@ public class WxAppinfo extends BaseTenantEntity { | |||
| private Integer groupSupport; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否启用(0:启用,1禁用)",name="enable") | |||
| private Integer enable; | |||
| @io.swagger.annotations.ApiModelProperty(value="app平台 EnumAppPlat ",name="plat") | |||
| private Integer plat; | |||
| } | |||
| @@ -39,6 +39,8 @@ public class WxProfitSharingReceiver extends TenantEntity { | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="分账参数,目前为分账比例(单位为万分之一)",name="parameter") | |||
| private String parameter; | |||
| @io.swagger.annotations.ApiModelProperty(value="平台 EnumAppPlat",name="plat") | |||
| private Integer plat; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="分账金额(分)",name="sharingAmount") | |||
| @@ -0,0 +1,29 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * app平台 | |||
| * @author alascor | |||
| */ | |||
| public enum EnumAppPlat { | |||
| WX(1,"微信"),ALI(2,"阿里"),TOUTIAO(3,"头条"); | |||
| EnumAppPlat(Integer code,String name) { | |||
| this.code = code; | |||
| this.name = name; | |||
| } | |||
| private Integer code; | |||
| private String name; | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public void setCode(Integer code) { | |||
| this.code = code; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| } | |||
| @@ -7,7 +7,7 @@ public enum EnumCardSpendFrom { | |||
| // 0:C端小程序扫一扫, 1:POS支付 | |||
| C(0, "小程序支付"), | |||
| C(0, "微信小程序支付"), | |||
| POS(1, "POS支付") | |||
| ; | |||
| @@ -19,6 +19,15 @@ public enum EnumCardSpendFrom { | |||
| } | |||
| return null; | |||
| } | |||
| public static EnumPayWay getPayWay(Integer code) { | |||
| for (EnumPayWay payWay:EnumPayWay.values()) { | |||
| if (null != payWay.getCardSpendFrom() && payWay.getCardSpendFrom().getCode().intValue() == code.intValue() ) { | |||
| return payWay; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| @@ -5,22 +5,22 @@ package com.iformall.enums; | |||
| */ | |||
| public enum EnumPayWay { | |||
| PAY_WAY_WECHAT(1, "微信小程序支付",EnumPayWayType.WX_MINIPAY), | |||
| PAY_WAY_WECHAT_MA(12, "微信小程序B端扫码支付",EnumPayWayType.WX_MINIPAY), | |||
| PAY_WAY_WECHAT_WAP(2, "微信H5",EnumPayWayType.WX_H5PAY), | |||
| PAY_WAY_ALIPAY(3, "支付宝",EnumPayWayType.ALI_MINIPAY), | |||
| PAY_WAY_ALIPAY_WAP(4, "支付宝H5",EnumPayWayType.ALI_H5PAY), | |||
| PAY_WAY_POS_B(10, "POS B端",EnumPayWayType.POS), | |||
| PAY_WAY_POS_NEU(11, "POS 东软",EnumPayWayType.NEU_POS), | |||
| PAY_WAY_NOT_UNPAY_MERCHANT(91, "商户注券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_VERRIFY(92, "核销发券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_B_MA(93, "B端扫码支付发券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_CAR_STOP(94, "停车发券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_SYSTEM_SEND(95, "系统定时发放券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_BATCH_SEND(96, "后台批量发券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_TRADE(97, "交易发券,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_PASSWD(98, "根据卡密兑换卡,无需支付",null), | |||
| PAY_WAY_NOT_UNPAY_CREDIT(99, "积分兑换券,无需支付",null) | |||
| PAY_WAY_WECHAT(1, "微信小程序支付",EnumPayWayType.WX_MINIPAY,EnumAppPlat.WX,EnumCardSpendFrom.C), | |||
| PAY_WAY_WECHAT_MA(12, "微信小程序B端扫码支付",EnumPayWayType.WX_MINIPAY,EnumAppPlat.WX,null), | |||
| PAY_WAY_WECHAT_WAP(2, "微信H5",EnumPayWayType.WX_H5PAY,EnumAppPlat.WX,null), | |||
| PAY_WAY_ALIPAY(3, "支付宝",EnumPayWayType.ALI_MINIPAY,EnumAppPlat.ALI,null), | |||
| PAY_WAY_ALIPAY_WAP(4, "支付宝H5",EnumPayWayType.ALI_H5PAY,EnumAppPlat.ALI,null), | |||
| PAY_WAY_POS_B(10, "POS B端",EnumPayWayType.POS,null,null), | |||
| PAY_WAY_POS_NEU(11, "POS 东软",EnumPayWayType.NEU_POS,null,EnumCardSpendFrom.POS), | |||
| PAY_WAY_NOT_UNPAY_MERCHANT(91, "商户注券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_VERRIFY(92, "核销发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_B_MA(93, "B端扫码支付发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_CAR_STOP(94, "停车发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_SYSTEM_SEND(95, "系统定时发放券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_BATCH_SEND(96, "后台批量发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_TRADE(97, "交易发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_PASSWD(98, "根据卡密兑换卡,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_CREDIT(99, "积分兑换券,无需支付",null,null,null) | |||
| ; | |||
| public static EnumPayWay getEnum(Integer code) { | |||
| @@ -32,14 +32,19 @@ public enum EnumPayWay { | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| private EnumPayWayType type; | |||
| private EnumAppPlat plat; | |||
| private EnumCardSpendFrom cardSpendFrom; | |||
| EnumPayWay(Integer code, String message,EnumPayWayType type) { | |||
| EnumPayWay(Integer code, String message,EnumPayWayType type,EnumAppPlat plat,EnumCardSpendFrom cardSpendFrom) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.type = type; | |||
| this.plat = plat; | |||
| this.cardSpendFrom = cardSpendFrom; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -54,6 +59,16 @@ public enum EnumPayWay { | |||
| return type; | |||
| } | |||
| public EnumAppPlat getPlat() { | |||
| return plat; | |||
| } | |||
| public EnumCardSpendFrom getCardSpendFrom() { | |||
| return cardSpendFrom; | |||
| } | |||
| public static enum EnumPayWayType { | |||
| WX_MINIPAY,WX_H5PAY,ALI_MINIPAY,ALI_H5PAY,NEU_POS,POS | |||
| @@ -10,6 +10,8 @@ import com.iformall.domain.vo.WxMerchantSimpleVo; | |||
| import com.iformall.domain.vo.WxMerchantTradeDetailVo; | |||
| import com.iformall.domain.vo.WxMerchantTradeVo; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @@ -115,7 +117,7 @@ public interface WxMerchantService { | |||
| ResultData updateMerchant(WxMerchant wxMerchant); | |||
| ResultData updateMerchantAccount(WxMerchant wxMerchant); | |||
| ResultData updateMerchantAccount(WxMerchant wxMerchant,EnumPayWay payWay); | |||
| ResultData updateMerchantAdmin(WxMerchant wxMerchant); | |||
| @@ -5,6 +5,7 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import java.util.List; | |||
| @@ -44,11 +45,11 @@ public interface WxProfitSharingReceiverService { | |||
| WxProfitSharingReceiver findReceiver(WxMerchant merchant); | |||
| ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList); | |||
| ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList,EnumPayWay payWay); | |||
| ResultData delReceiver(WxProfitSharingReceiver receiver, Integer send); | |||
| ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver); | |||
| ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver,EnumPayWay payWay); | |||
| void sendMsg(String phone, String account, String merchant, String time, Integer modelType, TenantEntity tenantEntity); | |||
| @@ -457,7 +457,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public ResultData updateMerchantAccount(WxMerchant wxMerchant) { | |||
| public ResultData updateMerchantAccount(WxMerchant wxMerchant,EnumPayWay payWay) { | |||
| try { | |||
| if (wxMerchant.getId() == null) { | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| @@ -473,7 +473,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| receiver.setReceiverType(wxMerchant.getAccountTypeValue()); | |||
| receiver.setTrueName(wxMerchant.getAccountName()); | |||
| receiver.setParameter(wxMerchant.getAccountParameter()); | |||
| return wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver); | |||
| return wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver,payWay); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("db failed: 账户操作失败, e:" + e.getMessage()); | |||
| @@ -67,6 +67,9 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { | |||
| @Autowired | |||
| WxCouponChannelMapper wxCouponChannelMapper; | |||
| @Autowired | |||
| WxPayOrderMapper wxPayOrderMapper; | |||
| private int updateOrderGroup(WxOrderGroup wxOrderGroup,WxOrder order, WxCoupon wxCoupon) { | |||
| //锁住人数 | |||
| @@ -393,11 +396,9 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { | |||
| order.setOrderGroupId(group.getId()); | |||
| order.setOrderStatus(group.getStatus()); | |||
| wxOrderMapper.updateStatusByOrderGroupId(order); | |||
| //获取APP信息 | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.setTenantId(order.getTenantId()); | |||
| appinfo.setType(EnumAppType.C.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| WxAppinfo appinfo =null; | |||
| //退款流程 | |||
| WxOrder wxOrder = new WxOrder(); | |||
| wxOrder.setTenantId(group.getTenantId()); | |||
| @@ -408,6 +409,37 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { | |||
| || temp.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode())) { | |||
| boolean has = wxRefundOrderService.hasRefundOrder(order.getId(), EnumRefundStatus.REFUND_SUCCESS.getCode()); | |||
| if (!has) { | |||
| // 查找支付订单 | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.updateTenantInfo(wxOrder); | |||
| payOrderQ.setCUserId(wxOrder.getCUserId()); | |||
| payOrderQ.setOrderId(wxOrder.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| WxPayOrder payOrder = null; | |||
| List<WxPayOrder> payOrderlist = wxPayOrderMapper.findList(payOrderQ); | |||
| if (list.size() > 0) { | |||
| if (list.size() > 1) { | |||
| logger.error("TODO: payOrder成功记录应该只有一条????!!!"); | |||
| } | |||
| logger.warn(""); | |||
| payOrder = payOrderlist.get(0); | |||
| } | |||
| if (payOrder == null) { | |||
| logger.error("支付订单不存在(payOrder不存在)"); | |||
| return ; | |||
| } | |||
| //获取APP信息 | |||
| if (null == appinfo) { | |||
| appinfo = new WxAppinfo(); | |||
| appinfo.setTenantId(order.getTenantId()); | |||
| appinfo.setPlat(EnumPayWay.getEnum(payOrder.getPayVendor()).getPlat().getCode()); | |||
| appinfo.setType(EnumAppType.C.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| } | |||
| //去库存 | |||
| wxOrderService.stockBack(temp); | |||
| wxRefundOrderService.returnMoney(appinfo, temp.getId()); | |||
| @@ -1318,19 +1318,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| } | |||
| private WxAppinfo getWxAppinfo(Integer orderType, String tenentId) { | |||
| WxAppinfo appInfo = null; | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setTenantId(tenentId); | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| List<WxAppinfo> appList = wxAppinfoMapper.selectList(new QueryWrapper(appinfoQ)); | |||
| if (appList.size() > 0) { | |||
| appInfo = appList.get(0); | |||
| } | |||
| return appInfo; | |||
| } | |||
| @Override | |||
| public PageInfo<WxPayOrder> listAsPage(WxPayOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPayOrderMapper.findList(record)); | |||
| @@ -108,14 +108,11 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| private WxAppinfo getAppinfo(Long cUserId) { | |||
| private WxAppinfo getAppinfo(String tenantId,Integer payWay) { | |||
| WxAppinfo wxAppinfo = new WxAppinfo(); | |||
| WxCUser wxCUser = wxCUserMapper.selectById(cUserId); | |||
| if (wxCUser == null) | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| wxAppinfo.setAppId(wxCUser.getAppId()); | |||
| wxAppinfo.setTenantId(tenantId); | |||
| wxAppinfo.setPlat(EnumPayWay.getEnum(payWay).getPlat().getCode()); | |||
| wxAppinfo.setType(EnumAppType.C.getCode()); | |||
| wxAppinfo = wxAppinfoMapper.selectOne(new QueryWrapper(wxAppinfo)); | |||
| if (wxAppinfo == null) | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| @@ -135,7 +132,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| } | |||
| WxPayOrder payOrder = wxPayOrderMapper.selectById(sharingOrder.getOrderId()); | |||
| WxAppinfo appInfo = getAppinfo(payOrder.getCUserId()); | |||
| WxAppinfo appInfo = getAppinfo(payOrder.getTenantId(),payOrder.getPayVendor()); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| List<JSONObject> receivers; | |||
| @@ -251,7 +248,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| WxAppinfo appInfo = getAppinfo(sharingOrderDto.getCUserId()); | |||
| WxAppinfo appInfo = getAppinfo(sharingOrderDto.getTenantId(),payWay); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| //准备分账列表 | |||
| @@ -389,13 +386,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| WxPayOrder wxPayOrder = wxPayOrderMapper.selectById(wxProfitSharingOrder.getOrderId()); | |||
| if (wxPayOrder == null) | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| appInfo = getAppinfo(wxPayOrder.getCUserId()); | |||
| appInfo = getAppinfo(wxPayOrder.getTenantId(),wxPayOrder.getPayVendor()); | |||
| } else if(wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()) | |||
| ||wxProfitSharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI_FINISH.getCode())){ | |||
| WxCardSpend wxCardSpend = wxCardSpendMapper.selectById(wxProfitSharingOrder.getOrderId()); | |||
| if (wxCardSpend == null) | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| appInfo = getAppinfo(wxCardSpend.getOwnerId()); | |||
| appInfo = getAppinfo(wxCardSpend.getTenantId(),EnumCardSpendFrom.getPayWay(wxCardSpend.getPayFrom()).getCode()); | |||
| } else { | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_QUERY_UNKNOWN_TYPE); | |||
| } | |||
| @@ -527,7 +524,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| WxAppinfo appInfo = getAppinfo(sharingOrderDto.getCUserId()); | |||
| WxAppinfo appInfo = getAppinfo(sharingOrderDto.getTenantId(),payWay); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| @@ -26,6 +26,8 @@ import com.iformall.pay.WxPayment; | |||
| import com.iformall.pay.WxProfitSharing; | |||
| import com.iformall.pay.WxProfitSharingReceiverP; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | |||
| import com.iformall.utils.BeanUtils; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.Utility; | |||
| @@ -65,6 +67,9 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| WxMerchantMapper wxMerchantMapper; | |||
| @Autowired | |||
| private MqBaseProducer mqBaseProducer; | |||
| @Autowired | |||
| PayServiceFactory payServiceFactory; | |||
| @Override | |||
| public PageInfo<WxProfitSharingReceiver> listAsPage(WxProfitSharingReceiver record, Integer pageIndex, Integer pageSize) { | |||
| @@ -106,10 +111,11 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| @Override | |||
| public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList) { | |||
| public ResultData addReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver, List<WxProfitSharingReceiver> delList,EnumPayWay payWay) { | |||
| WxAppinfo appInfo = new WxAppinfo(); | |||
| appInfo.updateTenantInfo(merchant); | |||
| appInfo.setPlat(EnumPayWay.getEnum(payWay.getCode()).getPlat().getCode()); | |||
| appInfo.setType(EnumAppType.C.getCode()); | |||
| appInfo = wxAppinfoMapper.findList(appInfo).get(0); | |||
| @@ -124,6 +130,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| receiver.setUpdateTime(date); | |||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); | |||
| receiver.setIsUse(EnumProfitSharingUse.APPLY.getCode()); | |||
| receiver.setPlat(payWay.getPlat().getCode()); | |||
| //passed from uplevel | |||
| //receiver.setReceiverAccount(receiverParam.getReceiverAccount()); | |||
| //receiver.setReceiverComments(receiverParam.getReceiverComments()); | |||
| @@ -131,53 +138,11 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| //receiver.setTrueName(receiverParam.getTrueName()); | |||
| //添加分账账户 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| if (StringUtils.isNotBlank(appInfo.getParentAppId())) { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| } else { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| } | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type", EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| receiverJSON.put("account", receiver.getReceiverAccount()); | |||
| receiverJSON.put("name", receiver.getTrueName()); | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| logger.info(response); | |||
| } 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()); | |||
| ShareAccountResult createResult = payServiceFactory.getPayShareAdapterService(payWay.getCode()).createShareAccount(appInfo, payAccount, receiver); | |||
| if (!createResult.isSuccess()) { | |||
| return new ResultData(createResult.getCode(), createResult.getMsg()); | |||
| } | |||
| 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()); | |||
| } | |||
| wxProfitSharingReceiverMapper.insert(receiver); | |||
| //添加成功才删除账户 | |||
| @@ -198,7 +163,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| //添加变更短信 | |||
| sendMsgByType(EnumMsgModel.UPDATE_SHARING_ACCOUNT_NOTIFY_MERCHANT.getCode(), merchant.getId(), receiver.getReceiverAccount(), receiver); | |||
| } | |||
| return new ResultData(returnMap); | |||
| return new ResultData(createResult.getData()); | |||
| } | |||
| private void sendMsgByType(Integer type, Long merchantId, String account, TenantEntity tenantEntity) { | |||
| @@ -282,56 +247,10 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| ))) { | |||
| //还有别的商户使用这个账号,不从微信服务器申请删除 | |||
| } else { | |||
| //删除分账账户从微信服务器 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| if (StringUtils.isNotBlank(appInfo.getParentAppId())) { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| } else { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| } | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type", EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| receiverJSON.put("account", receiver.getReceiverAccount()); | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| 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()); | |||
| receiver.setUpdateTime(new Date()); | |||
| wxProfitSharingReceiverMapper.updateById(receiver); | |||
| } | |||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("err_code_des")); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("err_code_des")); | |||
| } | |||
| if (!WxPayment.verifyNotifyHMAC(returnMap, payAccount.getApiKey())) { | |||
| logger.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | |||
| return new ResultData(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), "verifyNotifyHMAC"); | |||
| } | |||
| ShareAccountResult shareResult = payServiceFactory.getPayShareAdapterService(receiver.getPlat()).deleteShareAccount(appInfo, payAccount, receiver); | |||
| if (!shareResult.isSuccess()) { | |||
| return new ResultData(shareResult.getCode(), shareResult.getMsg()); | |||
| } | |||
| } | |||
| receiver.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_INVALID.getCode()); | |||
| @@ -347,7 +266,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| } | |||
| @Override | |||
| public ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver) { | |||
| public ResultData updateReceiver(WxMerchant merchant, WxProfitSharingReceiver receiver,EnumPayWay payWay) { | |||
| WxProfitSharingReceiver oldReceiver = new WxProfitSharingReceiver(); | |||
| oldReceiver.updateTenantInfo(merchant); | |||
| @@ -361,7 +280,7 @@ public class WxProfitSharingReceiverServiceImpl implements WxProfitSharingReceiv | |||
| oldReceiver = wxProfitSharingReceiverMapper.selectOne(new QueryWrapper(oldReceiver)); | |||
| if (oldReceiver == null) { | |||
| return addReceiver(merchant, receiver, delList); | |||
| return addReceiver(merchant, receiver, delList,payWay); | |||
| } else { | |||
| oldReceiver.setParameter(receiver.getParameter()); | |||
| oldReceiver.setUpdateTime(new Date()); | |||
| @@ -6,10 +6,12 @@ import com.alibaba.fastjson.JSONArray; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxProfitSharingOrder; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumProfitSharingOrderType; | |||
| import com.iformall.enums.EnumProfitSharingReceiverType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | |||
| import com.iformall.service.pay.service.share.entity.PayShareResult; | |||
| import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; | |||
| @@ -62,7 +64,28 @@ public interface PayShareAdapterService { | |||
| */ | |||
| public EnumProfitSharingReceiverType getShareAccount(Integer accountType); | |||
| /** | |||
| * 分账异步通知接收 | |||
| * @param paramMap | |||
| * @param payWay | |||
| * @return | |||
| */ | |||
| public ShareNotifyAdapterResult notify(Map<String, String> paramMap,EnumPayWay payWay); | |||
| /** | |||
| * 调用API 添加分账账户 | |||
| * @param appInfo | |||
| * @param payAccount | |||
| * @param receiver | |||
| */ | |||
| public ShareAccountResult createShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver); | |||
| /** | |||
| * 调用API 删除分账账户 | |||
| * @param appInfo | |||
| * @param payAccount | |||
| * @param receiver | |||
| */ | |||
| public ShareAccountResult deleteShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver); | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package com.iformall.service.pay.service.share.entity; | |||
| import java.io.Serializable; | |||
| import lombok.AllArgsConstructor; | |||
| import lombok.Data; | |||
| @Data | |||
| @AllArgsConstructor | |||
| public class ShareAccountResult implements Serializable{ | |||
| private static final long serialVersionUID = -3701322871877301001L; | |||
| private boolean isSuccess; | |||
| private Integer code; | |||
| private String msg; | |||
| private Object data; | |||
| } | |||
| @@ -11,28 +11,35 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.domain.po.WxProfitSharingOrder; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.enums.EnumMerchantSubsidyType; | |||
| import com.iformall.enums.EnumPayEndFrom; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumProfitSharingOrderStatus; | |||
| import com.iformall.enums.EnumProfitSharingOrderType; | |||
| import com.iformall.enums.EnumProfitSharingReceiverStatus; | |||
| import com.iformall.enums.EnumProfitSharingReceiverType; | |||
| import com.iformall.enums.EnumProfitSharingType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxAppinfoMapper; | |||
| import com.iformall.mapper.WxPayAccountMapper; | |||
| import com.iformall.mapper.WxPayOrderMapper; | |||
| import com.iformall.mapper.WxProfitSharingReceiverMapper; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.pay.WxProfitSharing; | |||
| import com.iformall.pay.WxProfitSharingFinishP; | |||
| import com.iformall.pay.WxProfitSharingP; | |||
| import com.iformall.pay.WxProfitSharingReceiverP; | |||
| import com.iformall.service.pay.service.share.PayShareAdapterService; | |||
| import com.iformall.service.pay.service.share.PayShareBaseAdapterService; | |||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | |||
| import com.iformall.service.pay.service.share.entity.PayShareResult; | |||
| import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; | |||
| import com.iformall.utils.BeanUtils; | |||
| @@ -259,4 +266,116 @@ public class WxPayShareService extends PayShareBaseAdapterService{ | |||
| return getErrorResult("FAILED"); | |||
| } | |||
| @Override | |||
| public ShareAccountResult createShareAccount(WxAppinfo appInfo,WxPayAccount payAccount,WxProfitSharingReceiver receiver) { | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| if (StringUtils.isNotBlank(appInfo.getParentAppId())) { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| } else { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| } | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type", EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| receiverJSON.put("account", receiver.getReceiverAccount()); | |||
| receiverJSON.put("name", receiver.getTrueName()); | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.addReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| log.info(response); | |||
| } catch (Exception e) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + e.getMessage()); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), e.getMessage(), null); | |||
| } | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| if (!"SUCCESS".equals(return_code)) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + returnMap.get("return_msg")); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("return_msg"), null); | |||
| } | |||
| String result_code = returnMap.get("result_code"); | |||
| if (!"SUCCESS".equals(result_code)) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + returnMap.get("err_code_des")); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), returnMap.get("err_code_des"), null); | |||
| } | |||
| if (!WxPayment.verifyNotifyHMAC(returnMap, payAccount.getApiKey())) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage() + "verifyNotifyHMAC"); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getCode(), ErrorCode.PROFIT_SHARING_RECEIVER_ADD_FAILED.getMessage(), null); | |||
| } | |||
| return new ShareAccountResult(true, null, "success", returnMap); | |||
| } | |||
| @Autowired | |||
| WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; | |||
| @Override | |||
| public ShareAccountResult deleteShareAccount(WxAppinfo appInfo, WxPayAccount payAccount, | |||
| WxProfitSharingReceiver receiver) { | |||
| //删除分账账户从微信服务器 | |||
| WxProfitSharingReceiverP wxProfitSharingReceiverP = new WxProfitSharingReceiverP(); | |||
| if (StringUtils.isNotBlank(appInfo.getParentAppId())) { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getParentAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| wxProfitSharingReceiverP.setSub_appid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setSub_mch_id(payAccount.getSubMchId()); | |||
| } else { | |||
| wxProfitSharingReceiverP.setAppid(appInfo.getAppId()); | |||
| wxProfitSharingReceiverP.setMch_id(payAccount.getMchId()); | |||
| } | |||
| wxProfitSharingReceiverP.setNonce_str(Utility.generate32UUID()); | |||
| wxProfitSharingReceiverP.setSign_type("HMAC-SHA256"); | |||
| JSONObject receiverJSON = new JSONObject(); | |||
| receiverJSON.put("type", EnumProfitSharingReceiverType.getEnum(receiver.getReceiverType()).getMessage()); | |||
| receiverJSON.put("account", receiver.getReceiverAccount()); | |||
| wxProfitSharingReceiverP.setReceiver(receiverJSON.toJSONString()); | |||
| String response; | |||
| try { | |||
| wxProfitSharingReceiverP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingReceiverP), payAccount.getApiKey())); | |||
| response = WxProfitSharing.delReceiver(BeanUtils.toStringMap(wxProfitSharingReceiverP)); | |||
| } catch (Exception e) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + e.getMessage()); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), e.getMessage(), null); | |||
| } | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String return_code = returnMap.get("return_code"); | |||
| if (!"SUCCESS".equals(return_code)) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("return_msg")); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("return_msg"), null); | |||
| } | |||
| 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()); | |||
| receiver.setUpdateTime(new Date()); | |||
| wxProfitSharingReceiverMapper.updateById(receiver); | |||
| } | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage() + returnMap.get("err_code_des")); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), returnMap.get("err_code_des"), null); | |||
| } | |||
| if (!WxPayment.verifyNotifyHMAC(returnMap, payAccount.getApiKey())) { | |||
| log.error(ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getMessage()); | |||
| return new ShareAccountResult(false, ErrorCode.PROFIT_SHARING_RECEIVER_DEL_FAILED.getCode(), "verifyNotifyHMAC", null); | |||
| } | |||
| return new ShareAccountResult(true, null, "success", returnMap); | |||
| } | |||
| } | |||
| @@ -8,6 +8,7 @@ import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.WxMerchantService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -118,7 +119,7 @@ public class WxMerchantController extends BaseController { | |||
| public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); | |||
| wxMerchant.updateTenantInfo(getTenantInfo()); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant,EnumPayWay.PAY_WAY_WECHAT); | |||
| } | |||
| @ApiOperation("更新管理员接口") | |||