Merge branch 'dev' into test

# Conflicts:
#	cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java
This commit is contained in:
2025-11-06 18:23:50 +08:00
15 changed files with 100 additions and 62 deletions

View File

@@ -48,7 +48,8 @@ public class DistributionUserController {
@RequestParam(required = false, defaultValue = "1") Integer page,
@RequestParam(required = false, defaultValue = "10") Integer size) {
AssertUtil.isNull(id, "邀请人ID");
return CzgResult.success(distributionUserService.getInviteUser(id, shopUserId, distributionLevelId, page, size));
Long shopId = StpKit.USER.getShopId();
return CzgResult.success(distributionUserService.getInviteUser(id,shopId, shopUserId, distributionLevelId, page, size));
}
/**
@@ -99,7 +100,8 @@ public class DistributionUserController {
@SaAdminCheckPermission(value = "distribution:user:delete", name = "分销员删除")
public CzgResult<String> deleteDistributionUser(@RequestParam Long id) {
AssertUtil.isNull(id, "{}不能为空", "id");
distributionUserService.deleteDistributionUser(id);
Long shopId = StpKit.USER.getShopId();
distributionUserService.deleteDistributionUser(id,shopId);
return CzgResult.success();
}

View File

@@ -119,10 +119,11 @@ public class UDistributionController {
@GetMapping("/inviteUser")
public CzgResult<Page<InviteUserVO>> getInviteUser(
@RequestParam Long id,
@RequestParam Long shopId,
@RequestParam(required = false, defaultValue = "1") Integer page,
@RequestParam(required = false, defaultValue = "10") Integer size) {
AssertUtil.isNull(id, "邀请人ID");
return CzgResult.success(distributionUserService.getInviteUser(id, null, null, page, size));
return CzgResult.success(distributionUserService.getInviteUser(id, shopId, null, null, page, size));
}
/**

View File

@@ -34,6 +34,17 @@ public class CzgControllerAdvice {
@ExceptionHandler(value = Exception.class)
@ResponseStatus(HttpStatus.OK)
public CzgResult<Object> errorHandler(Exception ex) {
Throwable rootCause = ex;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
if (rootCause instanceof CzgException) {
break;
}
}
// 处理自定义异常
if (rootCause instanceof CzgException czgException) {
return CzgResult.failure(czgException.getCode(), czgException.getMessage());
}
setErrorLog(ex);
return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), ex.getMessage());
}
@@ -143,7 +154,7 @@ public class CzgControllerAdvice {
}
private void setErrorLog(Exception ex) {
log.error("错误",ex);
log.error(ex.getMessage());
log.error("错误",ex);
}
}

View File

@@ -29,7 +29,7 @@ public interface ShopUserService extends IService<ShopUser> {
/**
* 获取邀请用户列表
*/
Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
Page<InviteUserVO> getInviteUser(Long getDistributionUserId, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
boolean updateInfo(ShopUser shopUser);

View File

@@ -40,6 +40,7 @@ public class MkDistributionUser implements Serializable {
/**
* 店铺id
*/
@Id
private Long shopId;
private Long userId;

View File

@@ -67,7 +67,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
/**
* 获取分销员邀请人分页列表
*/
Page<InviteUserVO> getInviteUser(Long id, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
Page<InviteUserVO> getInviteUser(Long id, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size);
/**
* 分销员:按消费金额升级等级
@@ -97,7 +97,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
* 删除分销员
* 逻辑删除分销员
*/
void deleteDistributionUser(Long id);
void deleteDistributionUser(Long id, Long shopId);
@@ -152,4 +152,6 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
* CANCELLED 已撤销
*/
void withdrawNotify(String outBillNo, String state, String failReason);
MkDistributionUser getMkDistributionUserByIdAndShopId(Long shopUserId, Long shopId);
}

View File

@@ -70,7 +70,7 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
* @param distributionUserId 分销员ID
* @return 分页结果
*/
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId);
List<InviteUserVO> getInviteUser(Long distributionUserId, Long shopId, Long shopUserId, Long distributionLevelId);
void updateOneOrTwoAmount(Long shopUserId, Long shopId, BigDecimal amount, Integer isOne);

View File

@@ -23,6 +23,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.processor.util.StrUtil;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
@@ -84,6 +85,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
shopUser.setSourceShopId(shopId);
shopUser.setUserId(userId);
shopUser.setId(null);
if (StrUtil.isBlank(shopUser.getBirthDay())) {
shopUser.setBirthDay(null);
}
save(shopUser);
}
if (shopUser.getMemberLevelId() != null) {
@@ -99,9 +103,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
}
@Override
public Page<InviteUserVO> getInviteUser(Long distributionUserId, Long shopUserId, Long distributionLevelId, Integer page, Integer size) {
public Page<InviteUserVO> getInviteUser(Long distributionUserId, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size) {
PageHelper.startPage(page, size);
List<InviteUserVO> inviteUser = mapper.getInviteUser(distributionUserId, shopUserId, distributionLevelId);
List<InviteUserVO> inviteUser = mapper.getInviteUser(distributionUserId, shopId, shopUserId, distributionLevelId);
return PageUtil.convert(new PageInfo<>(inviteUser));
}

View File

@@ -292,11 +292,11 @@
dist.distribution_level_name AS levelName,
u.distribution_shops AS distributionShops
FROM tb_shop_user_invite invite
left join tb_shop_user u on invite.shop_user_id = u.id
left join mk_distribution_user dist on u.id = dist.id
WHERE u.`distribution_user_id` = #{distributionUserId}
left join tb_shop_user u on invite.shop_user_id = u.id
left join mk_distribution_user dist on u.id = dist.id and dist.shop_id = #{shopId}
WHERE invite.`distribution_user_id` = #{distributionUserId} and invite.shop_id = #{shopId}
<if test="distributionLevelId != null">and dist.distribution_level_id = #{distributionLevelId}</if>
<if test="shopUserId != null">and u.id = #{shopUserId}</if>
ORDER BY u.`invite_time` DESC
<if test="shopUserId != null">and invite.shop_user_id = #{shopUserId}</if>
ORDER BY invite.`invite_time` DESC
</select>
</mapper>

View File

@@ -24,7 +24,7 @@ public interface MkDistributionUserMapper extends BaseMapper<MkDistributionUser>
*/
List<DistributionCenterShopVO> selectUnDistributionShops(Long userId);
boolean updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id);
boolean updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long shopId);
/**
* 统计消费金额

View File

@@ -40,6 +40,7 @@ public class MkDistributionAmountFlowServiceImpl extends ServiceImpl<MkDistribut
.eq(MkDistributionAmountFlow::getShopId, shopId)
.le(MkDistributionAmountFlow::getCreateTime, endTime)
.ge(MkDistributionAmountFlow::getCreateTime, startTime)
.ne(MkDistributionAmountFlow::getType, TableValueConstant.DistributionAmountFlow.Type.OPEN.getCode())
.select(OrderInfo::getOrderNo);
if (StrUtil.isNotBlank(type)) {
String[] split = type.split(",");

View File

@@ -155,14 +155,13 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
result.put("cashOutAmount", userInfo.getDistributionAmount() == null ? 0.0 : userInfo.getDistributionAmount());
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId());
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
MkDistributionUser mkDistributionUser = this.getById(shopUserInvite.getDistributionUserId());
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUserInvite.getDistributionUserId(), shopId);
AssertUtil.isNull(mkDistributionUser, "上级分销员不存在");
ShopUser shopUserParent = shopUserService.getById(mkDistributionUser.getId());
result.put("parentName", shopUserParent.getNickName());
result.put("parentPhone", shopUserParent.getPhone());
}
MkDistributionUser mkDistributionUser = this.getOne(QueryWrapper.create()
.eq(MkDistributionUser::getId, shopUser.getId()).eq(MkDistributionUser::getShopId, shopId));
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId);
MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId);
if (mkDistributionUser != null) {
Map<String, Object> distributionUser = new HashMap<>();
@@ -212,8 +211,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
if (!"auto".equals(mkDistributionConfigVO.getOpenType())) {
throw new CzgException("该店铺不可自行成为分销员");
}
MkDistributionUser mkDistributionUser = this.getOne(QueryWrapper.create()
.eq(MkDistributionUser::getId, shopUser.getId()).eq(MkDistributionUser::getShopId, shopId));
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId);
if (mkDistributionUser == null) {
mkDistributionUser = new MkDistributionUser();
mkDistributionUser.setId(shopUser.getId());
@@ -286,7 +284,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
if ("自主申请".equals(parent.getOpeningMethod()) && parent.getStatus() == 0 && mkDistributionConfig != null) {
if (newDistributionUser.getInviteCount() >= mkDistributionConfig.getInviteCount()) {
ShopUser parentShopUser1 = new ShopUser();
parentShopUser1.setId(shopUser.getId());
parentShopUser1.setId(parentShopUser.getId());
parentShopUser1.upDistributionShop(param.getShopId(), 1);
shopUserService.updateById(parentShopUser1);
}
@@ -295,7 +293,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
if ("invite".equals(mkDistributionConfig.getUpgradeType())) {
if (mkDistributionConfig.getInviteConsume() == 1) {
long count = orderInfoService.count(QueryWrapper.create()
.eq(OrderInfo::getUserId, shopUser.getId())
.eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, parent.getShopId())
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
if (count < 1) {
@@ -315,7 +313,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
costUpgradeLevel(parent.getId(), parent.getShopId());
}
}
this.updateById(newDistributionUser);
update(newDistributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, parent.getId())
.eq(MkDistributionUser::getShopId, parent.getShopId()));
}
@Override
@@ -333,7 +332,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
* 分销员:按消费金额升级等级
*/
public void costUpgradeLevel(Long shopUserId, Long shopId) {
MkDistributionUser distributionUser = getById(shopUserId);
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(shopUserId, shopId);
if (distributionUser == null || distributionUser.getIsAssignLevel() == 1) {
return;
}
@@ -360,7 +359,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
newDistributionUser.setDistributionLevelName(levelConfig.getName());
}
}
updateById(newDistributionUser);
update(newDistributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, shopUserId)
.eq(MkDistributionUser::getShopId, shopId));
}
@@ -401,8 +401,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}
@Override
public Page<InviteUserVO> getInviteUser(Long id, Long shopUserId, Long distributionLevelId, Integer page, Integer size) {
return shopUserService.getInviteUser(id, shopUserId, distributionLevelId, page, size);
public Page<InviteUserVO> getInviteUser(Long id, Long shopId, Long shopUserId, Long distributionLevelId, Integer page, Integer size) {
return shopUserService.getInviteUser(id, shopId, shopUserId, distributionLevelId, page, size);
}
@Override
@@ -413,9 +413,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
AssertUtil.isNull(param.getId(), "店铺用户ID不能为空");
ShopUser shopUser = shopUserService.getById(param.getId());
AssertUtil.isNull(shopUser, "店铺用户ID不能为空");
MkDistributionUser distributionUser = getOne(QueryWrapper.create()
.eq(MkDistributionUser::getId, param.getId())
.eq(MkDistributionUser::getShopId, param.getShopId()));
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(param.getId(), param.getShopId());
if (distributionUser != null && distributionUser.getStatus() != 0) {
throw new CzgException("该用户已是分销员,不可重复添加");
}
@@ -424,6 +422,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
.eq(MkDistributionConfig::getIsEnable, 1));
AssertUtil.isNull(config, "店铺未配置分销");
param.setStatus(0);
param.setInviteCount(0);
if (!"自主申请".equals(param.getOpeningMethod()) || config.getInviteCount() == 0) {
initLevel(config, param);
}
@@ -432,7 +431,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
distributionUser.setDistributionLevelId(param.getDistributionLevelId());
distributionUser.setDistributionLevelName(param.getDistributionLevelName());
distributionUser.setStatus(1);
updateById(distributionUser);
update(distributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, param.getId())
.eq(MkDistributionUser::getShopId, param.getShopId()));
} else {
if ("手动添加".equals(param.getOpeningMethod())) {
param.setStatus(1);
@@ -457,13 +457,14 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
public void updateDistributionUserById(MkDistributionUserDTO param) {
AssertUtil.isNull(param.getId(), "分销员ID不能为空");
MkDistributionUser distributionUser = BeanUtil.toBean(param, MkDistributionUser.class);
updateById(distributionUser);
update(distributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, param.getId())
.eq(MkDistributionUser::getShopId, param.getShopId()));
}
@Override
public void resetDistributionUserLevel(MkDistributionUserDTO param) {
AssertUtil.isNull(param.getId(), "分销员ID不能为空");
MkDistributionUser distributionUser = getById(param.getId());
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(param.getId(), param.getShopId());
AssertUtil.isNull(distributionUser, "分销员不存在");
AssertUtil.isTrue(distributionUser.getIsAssignLevel() == 0, "分销员并未指定等级,不可重置");
MkDistributionConfig config = mkDistributionConfigService.getOne(
@@ -477,7 +478,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
newDistributionUser.setDistributionLevelId(distributionUser.getDistributionLevelId());
newDistributionUser.setDistributionLevelName(distributionUser.getDistributionLevelName());
newDistributionUser.setConsumeAmount(distributionUser.getConsumeAmount());
updateById(newDistributionUser);
update(newDistributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, distributionUser.getId())
.eq(MkDistributionUser::getShopId, distributionUser.getShopId()));
}
@@ -515,12 +517,12 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}
@Override
public void deleteDistributionUser(Long id) {
public void deleteDistributionUser(Long id, Long shopId) {
AssertUtil.isNull(id, "分销员ID不能为空");
MkDistributionUser distributionUser = new MkDistributionUser();
distributionUser.setId(id);
distributionUser.setIsDel(1);
updateById(distributionUser);
update(distributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, id)
.eq(MkDistributionUser::getShopId, shopId));
}
@@ -543,11 +545,11 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
public void open(Long shopUserId, BigDecimal amount, Long shopId, Long sourceId) {
ShopUser shopUserInfo = shopUserService.getById(shopUserId);
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("分销员购买"));
// 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("分销员购买"));
try {
addDistributionUser(new MkDistributionUser().setShopId(shopId)
.setUserId(shopUserInfo.getUserId())
@@ -591,7 +593,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
// 上上级分销员
if (currentShopUser != null && currentShopUser.getDistributionUserId() != null) {
MkDistributionUser parent = getOne(new QueryWrapper().eq(MkDistributionUser::getId, currentShopUser.getDistributionUserId()));
MkDistributionUser parent = getMkDistributionUserByIdAndShopId(currentShopUser.getDistributionUserId(), config.getShopId());
try {
deepReward(orderSourceShopUser, level, config, parent, amount, sourceId, type, orderNo, currentLevel + 1);
} catch (Exception e) {
@@ -603,11 +605,13 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
log.info("当前分销员: {}, 上级分销员: {}, 分销等级: {}", currentDistributionUser.getId(), currentShopUser == null ? null : currentShopUser.getDistributionUserId(), level.getId());
if (config.getRewardCount() != null && config.getRewardCount() > 0) {
long count = distributionFlowService.count(new QueryWrapper().eq(MkDistributionFlow::getSourceShopUserId, currentDistributionUser.getId())
.eq(MkDistributionFlow::getShopUserId, currentDistributionUser.getId()));
long count = distributionFlowService.count(new QueryWrapper()
.eq(MkDistributionFlow::getShopId, config.getShopId()).eq(MkDistributionFlow::getShopUserId, currentDistributionUser.getId()));
if (count >= config.getRewardCount()) {
log.info("分销员{}已达到奖励次数上限, 次数: {}", currentDistributionUser.getId(), config.getRewardCount());
return;
}else {
log.info("分销员奖励次数: {}", count);
}
}
@@ -686,7 +690,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
distributionFlowService.updateById(item);
} else {
// 执行扣款
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(),item.getShopUserId(), item.getShopId(), item.getLevel());
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
updateShopInfoAmount(item.getShopId(), item.getRewardAmount(), orderId, TableValueConstant.DistributionAmountFlow.Type.REFUND, "分销回退");
}
distributionFlowService.save(refundFlow);
@@ -708,7 +712,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceInviteUser.getDistributionUserId());
MkDistributionUser distributionUser = getById(sourceInviteUser.getDistributionUserId());
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(sourceInviteUser.getDistributionUserId(), shopId);
deepReward(sourceShopUserInfo, null, config, distributionUser, amount, sourceId, type, orderNo, 1);
});
distributionDeliverService.save(deliver);
@@ -722,12 +726,20 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
// 用户可提现余额
userInfoService.updateDistributionAmount(userId, receivedIncome);
//分销员余额
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id);
boolean flag = mapper.updateIncome(pendingIncome, receivedIncome, withdrawIncome, id, shopId);
if (!flag) {
throw new CzgException("操作失败");
}
}
static void main() {
BigDecimal amount = new BigDecimal("0.18");
BigDecimal fee = amount.multiply(BigDecimal.valueOf(0.08)).setScale(2, RoundingMode.UP);
BigDecimal finalAmount = amount.subtract(fee);
System.out.println(finalAmount);
System.out.println(fee);
}
@Override
public Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO) {
UserInfo userInfo = userInfoService.getById(userId);
@@ -739,7 +751,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
throw new CzgException("请先实名认证");
}
BigDecimal fee = withdrawFlowDTO.getAmount().multiply(BigDecimal.valueOf(0.08));
BigDecimal fee = withdrawFlowDTO.getAmount().multiply(BigDecimal.valueOf(0.08)).setScale(2, RoundingMode.UP);
BigDecimal finalAmount = withdrawFlowDTO.getAmount().subtract(fee);
MkDistributionWithdrawFlow withdrawFlow = new MkDistributionWithdrawFlow().setUserId(userId)
@@ -785,4 +797,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
flow.setFailReason(failReason);
withdrawFlowService.updateById(flow);
}
@Override
public MkDistributionUser getMkDistributionUserByIdAndShopId(Long shopUserId, Long shopId) {
return getOne(new QueryWrapper().eq(MkDistributionUser::getId, shopUserId).eq(MkDistributionUser::getShopId, shopId));
}
}

View File

@@ -5,7 +5,7 @@
<mapper namespace="com.czg.service.market.mapper.MkDistributionFlowMapper">
<select id="pageInfo" resultType="com.czg.market.vo.MkDistributionFlowVO">
select a.*, b.phone, c.phone as sourcePhone, e.shop_name from mk_distribution_flow as a
select distinct a.*, b.phone, c.phone as sourcePhone, e.shop_name from mk_distribution_flow as a
left join mk_distribution_user as d on d.id=a.distribution_user_id
left join tb_shop_info as e on e.id=a.shop_id
left join tb_shop_user as b on a.shop_user_id=b.id

View File

@@ -15,7 +15,7 @@
pending_income = pending_income + #{pendingIncome},
received_income = received_income + #{receivedIncome},
withdrawn_income = withdrawn_income + #{withdrawIncome}
where id = #{id}
where id = #{id} and shop_id = #{shopId}
</update>
<select id="selectMyDistributionShops" resultType="com.czg.market.vo.DistributionCenterShopVO">
@@ -56,17 +56,16 @@
</select>
<select id="getOrderConsumeAmountByList" resultType="java.math.BigDecimal">
SELECT
IFNULL( SUM( ord.pay_amount ), 0 ) AS totalAmount
FROM
tb_shop_user su
INNER JOIN tb_order_info ord ON su.user_id = ord.user_id
SELECT IFNULL(SUM(ord.pay_amount), 0) AS totalAmount
FROM tb_shop_user_invite invite
INNER JOIN tb_shop_user su on invite.shop_user_id = su.id
INNER JOIN tb_order_info ord ON su.user_id = ord.user_id
and invite.shop_id = #{shopId}
AND ord.shop_id = #{shopId}
AND ord.STATUS = 'done'
AND ord.pay_type NOT IN ( 'vip_pay', 'credit_pay' )
AND ord.paid_time >= su.invite_time
WHERE
su.distribution_user_id = #{inviterId}
AND ord.pay_type NOT IN ('vip_pay', 'credit_pay')
AND ord.paid_time >= invite.invite_time
WHERE invite.distribution_user_id = #{inviterId}
</select>
<select id="getOrderConsumeAmountById" resultType="java.math.BigDecimal">

View File

@@ -70,7 +70,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
.setPayType(isRecharge ? "distributionRecharge" : "distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(detail.getPayAmount());
.setPayType(isRecharge ? "distributionRecharge" : "distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
orderPaymentService.save(orderPayment);
InitInfo initInfo = new InitInfo().setConfig(detail);