This commit is contained in:
wangh 2024-01-09 17:09:51 +08:00
commit 289b04f406
5 changed files with 14 additions and 5 deletions

View File

@ -109,7 +109,7 @@ public class CardExchangeRecordServiceImpl extends ServiceImpl<CardExchangeRecor
*/ */
@Override @Override
public IPage<CardExchangeRecordVO> selectCancelRecords(Page page, CardExchangeRecordDTO cardExchangeRecordDTO) { public IPage<CardExchangeRecordVO> selectCancelRecords(Page page, CardExchangeRecordDTO cardExchangeRecordDTO) {
cardExchangeRecordDTO.setStoreId(TokenUtil.getNowAccountInfo().getStoreId()); /*cardExchangeRecordDTO.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());*/
cardExchangeRecordDTO.setMtUserId(TokenUtil.getNowAccountInfo().getId()); cardExchangeRecordDTO.setMtUserId(TokenUtil.getNowAccountInfo().getId());
return cardExchangeRecordMapper.selectCancelRecords(page,cardExchangeRecordDTO); return cardExchangeRecordMapper.selectCancelRecords(page,cardExchangeRecordDTO);
} }

View File

@ -91,7 +91,7 @@ public class CardFavorableRecordController extends BaseController {
* @return 新增结果 * @return 新增结果
*/ */
@PostMapping("drawDown") @PostMapping("drawDown")
public ResponseObject drawDown(@RequestBody IdListDTO idList) { public ResponseObject drawDown(@RequestBody IdListDTO idList) throws Exception {
return getSuccessResult(this.cardFavorableRecordService.drawDown(idList)); return getSuccessResult(this.cardFavorableRecordService.drawDown(idList));
} }

View File

@ -41,7 +41,7 @@ public interface CardFavorableRecordService extends IService<CardFavorableRecord
* @param idList * @param idList
* @return * @return
*/ */
boolean drawDown(IdListDTO idList); boolean drawDown(IdListDTO idList) throws Exception;
/** /**
* 小程序端判断是否领取优惠券 * 小程序端判断是否领取优惠券

View File

@ -100,7 +100,7 @@ public class CardFavorableRecordServiceImpl extends ServiceImpl<CardFavorableRec
* @return * @return
*/ */
@Override @Override
public boolean drawDown(IdListDTO idList) { public boolean drawDown(IdListDTO idList) throws Exception {
boolean save = false; boolean save = false;
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
Integer userId = nowAccountInfo.getId(); Integer userId = nowAccountInfo.getId();
@ -109,6 +109,11 @@ public class CardFavorableRecordServiceImpl extends ServiceImpl<CardFavorableRec
//优惠券 //优惠券
for (Integer id : idList.getIdList()) { for (Integer id : idList.getIdList()) {
CardFavorable cardFavorable = cardFavorableService.getById(id); CardFavorable cardFavorable = cardFavorableService.getById(id);
//优惠券的数量
Integer count = cardFavorable.getCount();
if (count < 1){
throw new Exception("优惠券已领完");
}
if (ObjectUtils.isNotEmpty(cardFavorable) && ObjectUtils.isNotEmpty(cardFavorable.getTimeType())){ if (ObjectUtils.isNotEmpty(cardFavorable) && ObjectUtils.isNotEmpty(cardFavorable.getTimeType())){
if (cardFavorable.getTimeType().equals("0")){ if (cardFavorable.getTimeType().equals("0")){
cardFavorableRecord.setStartTime(new Date()); cardFavorableRecord.setStartTime(new Date());
@ -133,6 +138,7 @@ public class CardFavorableRecordServiceImpl extends ServiceImpl<CardFavorableRec
cardFavorableRecord.setExchangeFrom("店铺发券"); cardFavorableRecord.setExchangeFrom("店铺发券");
cardFavorableRecord.setStatus("0"); cardFavorableRecord.setStatus("0");
save = save(cardFavorableRecord); save = save(cardFavorableRecord);
cardFavorable.setCount(count-1);
} }
} }
return save; return save;

View File

@ -58,8 +58,10 @@
export default { export default {
data() { data() {
return { return {
storeId: '',
cardsList: [], cardsList: [],
query: { query: {
storeId: '',
cardType: '兑换券', cardType: '兑换券',
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10
@ -86,6 +88,7 @@
}, },
onShow() { onShow() {
this.query.storeId = uni.getStorageSync("storeId");
this.getGiftRecords() this.getGiftRecords()
}, },
methods: { methods: {
@ -250,4 +253,4 @@
font-size: 14px; font-size: 14px;
border-radius: 15px; border-radius: 15px;
} }
</style> </style>