Commit c88ea733 by 吕明尚

修改抖音验券

parent 3bf6045f
......@@ -379,15 +379,15 @@ public class TiktokServiceImpl implements TiktokService {
JSONObject sku = entries.getJSONObject("sku");
JSONObject amount = entries.getJSONObject("amount");
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//查询领取记录表
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getCouponCode, entries.getStr("encrypted_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("该券已被领取");
}
// //查询领取记录表
// LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(SConsumerCoupon::getCouponCode, entries.getStr("encrypted_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("该券已被领取");
// }
TiktokCouponDto couponDto = new TiktokCouponDto();
couponDto.setVerifyToken(prepare.getStr("verify_token"));
couponDto.setPoiId(sStore.getTiktokPoiId());
......@@ -400,73 +400,74 @@ public class TiktokServiceImpl implements TiktokService {
couponDto.setEncryptedCodes(codes);
JSONObject verify = verify(couponDto);
JSONArray verifyResults = verify.getJSONArray("verify_results");
Object o1 = verifyResults.get(0);
JSONObject verifyResult = new JSONObject(o1);
String originCode = verifyResult.getStr("origin_code");
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setStoreId(sStore.getId());
sConsumerCoupon.setCouponCode(originCode);
sConsumerCoupon.setEncryptedCode(entries.getStr("encrypted_code"));
sConsumerCoupon.setName(sku.getStr("title"));
sConsumerCoupon.setSourceType(SourceTypeEnum.CHECK.getCode());
sConsumerCoupon.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setCreateTime(new Date());
Integer originalAmount = amount.getInt("list_market_amount");
sConsumerCoupon.setOriginalPrice(BigDecimal.valueOf(originalAmount / 100));
sConsumerCoupon.setCouponPayPrice(BigDecimal.valueOf(amount.getInt("coupon_pay_amount") / 100));
//时间戳转年月日时分秒
sConsumerCoupon.setEndDate(new Date(entries.getInt("expire_time") * 1000L));
//获取本日的00:00:00
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date startOfDay = calendar.getTime();
sConsumerCoupon.setStartDate(startOfDay);
LambdaQueryWrapper<SCoupon> sCouponLambdaQueryWrapper = new LambdaQueryWrapper<>();
sCouponLambdaQueryWrapper.eq(SCoupon::getTiktokSkuId, sku.getStr("sku_id"));
List<SCoupon> sCoupons = isCouponService.list(sCouponLambdaQueryWrapper);
SCoupon sCoupon = null;
if (!CollectionUtils.isEmpty(sCoupons)) {
sCoupon = sCoupons.get(0);
}
if (ObjectUtils.isEmpty(sCoupon)) {
sConsumerCoupon.setTiktokSkuId(sku.getStr("sku_id"));
sConsumerCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
sConsumerCoupon.setStoreType(StoreType.getCodeList());
sConsumerCoupon.setRoomType(RoomType.getCodeList());
verifyResults.forEach(item -> {
JSONObject verifyResult = new JSONObject(item);
String originCode = verifyResult.getStr("origin_code");
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setStoreId(sStore.getId());
sConsumerCoupon.setCouponCode(originCode);
sConsumerCoupon.setEncryptedCode(entries.getStr("encrypted_code"));
sConsumerCoupon.setName(sku.getStr("title"));
sConsumerCoupon.setSourceType(SourceTypeEnum.CHECK.getCode());
sConsumerCoupon.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
sConsumerCoupon.setUseStatus(UserStatusEnum.UNUSED.getCode());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setMinDuration(DEFAULT_MIN_DURATION);
sConsumerCoupon.setMaxDuration(DEFAULT_MAX_DURATION);
sConsumerCoupon.setDuration(DEFAULT_DURATION);
sConsumerCoupon.setMinPrice(DEFAULT_MIN_PRICE);
sConsumerCoupon.setCouponTimeStart(DEFAULT_START_TIME);
sConsumerCoupon.setCouponTimeEnd(DEFAULT_END_TIME);
sConsumerCoupon.setSalePrice(sConsumerCoupon.getCouponPayPrice());
} else {
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponType(sCoupon.getCouponType());
sConsumerCoupon.setStoreType(sCoupon.getStoreType());
sConsumerCoupon.setRoomType(sCoupon.getRoomType());
sConsumerCoupon.setMinDuration(sCoupon.getMinDuration());
sConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
sConsumerCoupon.setDuration(sCoupon.getDuration());
sConsumerCoupon.setMinPrice(sCoupon.getMinPrice());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
sConsumerCoupon.setOrderType(sCoupon.getOrderType());
sConsumerCoupon.setTiktokSkuId(sCoupon.getTiktokSkuId());
sConsumerCoupon.setStoreIds(sCoupon.getStoreIds());
sConsumerCoupon.setPackIds(sCoupon.getPackIds());
sConsumerCoupon.setWeeks(sCoupon.getWeeks());
sConsumerCoupon.setRemark(sCoupon.getRemark());
sConsumerCoupon.setSalePrice(sCoupon.getSalePrice());
}
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
sConsumerCoupon.setCreateTime(new Date());
Integer originalAmount = amount.getInt("list_market_amount");
sConsumerCoupon.setOriginalPrice(BigDecimal.valueOf(originalAmount / 100));
sConsumerCoupon.setCouponPayPrice(BigDecimal.valueOf(amount.getInt("coupon_pay_amount") / 100));
//时间戳转年月日时分秒
sConsumerCoupon.setEndDate(new Date(entries.getInt("expire_time") * 1000L));
//获取本日的00:00:00
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date startOfDay = calendar.getTime();
sConsumerCoupon.setStartDate(startOfDay);
LambdaQueryWrapper<SCoupon> sCouponLambdaQueryWrapper = new LambdaQueryWrapper<>();
sCouponLambdaQueryWrapper.eq(SCoupon::getTiktokSkuId, sku.getStr("sku_id"));
List<SCoupon> sCoupons = isCouponService.list(sCouponLambdaQueryWrapper);
SCoupon sCoupon = null;
if (!CollectionUtils.isEmpty(sCoupons)) {
sCoupon = sCoupons.get(0);
}
if (ObjectUtils.isEmpty(sCoupon)) {
sConsumerCoupon.setTiktokSkuId(sku.getStr("sku_id"));
sConsumerCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
sConsumerCoupon.setStoreType(StoreType.getCodeList());
sConsumerCoupon.setRoomType(RoomType.getCodeList());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setMinDuration(DEFAULT_MIN_DURATION);
sConsumerCoupon.setMaxDuration(DEFAULT_MAX_DURATION);
sConsumerCoupon.setDuration(DEFAULT_DURATION);
sConsumerCoupon.setMinPrice(DEFAULT_MIN_PRICE);
sConsumerCoupon.setCouponTimeStart(DEFAULT_START_TIME);
sConsumerCoupon.setCouponTimeEnd(DEFAULT_END_TIME);
sConsumerCoupon.setSalePrice(sConsumerCoupon.getCouponPayPrice());
} else {
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponType(sCoupon.getCouponType());
sConsumerCoupon.setStoreType(sCoupon.getStoreType());
sConsumerCoupon.setRoomType(sCoupon.getRoomType());
sConsumerCoupon.setMinDuration(sCoupon.getMinDuration());
sConsumerCoupon.setMaxDuration(sCoupon.getMaxDuration());
sConsumerCoupon.setDuration(sCoupon.getDuration());
sConsumerCoupon.setMinPrice(sCoupon.getMinPrice());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
sConsumerCoupon.setOrderType(sCoupon.getOrderType());
sConsumerCoupon.setTiktokSkuId(sCoupon.getTiktokSkuId());
sConsumerCoupon.setStoreIds(sCoupon.getStoreIds());
sConsumerCoupon.setPackIds(sCoupon.getPackIds());
sConsumerCoupon.setWeeks(sCoupon.getWeeks());
sConsumerCoupon.setRemark(sCoupon.getRemark());
sConsumerCoupon.setSalePrice(sCoupon.getSalePrice());
}
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
});
} catch (RuntimeException e) {
throw new RuntimeException(e);
}
......
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