会员商品 优惠卷列表

This commit is contained in:
2024-09-02 15:30:32 +08:00
parent 119b6ba9c7
commit b3850469ec
14 changed files with 240 additions and 26 deletions

View File

@@ -654,28 +654,7 @@ public class CartService {
couponAmount = userCoupons.getCouponsAmount();
} else {
TbUserCoupons userCoupons = userCouponsMapper.selectByPrimaryKey(couponsId);
if (Objects.isNull(userCoupons) || !userCoupons.getStatus().equals("0")) {
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "优惠券已使用");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
if (N.gt(userCoupons.getCouponsAmount(), totalAmount)) {
log.info("开始处理订单");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("status", "fail");
jsonObject1.put("msg", "订单金额小于优惠价金额");
jsonObject1.put("type", jsonObject.getString("type"));
jsonObject1.put("data", "");
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true);
log.info("消息推送");
return;
}
totalAmount = totalAmount.subtract(userCoupons.getCouponsAmount());
userCoupons.setStatus("1");
userCoupons.setEndTime(DateUtils.getNewDate(new Date(), 5, 30));

View File

@@ -0,0 +1,22 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto;
import com.chaozhanggui.system.cashierservice.sign.Result;
/**
* (TbUserCoupons)表服务接口
*
* @author ww
* @since 2024-09-02 13:38:20
*/
public interface TbUserCouponsService {
/**
* 分页查询
*
* @param tbUserCoupons 筛选条件
* @return 查询结果
*/
Result queryByPage(UserCouponDto tbUserCoupons);
}

View File

@@ -0,0 +1,70 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper;
import com.chaozhanggui.system.cashierservice.dao.TbActivateOutRecordMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.dao.TbUserCouponsMapper;
import com.chaozhanggui.system.cashierservice.entity.dto.UserCouponDto;
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
import com.chaozhanggui.system.cashierservice.entity.vo.UserCouponVo;
import com.chaozhanggui.system.cashierservice.service.TbUserCouponsService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* (TbUserCoupons)表服务实现类
*
* @author ww
* @since 2024-09-02 13:38:20
*/
@Primary
@Service
public class TbUserCouponsServiceImpl implements TbUserCouponsService {
@Resource
private TbUserCouponsMapper tbUserCouponsMapper;
@Resource
private TbActivateInRecordMapper inRecordMapper;
@Resource
private TbActivateOutRecordMapper outRecordMapper;
@Autowired
private TbShopUserMapper tbShopUserMapper;
/**
* 分页查询
* @return 查询结果
*/
@Override
public Result queryByPage(UserCouponDto couponDto) {
// PageHelper.startPage(couponDto.getPage(), couponDto.getSize());
// List<TbUserCoupons> result = tbUserCouponsMapper.queryAllSelective(couponDto);
// return new Result(CodeEnum.SUCCESS, new PageInfo<>(result));
// List<UserCouponVo> result = tbUserCouponsMapper.queryAllSelective(couponDto);
List<UserCouponVo> result = new ArrayList<>();
List<ShopUserListVo> tbShopUsers = tbShopUserMapper.selectByUserId(couponDto.getUserId().toString(), couponDto.getShopId()==null?null:couponDto.getShopId().toString());
if (!CollectionUtils.isEmpty(tbShopUsers)) {
tbShopUsers.forEach(s -> {
if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() != 0)) {
List<UserCouponVo> unuseCoupon = inRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue());
result.addAll(unuseCoupon);
}
if (couponDto.getStatus()==null || (couponDto.getStatus() != null && couponDto.getStatus() != 1)) {
List<UserCouponVo> useCoupon = outRecordMapper.queryVipPro(s.getMemberId().intValue(), s.getShopId().intValue());
result.addAll(useCoupon);
}
});
}
return new Result(CodeEnum.SUCCESS, result);
}
}