更新10.11
This commit is contained in:
parent
e7af9f6b53
commit
622df03a6e
@ -32,6 +32,7 @@
|
|||||||
FROM
|
FROM
|
||||||
active_applet aa LEFT JOIN t_account ta on aa.create_by = ta.acct_id
|
active_applet aa LEFT JOIN t_account ta on aa.create_by = ta.acct_id
|
||||||
<where>
|
<where>
|
||||||
|
type != '1' and type != '2'
|
||||||
<if test="entity.name != null and entity.name != ''">
|
<if test="entity.name != null and entity.name != ''">
|
||||||
AND aa.name like concat('%', #{entity.name}, '%')
|
AND aa.name like concat('%', #{entity.name}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -223,6 +223,15 @@ public class CardCouponController extends BaseController {
|
|||||||
return getSuccessResult(cardCouponService.sendCoupon(cardCouponUser));
|
return getSuccessResult(cardCouponService.sendCoupon(cardCouponUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户领取优惠券
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("userGetCoupon")
|
||||||
|
public ResponseObject userGetCoupon(Integer couponId){
|
||||||
|
return getSuccessResult(cardCouponService.userGetCoupon(couponId));
|
||||||
|
}
|
||||||
|
|
||||||
// @GetMapping("getCouponOne")
|
// @GetMapping("getCouponOne")
|
||||||
// public ResponseObject getCouponOne(Integer id) {
|
// public ResponseObject getCouponOne(Integer id) {
|
||||||
// return getSuccessResult(cardCouponService.getCouponOne(id));
|
// return getSuccessResult(cardCouponService.getCouponOne(id));
|
||||||
|
@ -31,6 +31,13 @@ public interface CardCouponService extends IService<CardCoupon> {
|
|||||||
int sendCoupon(CardCouponUser cardCouponUser);
|
int sendCoupon(CardCouponUser cardCouponUser);
|
||||||
|
|
||||||
CardCoupon selectOneBuId(Integer id);
|
CardCoupon selectOneBuId(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户领取卡券
|
||||||
|
* @param couponId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int userGetCoupon(Integer couponId);
|
||||||
/**
|
/**
|
||||||
* 卡券详情(小程序)
|
* 卡券详情(小程序)
|
||||||
* @param id
|
* @param id
|
||||||
|
@ -147,6 +147,69 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
|
|||||||
return baseMapper.selectById(id);
|
return baseMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户领取卡券
|
||||||
|
*
|
||||||
|
* @param couponId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int userGetCoupon(Integer couponId) {
|
||||||
|
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||||
|
//查询优惠券信息
|
||||||
|
CardCoupon cardCoupon = baseMapper.selectOne(new LambdaQueryWrapper<CardCoupon>()
|
||||||
|
.eq(CardCoupon::getId, couponId));
|
||||||
|
|
||||||
|
//判断优惠券是否在线
|
||||||
|
if (cardCoupon.getStatus().equals("0")) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否有库存
|
||||||
|
int count = cardCoupon.getTfTotal() - cardCoupon.getGiftCardTotal();
|
||||||
|
if (count == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//判断用户是否已经领取上限
|
||||||
|
Integer getCount = cardCouponUserMapper.selectCount(new LambdaQueryWrapper<CardCouponUser>()
|
||||||
|
.eq(CardCouponUser::getMtUserId, nowAccountInfo.getId())
|
||||||
|
.eq(CardCouponUser::getCardCouponId, couponId));
|
||||||
|
if (getCount >= cardCoupon.getGetNumLimit()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Integer validityDay = 0;
|
||||||
|
//优惠券的有效期
|
||||||
|
Date effectiveDateStart = new Date();
|
||||||
|
Date effectiveDateEnd = new Date();
|
||||||
|
if (cardCoupon.getTimeType().equals("1")) {
|
||||||
|
validityDay = cardCoupon.getValidityDay();
|
||||||
|
DateTime now = DateUtil.date();
|
||||||
|
effectiveDateStart = now;
|
||||||
|
effectiveDateEnd = DateUtil.offsetDay(now, validityDay);
|
||||||
|
}else {
|
||||||
|
effectiveDateStart = cardCoupon.getEffectiveDateStart();
|
||||||
|
effectiveDateEnd = cardCoupon.getEffectiveDateEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加到用户优惠券表
|
||||||
|
CardCouponUser cardCouponUser = new CardCouponUser();
|
||||||
|
cardCouponUser.setStatus("0");
|
||||||
|
cardCouponUser.setChainStoreId(cardCoupon.getChainStorId());
|
||||||
|
cardCouponUser.setStoreId(cardCoupon.getStoreId());
|
||||||
|
cardCouponUser.setMtUserId(nowAccountInfo.getId());
|
||||||
|
cardCouponUser.setFromType("6");
|
||||||
|
cardCouponUser.setCardCouponId(cardCoupon.getId());
|
||||||
|
cardCouponUser.setStartTime(effectiveDateStart);
|
||||||
|
cardCouponUser.setEndTime(effectiveDateEnd);
|
||||||
|
cardCouponUser.setCreateTime(new Date());
|
||||||
|
cardCouponUser.setCreateBy(TokenUtil.getNowAccountInfo().getId().toString());
|
||||||
|
cardCouponUserMapper.insert(cardCouponUser);
|
||||||
|
|
||||||
|
//更新优惠券表
|
||||||
|
cardCoupon.setTfGetNum(cardCoupon.getTfGetNum() + 1);
|
||||||
|
return baseMapper.updateById(cardCoupon);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡券详情(小程序)
|
* 卡券详情(小程序)
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user