| @@ -0,0 +1,21 @@ | |||
| CREATE TABLE `seller_agent` ( | |||
| `id` bigint(20) unsigned NOT NULL, | |||
| `name` varchar(100) NOT NULL COMMENT '姓名', | |||
| `phone` varchar(20) NOT NULL COMMENT '电话', | |||
| `create_time` datetime DEFAULT NULL, | |||
| `update_time` datetime DEFAULT NULL, | |||
| `remark` varchar(300) DEFAULT NULL COMMENT '备注', | |||
| PRIMARY KEY (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| CREATE TABLE `seller_agent_account` ( | |||
| `id` bigint(20) unsigned NOT NULL, | |||
| `seller_agent_id` bigint(20) NOT NULL, | |||
| `merchant_u_id` varchar(30) NOT NULL COMMENT '商户收款商户号', | |||
| `plat` int(1) NOT NULL COMMENT '平台', | |||
| `create_time` datetime DEFAULT NULL, | |||
| `update_time` datetime DEFAULT NULL, | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `UNIQUE_A_M_P` (`seller_agent_id`,`merchant_u_id`,`plat`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| @@ -12,6 +12,7 @@ import com.iformall.service.WxCouponOrderService; | |||
| import com.iformall.service.WxOrderService; | |||
| import com.iformall.service.WxProfitSharingOrderService; | |||
| import com.iformall.service.WxRefundOrderService; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -215,12 +216,13 @@ public class CouponOrderExpiringSchedule { | |||
| wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | |||
| wxSharingOrderDto.updateTenantInfo(wxPayOrder); | |||
| wxSharingOrderDto.setTransactionId(wxPayOrder.getTransactionId()); | |||
| if (wxPayOrder.getChildOrderShare(co.getOrderId()).getRateAmount() != null) { | |||
| WxComposeChildOrderShare share = wxPayOrder.getChildOrderShare(co.getOrderId()); | |||
| if (share.getRateAmount() != null) { | |||
| // 实际分账金额为 分账金额 + 通道费差 | |||
| wxSharingOrderDto.setShareAmount(wxPayOrder.getChildOrderShare(co.getOrderId()).getShareAmount()+wxPayOrder.getChildOrderShare(co.getOrderId()).getRateAmount()); | |||
| wxSharingOrderDto.setShareAmount(share.getShareAmount()+share.getRateAmount()); | |||
| } else { | |||
| // 未设置通道费差 | |||
| wxSharingOrderDto.setShareAmount(wxPayOrder.getChildOrderShare(co.getOrderId()).getShareAmount()); | |||
| wxSharingOrderDto.setShareAmount(share.getShareAmount()); | |||
| } | |||
| //wxSharingOrderDto.setShareAmount(wxPayOrder.getPayAmount()); | |||
| wxProfitSharingOrderService.createSharingOrder(wxSharingOrderDto,wxPayOrder); | |||
| @@ -0,0 +1,30 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "seller_agent") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class SellerAgent extends BaseEntity { | |||
| private static final long serialVersionUID = 6722507735075416305L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="姓名",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="电话",name="phone") | |||
| private String phone; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||
| private Date updateTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="备注",name="remark") | |||
| private String remark; | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "seller_agent_account") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class SellerAgentAccount extends BaseEntity { | |||
| private static final long serialVersionUID = 6722507735075416305L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="销售代理id",name="sellerAgentId") | |||
| private Long sellerAgentId; | |||
| @io.swagger.annotations.ApiModelProperty(value="收款商户号",name="merchantUId") | |||
| private String merchantUId; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumAppPlat",name="createTime") | |||
| private Integer plat; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||
| private Date updateTime; | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.SellerAgentAccount; | |||
| import java.util.List; | |||
| import org.apache.ibatis.annotations.Param; | |||
| public interface SellerAgentAccountMapper extends CommonMapper<SellerAgentAccount, Long> { | |||
| List<SellerAgentAccount> findList(SellerAgentAccount record); | |||
| SellerAgentAccount getById(@Param("id")Long id); | |||
| void deleteById(@Param("id")Long id); | |||
| void deleteByAgentId(@Param("agentId")Long agentId); | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.SellerAgent; | |||
| import java.util.List; | |||
| import org.apache.ibatis.annotations.Param; | |||
| public interface SellerAgentMapper extends CommonMapper<SellerAgent, Long> { | |||
| List<SellerAgent> findList(SellerAgent record); | |||
| SellerAgent getById(@Param("id")Long id); | |||
| void deleteById(@Param("id")Long id); | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.iformall.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.SellerAgent; | |||
| import com.iformall.domain.po.SellerAgentAccount; | |||
| public interface SellerAgentService { | |||
| PageInfo<SellerAgent> listAsPage(SellerAgent record, Integer pageIndex, Integer pageSize); | |||
| List<SellerAgent> list(SellerAgent agent); | |||
| void saveOrUpdate(SellerAgent agent); | |||
| SellerAgent getById(Long id); | |||
| List<SellerAgentAccount> getAccountList(Long agentId, Integer plat); | |||
| void saveOrUpdateAccount(SellerAgentAccount agentAccount); | |||
| void deleteSellerAgent(Long id); | |||
| void deleteAccountById(Long accountId); | |||
| void deleteAccountByAgentId(Long agentId); | |||
| } | |||
| @@ -0,0 +1,98 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.CouponPressBatchVo; | |||
| import com.iformall.enums.EnumPressBatchStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.*; | |||
| @Service | |||
| public class SellerAgentServiceImpl implements SellerAgentService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| SellerAgentMapper sellerAgentMapper; | |||
| @Autowired | |||
| SellerAgentAccountMapper sellerAgentAccountMapper; | |||
| @Override | |||
| public List<SellerAgent> list(SellerAgent record){ | |||
| return sellerAgentMapper.findList(record); | |||
| } | |||
| @Override | |||
| public PageInfo<SellerAgent> listAsPage(SellerAgent record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> sellerAgentMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(SellerAgent record) { | |||
| if (null == record.getId()) { | |||
| record.setCreateTime(new Date()); | |||
| record.setUpdateTime(new Date()); | |||
| sellerAgentMapper.insert(record); | |||
| }else { | |||
| record.setUpdateTime(new Date()); | |||
| sellerAgentMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| public SellerAgent getById(Long id) { | |||
| return sellerAgentMapper.getById(id); | |||
| } | |||
| @Override | |||
| public List<SellerAgentAccount> getAccountList(Long agentId, Integer plat) { | |||
| SellerAgentAccount iteq = new SellerAgentAccount(); | |||
| iteq.setSellerAgentId(agentId); | |||
| iteq.setPlat(plat); | |||
| return sellerAgentAccountMapper.findList(iteq); | |||
| } | |||
| @Override | |||
| public void saveOrUpdateAccount(SellerAgentAccount record) { | |||
| if (null == record.getId()) { | |||
| record.setCreateTime(new Date()); | |||
| record.setUpdateTime(new Date()); | |||
| sellerAgentAccountMapper.insert(record); | |||
| }else { | |||
| record.setUpdateTime(new Date()); | |||
| sellerAgentAccountMapper.updateById(record); | |||
| } | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void deleteSellerAgent(Long id) { | |||
| sellerAgentMapper.deleteById(id); | |||
| deleteAccountByAgentId(id); | |||
| } | |||
| @Override | |||
| public void deleteAccountById(Long accountId) { | |||
| sellerAgentAccountMapper.deleteById(accountId);; | |||
| } | |||
| @Override | |||
| public void deleteAccountByAgentId(Long agentId) { | |||
| sellerAgentAccountMapper.deleteByAgentId(agentId); | |||
| } | |||
| } | |||
| @@ -1753,10 +1753,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | |||
| } | |||
| wxSharingOrderDto.setPayAmount(wxPayOrder.getPayAmount()); | |||
| wxSharingOrderDto.setShareAmount(wxPayOrder.getChildOrderShare(couponOrder.getOrderId()).getShareAmount()); | |||
| wxSharingOrderDto.setRateAmount(wxPayOrder.getChildOrderShare(couponOrder.getOrderId()).getRateAmount()); | |||
| wxSharingOrderDto.setRealRateAmount(wxPayOrder.getChildOrderShare(couponOrder.getOrderId()).getRealRateAmount()); | |||
| wxSharingOrderDto.setCommissionAmount(wxPayOrder.getChildOrderShare(couponOrder.getOrderId()).getCommissionAmount()); | |||
| wxSharingOrderDto.setShareAmount(childShare.getShareAmount()); | |||
| wxSharingOrderDto.setRateAmount(childShare.getRateAmount()); | |||
| wxSharingOrderDto.setRealRateAmount(childShare.getRealRateAmount()); | |||
| wxSharingOrderDto.setCommissionAmount(childShare.getCommissionAmount()); | |||
| wxSharingOrderDto.setOrderId(wxPayOrder.getId()); | |||
| wxSharingOrderDto.setPayTimeStart(wxPayOrder.getPayTimeStart()); | |||
| wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | |||
| @@ -2586,10 +2586,11 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| sharingOrder.setMerchantId(wxMerchantBUser.getMerchantId()); | |||
| sharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); | |||
| sharingOrder.setPayAmount(wxPayOrder.getPayAmount()); | |||
| sharingOrder.setShareAmount(wxPayOrder.getChildOrderShare(orderId).getShareAmount()); | |||
| sharingOrder.setRateAmount(wxPayOrder.getChildOrderShare(orderId).getRateAmount()); | |||
| sharingOrder.setRealRateAmount(wxPayOrder.getChildOrderShare(orderId).getRealRateAmount()); | |||
| sharingOrder.setCommissionAmount(wxPayOrder.getChildOrderShare(orderId).getCommissionAmount()); | |||
| WxComposeChildOrderShare share = wxPayOrder.getChildOrderShare(orderId); | |||
| sharingOrder.setShareAmount(share.getShareAmount()); | |||
| sharingOrder.setRateAmount(share.getRateAmount()); | |||
| sharingOrder.setRealRateAmount(share.getRealRateAmount()); | |||
| sharingOrder.setCommissionAmount(share.getCommissionAmount()); | |||
| sharingOrder.setOrderId(wxPayOrder.getId()); | |||
| sharingOrder.setPayTimeStart(wxPayOrder.getPayTimeStart()); | |||
| sharingOrder.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | |||
| @@ -453,15 +453,15 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| Long merchant_id = null; | |||
| String merchant_uid = ""; | |||
| if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 | |||
| //11111111111加缓存 | |||
| merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId()); | |||
| WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); | |||
| // merchant_uid = wxCouponChannelService.getCouponOneMerchantUid(payWay,merchant_id,o.getTenantId()); | |||
| // if(null == merchant_id || StringUtils.isBlank(merchant_uid)){ | |||
| if(receiver == null){ | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); | |||
| } | |||
| merchant_uid = receiver.getReceiverAccount(); | |||
| } | |||
| //1111111111111加缓存 | |||
| int rate = payShareServie.getOfficialCommission(o,payAccount);//抖音分佣率 | |||
| logger.info("抖音分佣率"+rate); | |||
| PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(o.getPayment(),rate, payAccount); | |||
| @@ -183,9 +183,4 @@ public class WxPressBatchServiceImpl implements WxPressBatchService { | |||
| return null; | |||
| } | |||
| } | |||
| @@ -112,7 +112,8 @@ public class PayServiceFactory { | |||
| if (null == qrcodeMap) { | |||
| qrcodeMap = new ConcurrentHashMap<String,PayAdapterService>(); | |||
| qrcodeMap.put(EnumAppPlat.WX.getCode()+"_"+EnumPayVersion.WX_PAY_V2.getCode(), wxMiniAppPayService); | |||
| qrcodeMap.put(EnumAppPlat.WX.getCode()+"_"+EnumPayVersion.WX_PAY_V3_SFT.getCode(), wxMiniAppPayService); | |||
| qrcodeMap.put(EnumAppPlat.WX.getCode()+"_"+EnumPayVersion.WX_PAY_V3_SFT.getCode(), wxMiniAppPaySFTAdapterService); | |||
| qrcodeMap.put(EnumAppPlat.WX.getCode()+"_"+EnumPayVersion.WX_PAY_V3.getCode(), wxMiniAppPayV3AdapterService); | |||
| qrcodeMap.put(EnumAppPlat.TOUTIAO.getCode()+"_"+EnumPayVersion.DY_PAY_V2.getCode(),ttMiniAppPayService); | |||
| } | |||
| return qrcodeMap; | |||
| @@ -12,9 +12,9 @@ public class PayShareCalculateAmount implements Serializable{ | |||
| private static final long serialVersionUID = -3701322871877301001L; | |||
| private Integer payAmount; | |||
| private Integer mallCharge;//商场拿走的钱+平台手续费 | |||
| private Integer realRateAmount;//平台手续费 | |||
| private Integer commissionAmount;//平台佣金 | |||
| private Integer mallCharge;//商场拿走的钱+realRateAmount | |||
| private Integer realRateAmount;//平台手续费(微信,抖音的支付通道费) | |||
| private Integer commissionAmount;//平台佣金(微信,抖音平台抽点) | |||
| //分账的钱 | |||
| public Integer getShareAmount() { | |||
| @@ -0,0 +1,60 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.SellerAgentAccountMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.SellerAgentAccount"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="seller_agent_id" jdbcType="VARCHAR" property="sellerAgentId"/> | |||
| <result column="merchant_u_id" jdbcType="VARCHAR" property="merchantUId" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||
| <result column="plat" jdbcType="VARCHAR" property="plat"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `seller_agent_id`, `merchant_u_id`, `create_time`, `update_time`, `plat` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != sellerAgentId "> | |||
| and `seller_agent_id` = #{sellerAgentId} | |||
| </if> | |||
| <if test=" null != plat "> | |||
| and `plat` = #{plat} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and `id` in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.SellerAgentAccount" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from seller_agent_account | |||
| <include refid="dynamicWhereConditions"/> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| <select id="getById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from seller_agent_account where `id` = #{id} | |||
| </select> | |||
| <delete id="deleteById" parameterType="java.util.HashMap" > | |||
| delete from seller_agent_account where `id` = #{id} | |||
| </delete> | |||
| <delete id="deleteByAgentId" parameterType="java.util.HashMap" > | |||
| delete from seller_agent_account where `seller_agent_id` = #{agentId} | |||
| </delete> | |||
| </mapper> | |||
| @@ -0,0 +1,57 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.SellerAgentMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.SellerAgent"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `name`, `phone`, `create_time`, `update_time`, `remark` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != name "> | |||
| and `name` like concat('%', #{name},'%') | |||
| </if> | |||
| <if test=" null != phone "> | |||
| and `phone` like concat('%', #{phone},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and `id` in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.SellerAgent" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from seller_agent | |||
| <include refid="dynamicWhereConditions"/> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| <select id="getById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from seller_agent where `id` = #{id} | |||
| </select> | |||
| <delete id="deleteById" parameterType="java.util.HashMap" > | |||
| delete from seller_agent where `id` = #{id} | |||
| </delete> | |||
| </mapper> | |||
| @@ -61,7 +61,7 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findPressList" parameterType="com.iformall.domain.vo.WxOrderPressVo" resultMap="VoBaseResultMap"> | |||
| <select id="findPressList" parameterType="com.iformall.domain.vo.WxOrderPressVo" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> | |||
| from wx_order_press op | |||
| where op.`order_id` = #{orderId} and op.tenant_id = #{tenantId} | |||