配置中心
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user