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
public IPage<CardExchangeRecordVO> selectCancelRecords(Page page, CardExchangeRecordDTO cardExchangeRecordDTO) {
cardExchangeRecordDTO.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());
/*cardExchangeRecordDTO.setStoreId(TokenUtil.getNowAccountInfo().getStoreId());*/
cardExchangeRecordDTO.setMtUserId(TokenUtil.getNowAccountInfo().getId());
return cardExchangeRecordMapper.selectCancelRecords(page,cardExchangeRecordDTO);
}

View File

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

View File

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

View File

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

View File

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