分销员开通接口
This commit is contained in:
parent
8ed14ed241
commit
423b6f303f
|
|
@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付
|
||||
* 分销员开通
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
|
|
@ -29,12 +29,12 @@ public class DistributionPayController {
|
|||
private SysParamsService paramsService;
|
||||
|
||||
|
||||
@PostMapping("/cashPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.cashPayOrder(payParam);
|
||||
}
|
||||
// @PostMapping("/cashPay")
|
||||
// @Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
// public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
// payParam.setShopId(shopId);
|
||||
// return payService.cashPayOrder(payParam);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
|
|
@ -42,31 +42,31 @@ public class DistributionPayController {
|
|||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/ltPayOrder")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
@Debounce(value = "#payParam.userId")
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 正扫
|
||||
*/
|
||||
@PostMapping("/scanPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反扫
|
||||
* authCode 必填 扫描码
|
||||
*/
|
||||
@PostMapping("/microPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.microPayOrder(payParam);
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 正扫
|
||||
// */
|
||||
// @PostMapping("/scanPay")
|
||||
// @Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
// public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
// payParam.setShopId(shopId);
|
||||
// return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 反扫
|
||||
// * authCode 必填 扫描码
|
||||
// */
|
||||
// @PostMapping("/microPay")
|
||||
// @Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
// public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
// payParam.setShopId(shopId);
|
||||
// return payService.microPayOrder(payParam);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 分销员表 实体类。
|
||||
|
|
@ -26,6 +27,7 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("mk_distribution_user")
|
||||
@Accessors(chain = true)
|
||||
public class MkDistributionUser implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.czg.market.vo.MkDistributionConfigVO;
|
|||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.MkDistributionConfig;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -22,4 +23,12 @@ public interface MkDistributionConfigService extends IService<MkDistributionConf
|
|||
Map<String, Object> pay(long userId, MkDistributionPayDTO payDTO);
|
||||
|
||||
Boolean cashPayOrder(long adminId, MkDistributionPayDTO payParam);
|
||||
|
||||
/**
|
||||
* 分销员开通
|
||||
* @param userId 用户
|
||||
* @param amount 金额
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
void open(Long userId, BigDecimal amount, Long shopId, Long sourceId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public interface TableValueConstant {
|
|||
enum Type {
|
||||
MANUAL_RECHARGE("manual_recharge", "手动充值"),
|
||||
SUB("sub", "系统扣减"),
|
||||
OPEN("open", "分销员购买"),
|
||||
MANUAL_SUB("manual_sub", "手动扣减"),
|
||||
SELF_RECHARGE("self_recharge", "自助充值");
|
||||
private final String code;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,16 @@ package com.czg.service.market.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkDistributionConfigDTO;
|
||||
import com.czg.market.entity.MkDistributionAmountFlow;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
import com.czg.market.service.MkDistributionAmountFlowService;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.market.entity.MkDistributionLevelConfig;
|
||||
import com.czg.market.service.MkDistributionLevelConfigService;
|
||||
|
|
@ -47,6 +51,10 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl<MkDistributionC
|
|||
private MkDistributionLevelConfigService levelConfigService;
|
||||
@Resource
|
||||
private MkDistributionAmountFlowService distributionAmountFlowService;
|
||||
@Resource
|
||||
private MkDistributionUserService distributionUserService;
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@DubboReference
|
||||
private OrderPaymentService orderPaymentService;
|
||||
|
|
@ -105,13 +113,25 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl<MkDistributionC
|
|||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
BigDecimal amount = shopInfoService.updateAmount(shopInfo.getId(), payParam.getAmount());
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopInfo.getId());
|
||||
shopInfoService.updateAmount(shopInfo.getId(), payParam.getAmount());
|
||||
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
.setType(payParam.getAmount().compareTo(BigDecimal.ZERO) < 0 ? TableValueConstant.DistributionAmountFlow.Type.MANUAL_SUB.getCode() :
|
||||
TableValueConstant.DistributionAmountFlow.Type.MANUAL_RECHARGE.getCode())
|
||||
.setMainShopId(mainShopId).setShopId(shopInfo.getId()).setAmount(amount).setChangeAmount(payParam.getAmount())
|
||||
.setRemark(payParam.getRemark()).setOpAccount(StpKit.USER.getAccount()));
|
||||
return null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(Long userId, BigDecimal amount, Long shopId, Long sourceId) {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(shopId, userId);
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
BigDecimal finalAmount = shopInfoService.updateAmount(shopId, amount);
|
||||
distributionAmountFlowService.save(new MkDistributionAmountFlow()
|
||||
.setType(TableValueConstant.DistributionAmountFlow.Type.OPEN.getCode())
|
||||
.setMainShopId(mainShopId).setShopId(shopId).setAmount(finalAmount).setChangeAmount(amount).setSourceId(sourceId)
|
||||
.setRemark("分销员购买").setOpAccount(StpKit.USER.getAccount()));
|
||||
distributionUserService.addDistributionUser(new MkDistributionUser().setParentId(null).setShopId(shopId)
|
||||
.setShopUserId(shopUserInfo.getId()).setOpeningMethod("付费开通"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,14 +64,13 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||
}
|
||||
|
||||
private InitInfo initPayment(Long userId, MkDistributionPayDTO payParam) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
|
||||
MkDistributionConfigVO detail = configService.detail(payParam.getShopId());
|
||||
AssertUtil.isTrue(detail.getIsEnable() != 1, "分销未开启");
|
||||
if (!TableValueConstant.DistributionConfig.OpenType.PAY.getCode().equals(detail.getOpenType())) {
|
||||
throw new CzgException("当前未开启购买分销配置");
|
||||
}
|
||||
|
||||
OrderPayment orderPayment = new OrderPayment().setShopId(mainShopId).setSourceId(userId)
|
||||
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(userId)
|
||||
.setPayType("distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(detail.getPayAmount());
|
||||
orderPaymentService.save(orderPayment);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
private MkShopRechargeService shopRechargeService;
|
||||
@Resource
|
||||
private MkConsumeCashbackService consumeCashbackService;
|
||||
@Resource
|
||||
private MkDistributionConfigService distributionConfigService;
|
||||
// 延迟 5 秒
|
||||
private static final long DELAY = 5;
|
||||
//重试次数
|
||||
|
|
@ -1154,6 +1156,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
// 充值赠送积分
|
||||
memberConfigService.deliver(shopUser.getMainShopId(), shopUser.getUserId(), TableValueConstant.MemberExpFlow.Type.COST, payment.getAmount(), null, payment.getId());
|
||||
|
||||
// 分销员开通
|
||||
} else if ("distribution".equals(payment.getPayType())) {
|
||||
distributionConfigService.open(payment.getSourceId(), payment.getAmount(), payment.getShopId(), payment.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue