Commit 09c78f5e by 吕明尚

优惠券查询适用门店增加是否已验券判断

parent 4b7ef484
......@@ -2,7 +2,6 @@ package share.web.controller.system;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
......@@ -11,9 +10,7 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.core.page.TableDataInfo;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.domain.vo.FrontTokenComponent;
import share.system.request.CouponRequest;
import share.system.service.ISConsumerCouponService;
......@@ -52,6 +49,11 @@ public class SConsumerCouponController extends BaseController {
return success(sConsumerCouponService.selectSConsumerCouponById(id));
}
@GetMapping(value = "/queryCode")
public AjaxResult getInfo(@PathVariable("code") String code) {
return success(sConsumerCouponService.selectSConsumerCouponByCode(code));
}
// @PreAuthorize("@ss.hasPermi('system:coupon:list')")
@ApiOperation(value = "优惠券-查询可用优惠券")
......
......@@ -86,4 +86,6 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
int restoreCoupon(Long id);
int removeByIdList(List<Long> expiredCoupons);
SConsumerCoupon selectSConsumerCouponByCode(String code);
}
......@@ -99,10 +99,10 @@ public class QPServiceImpl implements QPService {
sStoreLambdaQueryWrapper.eq(SStore::getId, storeId);
SStore sStore = storeService.getOne(sStoreLambdaQueryWrapper);
if (ObjectUtils.isEmpty(sStore) || StoreStatusEnum.STOP.getIndex().equals(sStore.getStatus())) {
throw new RuntimeException("门店状态异常,请联系管理员");
throw new RuntimeException("门店维护中,请联系客服");
}
if (StringUtils.isEmpty(sStore.getOpenShopUuid())) {
throw new RuntimeException("门店未授权,请联系管理员");
throw new RuntimeException("门店未授权,请联系客服");
}
//验券准备
TuangouReceiptPrepareResponseEntity prepare = prepare(code.trim(), sStore.getOpenShopUuid(), status);
......@@ -433,6 +433,17 @@ public class QPServiceImpl implements QPService {
List<SStore> sStoreList = storeService.list(sStoreLambdaQueryWrapper);
//验券准备
TuangouReceiptPrepareResponseEntity prepare = prepare(code.trim(), sStoreList.get(0).getOpenShopUuid(), "");
//获取用户信息
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//查询领取记录表
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getCouponCode, code);
queryWrapper.eq(SConsumerCoupon::getUseStatus, UserStatusEnum.UNUSED.getCode());
queryWrapper.eq(SConsumerCoupon::getIsDelete, YesNoEnum.no.getIndex());
SConsumerCoupon unUsedCoupon = isConsumerCouponService.getOne(queryWrapper);
if (ObjectUtils.isNotEmpty(unUsedCoupon)) {
throw new RuntimeException("该券已被领取");
}
sStoreList = storeService.list(new LambdaQueryWrapper<>(SStore.class).isNotNull(SStore::getOpenShopUuid));
SCoupon sCoupon = isCouponService.getOne(new LambdaQueryWrapper<>(SCoupon.class).
eq(SCoupon::getCouponType, CouponTypeEnum.CASH.getCode()).
......
......@@ -454,6 +454,11 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
return baseMapper.removeByIdList(expiredCoupons);
}
@Override
public SConsumerCoupon selectSConsumerCouponByCode(String code) {
return baseMapper.selectOne(new LambdaQueryWrapper<>(SConsumerCoupon.class).eq(SConsumerCoupon::getCouponCode, code));
}
private void extracted(SConsumerCoupon item, BigDecimal bigDecimal, SRoom byId, BigDecimal subtract, SStore sStore) {
//计算价格
BigDecimal multiply = bigDecimal.multiply(byId.getPrice());
......
......@@ -335,10 +335,10 @@ public class TiktokServiceImpl implements TiktokService {
sStoreLambdaQueryWrapper.eq(SStore::getId, storeId);
SStore sStore = storeService.getOne(sStoreLambdaQueryWrapper);
if (ObjectUtils.isEmpty(sStore) || StoreStatusEnum.STOP.getIndex().equals(sStore.getStatus())) {
throw new RuntimeException("门店状态异常,请联系管理员");
throw new RuntimeException("门店维护中,请联系客服");
}
if (StringUtils.isEmpty(sStore.getTiktokPoiId())) {
throw new RuntimeException("门店未授权,请联系管理员");
throw new RuntimeException("门店未授权,请联系客服");
}
if (code.startsWith("https://v.douyin.com/") | code.length() == 15 | code.length() == 12) {
try {
......@@ -489,6 +489,9 @@ public class TiktokServiceImpl implements TiktokService {
tiktokCouponDto.setPoiId(sStoreList.get(0).getTiktokPoiId());
JSONObject prepare = prepare(tiktokCouponDto);
JSONArray certificates = prepare.getJSONArray("certificates");
if (CollectionUtils.isEmpty(certificates)) {
throw new RuntimeException("该券码已被使用");
}
Object o = certificates.get(0);
JSONObject entries = new JSONObject(o);
JSONObject sku = entries.getJSONObject("sku");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment