配置中心
This commit is contained in:
parent
e6ad8baeeb
commit
49755e6354
|
|
@ -31,6 +31,8 @@ public class DistributionUserController {
|
|||
*/
|
||||
@GetMapping
|
||||
public CzgResult<Page<MkDistributionUserDTO>> getDistributionUser(MkDistributionUserDTO param) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
param.setShopId(shopId);
|
||||
return CzgResult.success(distributionUserService.getDistributionUser(param));
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +45,7 @@ public class DistributionUserController {
|
|||
@OperationLog("分销员-添加")
|
||||
@SaAdminCheckPermission(value = "distribution:user:add", name = "分销员添加")
|
||||
public CzgResult<Void> addDistributionUser(@RequestBody MkDistributionUser param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
param.setShopId(shopId);
|
||||
distributionUserService.addDistributionUser(param);
|
||||
return CzgResult.success();
|
||||
|
|
@ -55,7 +57,7 @@ public class DistributionUserController {
|
|||
*/
|
||||
@PutMapping
|
||||
@OperationLog("分销员-修改")
|
||||
@SaAdminCheckPermission("distribution:user:update")
|
||||
@SaAdminCheckPermission(value = "distribution:user:update", name = "分销员修改")
|
||||
public CzgResult<Void> updateDistributionUser(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) MkDistributionUserDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
|
|
@ -68,7 +70,7 @@ public class DistributionUserController {
|
|||
*/
|
||||
@DeleteMapping
|
||||
@OperationLog("分销员-删除")
|
||||
@SaAdminCheckPermission("distribution:user::delete")
|
||||
@SaAdminCheckPermission(value = "distribution:user:delete", name = "分销员删除")
|
||||
public CzgResult<String> deleteDistributionUser(@RequestParam Long id) {
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
distributionUserService.deleteDistributionUser(id);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.vo.DistributionCenterShopVO;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -32,10 +31,36 @@ public class UDistributionController {
|
|||
return CzgResult.success(distributionUserService.pay(StpKit.USER.getLoginIdAsLong(), payDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员中心-首页
|
||||
*/
|
||||
@PostMapping("/centerUser")
|
||||
public CzgResult<Map<String, Object>> centerUser() {
|
||||
return CzgResult.success(distributionUserService.centerUser(StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
// @PostMapping("/center")
|
||||
// public CzgResult<Map<String, Object>> center() {
|
||||
// return CzgResult.success(distributionUserService.center(StpKit.USER.getLoginIdAsLong()));
|
||||
// }
|
||||
/**
|
||||
* 分销员中心-已开通的店铺
|
||||
*/
|
||||
@GetMapping("/centerUser/activates")
|
||||
public CzgResult<Page<DistributionCenterShopVO>> activates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||
return CzgResult.success(distributionUserService.activates(StpKit.USER.getLoginIdAsLong(), page, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员中心-未开通的店铺
|
||||
*/
|
||||
@GetMapping("/centerUser/unActivates")
|
||||
public CzgResult<Page<DistributionCenterShopVO>> unActivates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||
return CzgResult.success(distributionUserService.unActivates(StpKit.USER.getLoginIdAsLong(), page, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员中心-配置信息
|
||||
*/
|
||||
@PostMapping("/centerConfig")
|
||||
public CzgResult<Map<String, Object>> centerConfig() {
|
||||
return CzgResult.success(distributionUserService.centerConfig(StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,17 @@ package com.czg.market.entity;
|
|||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分销员表 实体类。
|
||||
*
|
||||
|
|
@ -49,6 +47,8 @@ public class MkDistributionUser implements Serializable {
|
|||
*/
|
||||
private Long shopId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 店铺用户Id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.czg.market.service;
|
|||
|
||||
import com.czg.market.dto.MkDistributionUserDTO;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
import com.czg.market.vo.DistributionCenterShopVO;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
|
@ -17,6 +18,27 @@ import java.util.Map;
|
|||
*/
|
||||
public interface MkDistributionUserService extends IService<MkDistributionUser> {
|
||||
|
||||
/**
|
||||
* 分销员中心-用户信息
|
||||
*/
|
||||
Map<String, Object> centerUser(Long userId);
|
||||
|
||||
/**
|
||||
* 分销员中心-已激活店铺
|
||||
*/
|
||||
Page<DistributionCenterShopVO> activates(Long userId, Integer page, Integer size);
|
||||
|
||||
/**
|
||||
* 分销员中心-未激活店铺
|
||||
*/
|
||||
Page<DistributionCenterShopVO> unActivates(Long userId, Integer page, Integer size);
|
||||
|
||||
|
||||
/**
|
||||
* 分销员中心-配置信息
|
||||
*/
|
||||
Map<String, Object> centerConfig(Long userId);
|
||||
|
||||
/**
|
||||
* 获取分销员分页列表
|
||||
*/
|
||||
|
|
@ -29,7 +51,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||
*/
|
||||
void addDistributionUser(MkDistributionUser param);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 更新分销员
|
||||
*/
|
||||
void updateDistributionUserById(MkDistributionUserDTO param);
|
||||
|
|
@ -48,6 +70,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
|||
|
||||
/**
|
||||
* 分销员开通
|
||||
*
|
||||
* @param userId 用户
|
||||
* @param amount 金额
|
||||
* @param shopId 店铺id
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.czg.market.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class DistributionCenterShopVO implements Serializable {
|
||||
|
||||
private Long shopId;
|
||||
//店铺封面
|
||||
private String coverImg;
|
||||
private String shopName;
|
||||
//店铺地址
|
||||
private String shopAddress;
|
||||
//收益
|
||||
private String income;
|
||||
|
||||
//标签内容
|
||||
private String labelContent;
|
||||
//开通方式 pay购买开通 auto自动开通 manual手动开通
|
||||
private String openType;
|
||||
//要求邀请人数
|
||||
private Integer shopInviteCount;
|
||||
//用户已邀请人数
|
||||
private Integer userInviteCount;
|
||||
//是否下过单
|
||||
private Integer orderCount;
|
||||
//是否进过店铺
|
||||
private Integer shopUser;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.czg.market.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class DistributionCenterTopVO {
|
||||
/**
|
||||
* 总收益
|
||||
*/
|
||||
private BigDecimal totalIncome;
|
||||
/**
|
||||
* 待入账
|
||||
*/
|
||||
private BigDecimal pendingIncome;
|
||||
/**
|
||||
* 已提现
|
||||
*/
|
||||
private BigDecimal cashOutAmount;
|
||||
|
||||
public BigDecimal getTotalIncome() {
|
||||
return totalIncome == null ? BigDecimal.ZERO : totalIncome;
|
||||
}
|
||||
|
||||
public BigDecimal getPendingIncome() {
|
||||
return pendingIncome == null ? BigDecimal.ZERO : pendingIncome;
|
||||
}
|
||||
|
||||
public BigDecimal getCashOutAmount() {
|
||||
return cashOutAmount == null ? BigDecimal.ZERO : cashOutAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getUnCashOutAmount() {
|
||||
return getTotalIncome().subtract(getPendingIncome()).subtract(getCashOutAmount());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.czg.market.vo.DistributionCenterShopVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销员表 映射层。
|
||||
*
|
||||
|
|
@ -11,4 +14,12 @@ import com.czg.market.entity.MkDistributionUser;
|
|||
*/
|
||||
public interface MkDistributionUserMapper extends BaseMapper<MkDistributionUser> {
|
||||
|
||||
/**
|
||||
* 查询我的分销店铺列表 已开通
|
||||
*/
|
||||
List<DistributionCenterShopVO> selectMyDistributionShops(Long shopUserId);
|
||||
/**
|
||||
* 查询我的分销店铺列表 未开通
|
||||
*/
|
||||
List<DistributionCenterShopVO> selectUnDistributionShops(Long shopUserId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,16 @@ import com.czg.account.service.ShopUserService;
|
|||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkDistributionUserDTO;
|
||||
import com.czg.market.entity.MkDistributionAmountFlow;
|
||||
import com.czg.market.entity.MkDistributionConfig;
|
||||
import com.czg.market.entity.MkDistributionLevelConfig;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
import com.czg.market.service.MkDistributionAmountFlowService;
|
||||
import com.czg.market.service.MkDistributionConfigService;
|
||||
import com.czg.market.service.MkDistributionLevelConfigService;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.vo.DistributionCenterShopVO;
|
||||
import com.czg.market.vo.DistributionCenterTopVO;
|
||||
import com.czg.market.entity.*;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.MkDistributionConfigVO;
|
||||
|
|
@ -20,6 +30,9 @@ import com.czg.sa.StpKit;
|
|||
import com.czg.service.market.mapper.MkDistributionUserMapper;
|
||||
import com.czg.system.service.WxService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
|
|
@ -30,6 +43,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -65,6 +79,61 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
@DubboReference
|
||||
private WxService wxService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> centerUser(Long userId) {
|
||||
QueryWrapper totalIncomeSumQueryWrapper = new QueryWrapper();
|
||||
totalIncomeSumQueryWrapper.select("sum(total_income) as totalIncome,sum(pending_income) as pendingIncome,sum(withdrawn_income) as cashOutAmount");
|
||||
totalIncomeSumQueryWrapper.eq(MkDistributionUser::getUserId, userId);
|
||||
totalIncomeSumQueryWrapper.eq(MkDistributionUser::isDel, 0);
|
||||
DistributionCenterTopVO centerTopVO = getObjAs(totalIncomeSumQueryWrapper, DistributionCenterTopVO.class);
|
||||
// 封装顶部收益数据
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("totalIncome", centerTopVO.getTotalIncome());
|
||||
result.put("pendingIncome", centerTopVO.getPendingIncome());
|
||||
result.put("cashOutAmount", centerTopVO.getUnCashOutAmount());
|
||||
|
||||
result.put("activates",activates(userId,1,5));
|
||||
result.put("unActivates",unActivates(userId,1,3));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionCenterShopVO> activates(Long userId, Integer page, Integer size) {
|
||||
PageHelper.startPage(page, size);
|
||||
List<DistributionCenterShopVO> activates = mapper.selectMyDistributionShops(userId);
|
||||
return PageUtil.convert(new PageInfo<>(activates));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DistributionCenterShopVO> unActivates(Long userId, Integer page, Integer size) {
|
||||
PageHelper.startPage(page, size);
|
||||
List<DistributionCenterShopVO> unActivates = mapper.selectUnDistributionShops(userId);
|
||||
for (DistributionCenterShopVO unActivate : unActivates) {
|
||||
|
||||
//'pay购买开通 auto自动开通 manual手动开通'
|
||||
if("pay".equals(unActivate.getOpenType())){
|
||||
if(unActivate.getShopUser() == 1){
|
||||
unActivate.setLabelContent("曾进入过店铺");
|
||||
}
|
||||
}else if("auto".equals(unActivate.getOpenType())){
|
||||
if(unActivate.getOrderCount() == 1){
|
||||
unActivate.setLabelContent("在本店下单过");
|
||||
}
|
||||
}
|
||||
// else if("manual".equals(unActivate.getOpenType())){
|
||||
// unActivate.setLabelContent("manual手动开通");
|
||||
// }
|
||||
|
||||
}
|
||||
return PageUtil.convert(new PageInfo<>(unActivates));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> centerConfig(Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MkDistributionUserDTO> getDistributionUser(MkDistributionUserDTO param) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
|
|
@ -103,19 +172,27 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
|||
public void addDistributionUser(MkDistributionUser param) {
|
||||
AssertUtil.isNull(param.getShopId(), "店铺ID不能为空");
|
||||
AssertUtil.isNull(param.getOpeningMethod(), "开通方式不能为空");
|
||||
AssertUtil.isNull(param.getUserId(), "用户ID不能为空");
|
||||
AssertUtil.isNull(param.getShopUserId(), "店铺用户ID不能为空");
|
||||
long count = count(QueryWrapper.create()
|
||||
.eq(MkDistributionUser::getShopId, param.getShopId())
|
||||
.eq(MkDistributionUser::getShopUserId, param.getShopUserId())
|
||||
.eq(MkDistributionUser::getUserId, param.getUserId()));
|
||||
if (count > 0) {
|
||||
throw new CzgException("该用户已被添加为分销员");
|
||||
}
|
||||
//TODO 通过不同的添加方式 增加校验
|
||||
MkDistributionConfig config = mkDistributionConfigService.getOne(
|
||||
QueryWrapper.create().eq(MkDistributionConfig::getShopId, param.getShopId())
|
||||
.eq(MkDistributionConfig::getIsEnable, 1));
|
||||
AssertUtil.isNull(config, "店铺未配置分销");
|
||||
if (config.getInviteCount() == 0) {
|
||||
param.setStatus(1);
|
||||
MkDistributionLevelConfig levelConfig = levelConfigService.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionLevelConfig::getShopId, param.getShopId())
|
||||
.eq(MkDistributionLevelConfig::getLevel, 1));
|
||||
AssertUtil.isNull(levelConfig, "店铺未配置分销等级");
|
||||
param.setDistributionLevelId(levelConfig.getId());
|
||||
param.setDistributionLevelName(levelConfig.getName());
|
||||
}
|
||||
param.setStatus(1);
|
||||
MkDistributionLevelConfig levelConfig = levelConfigService.getOne(QueryWrapper.create()
|
||||
.eq(MkDistributionLevelConfig::getShopId, param.getShopId())
|
||||
.eq(MkDistributionLevelConfig::getLevel, 1));
|
||||
AssertUtil.isNull(levelConfig, "店铺未配置分销等级");
|
||||
param.setDistributionLevelId(levelConfig.getId());
|
||||
param.setDistributionLevelName(levelConfig.getName());
|
||||
save(param);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,4 +4,35 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.market.mapper.MkDistributionUserMapper">
|
||||
|
||||
<select id="selectMyDistributionShops" resultType="com.czg.market.vo.DistributionCenterShopVO">
|
||||
select shop.id as shopId,
|
||||
shop.cover_img as coverImg,
|
||||
shop.shop_name as shopName,
|
||||
shop.address as shopAddress,
|
||||
user.total_income as income
|
||||
from mk_distribution_user user
|
||||
left join tb_shop_info shop on user.shop_id = shop.id
|
||||
where user.shop_user_id = #{shopUserId}
|
||||
and user.status = 1
|
||||
and user.is_del = 0
|
||||
</select>
|
||||
<select id="selectUnDistributionShops" resultType="com.czg.market.vo.DistributionCenterShopVO">
|
||||
SELECT shop.id AS shopId,
|
||||
shop.cover_img AS coverImg,
|
||||
shop.shop_name AS shopName,
|
||||
shop.address AS shopAddress,
|
||||
config.open_type AS openType,
|
||||
config.invite_count AS shopInviteCount,
|
||||
IFNULL(du.invite_count, 0) AS userInviteCount,
|
||||
COUNT(DISTINCT ord.id) AS orderCount,
|
||||
CASE WHEN COUNT(shu.id) > 0 THEN 1 ELSE 0 END AS shopUser
|
||||
FROM tb_shop_info shop
|
||||
inner JOIN mk_distribution_config config ON shop.id = config.shop_id
|
||||
LEFT JOIN mk_distribution_user du ON shop.id = du.shop_id AND du.user_id = #{user_id} AND du.is_del = 0
|
||||
LEFT JOIN tb_shop_user shu ON shop.id = shu.shop_id AND shu.user_id = #{user_id}
|
||||
LEFT JOIN tb_order_info ord ON shop.id = ord.shop_id AND ord.user_id = #{user_id}
|
||||
AND ord.STATUS = 'done'
|
||||
GROUP BY shop.id
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
throw new ValidateException("生成支付订单失败,商品:" + detail.getProductName() + " 抵扣券与限时折扣不可共用。");
|
||||
}
|
||||
detail.setHalfPriceCouponNum(BigDecimal.ONE);
|
||||
BigDecimal halfPrice = detail.getUnitPrice().divide(new BigDecimal("2")).setScale(2, RoundingMode.FLOOR);
|
||||
BigDecimal halfPrice = detail.getUnitPrice().divide(new BigDecimal("2"), 2, RoundingMode.FLOOR);
|
||||
detail.setDiscountAmount(detail.getDiscountAmount().add(halfPrice));
|
||||
detail.setPayAmount(detail.getPayAmount().subtract(halfPrice));
|
||||
oneGiftAmount.setPrice(halfPrice);
|
||||
|
|
@ -920,6 +920,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
originalPrice = originalPrice.add(orderDetail.getPayAmount());
|
||||
}
|
||||
log.info("满减活动门槛金额计算为:{}", originalPrice);
|
||||
for (MkDiscountThreshold threshold : discountAct.getThresholds()) {
|
||||
if (originalPrice.compareTo(threshold.getFullAmount()) >= 0) {
|
||||
return threshold.getDiscountAmount();
|
||||
|
|
|
|||
Loading…
Reference in New Issue