Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -4,6 +4,7 @@ import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto;
|
|||||||
import com.chaozhanggui.system.cashierservice.service.TbShopCouponService;
|
import com.chaozhanggui.system.cashierservice.service.TbShopCouponService;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -29,7 +30,7 @@ public class TbShopCouponController {
|
|||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
@RequestMapping("find")
|
@RequestMapping("find")
|
||||||
public Result find(@RequestBody CouponDto param) {
|
public Result find(@Validated @RequestBody CouponDto param) {
|
||||||
return tbShopCouponService.find(param);
|
return tbShopCouponService.find(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,9 @@ public interface TbActivateInRecordMapper {
|
|||||||
List<TbActivateInRecord> queryAll(TbActivateInRecord tbActivateInRecord);
|
List<TbActivateInRecord> queryAll(TbActivateInRecord tbActivateInRecord);
|
||||||
|
|
||||||
//未使用券
|
//未使用券
|
||||||
List<TbUserCouponVo> queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId);
|
List<TbUserCouponVo> queryByVipIdAndShopId(@Param("vipUserIds") List<Integer> vipUserIds, @Param("shopId") Integer shopId);
|
||||||
List<TbActivateInRecord> queryByVipIdAndShopIdIn(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId);
|
|
||||||
//过期券
|
//过期券
|
||||||
List<TbUserCouponVo> queryByVipIdAndShopIdExpire(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId);
|
List<TbUserCouponVo> queryByVipIdAndShopIdExpire(@Param("vipUserIds") List<Integer> vipUserIds, @Param("shopId") Integer shopId);
|
||||||
|
|
||||||
int countCouponNum(@Param("userId") Integer userId);
|
int countCouponNum(@Param("userId") Integer userId);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public interface TbActivateOutRecordMapper {
|
|||||||
*/
|
*/
|
||||||
List<TbActivateOutRecord> queryAll(TbActivateOutRecord tbActivateOutRecord, @Param("pageable") Pageable pageable);
|
List<TbActivateOutRecord> queryAll(TbActivateOutRecord tbActivateOutRecord, @Param("pageable") Pageable pageable);
|
||||||
|
|
||||||
List<TbUserCouponVo> queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId);
|
List<TbUserCouponVo> queryByVipIdAndShopId(@Param("vipUserIds") List<Integer> vipUserIds, @Param("shopId") Integer shopId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增数据
|
* 新增数据
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CouponDto {
|
public class CouponDto {
|
||||||
private Integer shopId;
|
private Integer shopId;
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
//-1已过期 1未使用 2已使用
|
//-1已过期 1未使用 2已使用
|
||||||
|
@NotNull(message = "状态不允许为空")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
private Integer orderId;
|
private Integer orderId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
|||||||
@Resource
|
@Resource
|
||||||
private TbActivateOutRecordMapper outRecordMapper;
|
private TbActivateOutRecordMapper outRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<TbUserCouponVo> getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) {
|
public List<TbUserCouponVo> getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) {
|
||||||
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId));
|
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId));
|
||||||
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Integer.valueOf(tbShopUser.getId()), shopId);
|
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Arrays.asList(Integer.valueOf(tbShopUser.getId())), shopId);
|
||||||
ArrayList<TbUserCouponVo> canUseCoupon = new ArrayList<>();
|
ArrayList<TbUserCouponVo> canUseCoupon = new ArrayList<>();
|
||||||
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
|
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
|
||||||
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
||||||
@@ -113,13 +114,13 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result find(CouponDto param) {
|
public Result find(CouponDto param) {
|
||||||
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(param.getUserId().toString(), param.getShopId().toString());
|
|
||||||
if (param.getOrderId() != null) {
|
if (param.getOrderId() != null) {
|
||||||
|
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(param.getUserId().toString(), param.getShopId().toString());
|
||||||
TbOrderInfo tbOrderInfo = orderInfoMapper.selectByPrimaryKey(param.getOrderId());
|
TbOrderInfo tbOrderInfo = orderInfoMapper.selectByPrimaryKey(param.getOrderId());
|
||||||
List<TbOrderDetail> tbOrderDetails = orderDetailMapper.selectAllByOrderId(param.getOrderId());
|
List<TbOrderDetail> tbOrderDetails = orderDetailMapper.selectAllByOrderId(param.getOrderId());
|
||||||
Set<Integer> pros = tbOrderDetails.stream().map(TbOrderDetail::getProductId).collect(Collectors.toSet());
|
Set<Integer> pros = tbOrderDetails.stream().map(TbOrderDetail::getProductId).collect(Collectors.toSet());
|
||||||
if (CollectionUtil.isNotEmpty(tbOrderDetails)) {
|
if (CollectionUtil.isNotEmpty(tbOrderDetails)) {
|
||||||
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Integer.valueOf(tbShopUser.getId()), param.getShopId());
|
List<TbUserCouponVo> tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(Arrays.asList(Integer.valueOf(tbShopUser.getId())), param.getShopId());
|
||||||
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
|
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
|
||||||
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周");
|
||||||
LocalTime now = LocalTime.now();
|
LocalTime now = LocalTime.now();
|
||||||
@@ -146,12 +147,14 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
List<TbShopUser> tbShopUser = shopUserMapper.selectAllByUserId(param.getUserId().toString());
|
||||||
|
List<Integer> ids = tbShopUser.stream().map(TbShopUser::getId).map(Integer::valueOf).collect(Collectors.toList());
|
||||||
if (param.getStatus().equals(1)) {
|
if (param.getStatus().equals(1)) {
|
||||||
return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopId(Integer.valueOf(tbShopUser.getId()), param.getShopId()));
|
return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopId(ids, param.getShopId()));
|
||||||
} else if (param.getStatus().equals(-1)) {
|
} else if (param.getStatus().equals(-1)) {
|
||||||
return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopIdExpire(Integer.valueOf(tbShopUser.getId()), param.getShopId()));
|
return new Result(CodeEnum.SUCCESS, inRecordMapper.queryByVipIdAndShopIdExpire(ids, param.getShopId()));
|
||||||
} else if (param.getStatus().equals(2)) {
|
} else if (param.getStatus().equals(2)) {
|
||||||
return new Result(CodeEnum.SUCCESS, outRecordMapper.queryByVipIdAndShopId(Integer.valueOf(tbShopUser.getId()), param.getShopId()));
|
return new Result(CodeEnum.SUCCESS, outRecordMapper.queryByVipIdAndShopId(ids, param.getShopId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Result(CodeEnum.SUCCESS);
|
return new Result(CodeEnum.SUCCESS);
|
||||||
|
|||||||
@@ -51,10 +51,18 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
|
|||||||
inRecord.use_end_time as endTime
|
inRecord.use_end_time as endTime
|
||||||
FROM
|
FROM
|
||||||
tb_activate_in_record inRecord
|
tb_activate_in_record inRecord
|
||||||
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and pro.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
WHERE
|
WHERE
|
||||||
inRecord.vip_user_id = #{vipUserId}
|
inRecord.vip_user_id in
|
||||||
and inRecord.shop_id = #{shopId}
|
<foreach item="item" index="index" collection="vipUserIds" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and inRecord.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
and inRecord.over_num != 0
|
and inRecord.over_num != 0
|
||||||
and inRecord.use_start_time < now()
|
and inRecord.use_start_time < now()
|
||||||
and inRecord.use_end_time > now()
|
and inRecord.use_end_time > now()
|
||||||
@@ -72,30 +80,20 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
|
|||||||
inRecord.use_end_time as endTime
|
inRecord.use_end_time as endTime
|
||||||
FROM
|
FROM
|
||||||
tb_activate_in_record inRecord
|
tb_activate_in_record inRecord
|
||||||
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and pro.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
WHERE
|
WHERE
|
||||||
inRecord.vip_user_id = #{vipUserId}
|
inRecord.vip_user_id in
|
||||||
and inRecord.shop_id = #{shopId}
|
<foreach item="item" index="index" collection="vipUserIds" open="(" separator="," close=")">
|
||||||
and inRecord.over_num != 0
|
#{item}
|
||||||
and inRecord.use_end_time < now()
|
</foreach>
|
||||||
order by inRecord.use_end_time asc
|
<if test="shopId != null and shopId != ''">
|
||||||
</select>
|
and inRecord.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
<select id="queryByVipIdAndShopIdIn" resultMap="TbActivateInRecordMap">
|
and inRecord.over_num != 0
|
||||||
SELECT
|
and inRecord.use_end_time < now()
|
||||||
<include refid="Base_Column_List"/>,
|
|
||||||
CASE
|
|
||||||
WHEN inRecord.type = 1 THEN inRecord.NAME
|
|
||||||
WHEN inRecord.type = 2 THEN pro.NAME
|
|
||||||
END AS `name`
|
|
||||||
FROM
|
|
||||||
tb_activate_in_record inRecord
|
|
||||||
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
|
||||||
WHERE
|
|
||||||
inRecord.vip_user_id = #{vipUserId}
|
|
||||||
and inRecord.shop_id = #{shopId}
|
|
||||||
and inRecord.over_num != 0
|
|
||||||
and inRecord.use_end_time < now()
|
|
||||||
order by inRecord.use_end_time asc
|
order by inRecord.use_end_time asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -41,15 +41,24 @@
|
|||||||
tb_activate_out_record outRecord
|
tb_activate_out_record outRecord
|
||||||
INNER JOIN tb_activate_in_record inRecord
|
INNER JOIN tb_activate_in_record inRecord
|
||||||
on outRecord.give_id = inRecord.id
|
on outRecord.give_id = inRecord.id
|
||||||
and inRecord.shop_id = #{shopId}
|
<if test="shopId != null and shopId != ''">
|
||||||
and inRecord.vip_user_id = #{vipUserId}
|
and inRecord.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
LEFT JOIN tb_product pro
|
LEFT JOIN tb_product pro
|
||||||
ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
|
ON inRecord.pro_id = pro.id
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and pro.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
WHERE
|
WHERE
|
||||||
outRecord.vip_user_id = #{vipUserId}
|
outRecord.vip_user_id in
|
||||||
and outRecord.shop_id = #{shopId}
|
<foreach item="item" index="index" collection="vipUserIds" open="(" separator="," close=")">
|
||||||
and outRecord.status = 'closed'
|
#{item}
|
||||||
and outRecord.use_num-outRecord.ref_num >0
|
</foreach>
|
||||||
|
<if test="shopId != null and shopId != ''">
|
||||||
|
and outRecord.shop_id = #{shopId}
|
||||||
|
</if>
|
||||||
|
and outRecord.status = 'closed'
|
||||||
|
and outRecord.use_num-outRecord.ref_num >0
|
||||||
order by outRecord.create_time desc
|
order by outRecord.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user