Commit 6d26dbad by 吕明尚

优惠卷领取记录增加抖音加密劵码

parent 760c2c16
......@@ -51,7 +51,7 @@ public class QPController {
public R<String> consumeByUser(String code, String storeId) {
if (code.length() == 10) {
return R.ok(qpService.consumeByUser(code, storeId, ConsumerCouponStatusEnum.CONTROLLER.getCode()));
} else if (code.startsWith("https://v.douyin.com/") | code.length() == 15) {
} else if (code.startsWith("https://v.douyin.com/") | code.length() == 15 | code.length() == 12) {
return R.ok(tiktokService.consumeByUser(code, storeId));
} else {
return R.fail("请输入正确的券码");
......
......@@ -118,7 +118,7 @@ public class RedisTask {
logger.info("券码:{}->查询结束:{}", coupon.getCouponCode(), getconsumed);
} else if (StringUtils.isNoneEmpty(coupon.getTiktokSkuId()) && coupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
//抖音复验券
JSONObject object = tiktokService.certificateGet(coupon.getCouponCode());
JSONObject object = tiktokService.certificateGet(coupon.getEncryptedCode());
JSONObject certificate = object.getJSONObject("certificate");
Integer status = certificate.getInt("status");
if (status.equals(TiktokCouponStatusEnum.AVAILABLE.getCode())) {
......
......@@ -65,6 +65,11 @@ public class SConsumerCoupon extends BaseEntity
@Excel(name = "优惠券编码")
private String couponCode;
/**
* 优惠券加密编码
*/
private String encryptedCode;
/** 优惠券名称 */
@Excel(name = "优惠券名称")
private String name;
......
......@@ -545,7 +545,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
} else if (StringUtils.isNoneEmpty(byId.getTiktokSkuId()) && byId.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
//抖音复验券
JSONObject object = tiktokService.certificateGet(byId.getCouponCode());
JSONObject object = tiktokService.certificateGet(byId.getEncryptedCode());
JSONObject certificate = object.getJSONObject("certificate");
Integer status = certificate.getInt("status");
Boolean isDelete = false;
......
......@@ -338,7 +338,7 @@ public class TiktokServiceImpl implements TiktokService {
if (StringUtils.isEmpty(sStore.getTiktokPoiId())) {
throw new RuntimeException("门店未授权,请联系管理员");
}
if (code.startsWith("https://v.douyin.com/") | code.length() == 15) {
if (code.startsWith("https://v.douyin.com/") | code.length() == 15 | code.length() == 12) {
try {
TiktokCouponDto tiktokCouponDto = new TiktokCouponDto();
if (code.startsWith("https://v.douyin.com/")) {
......@@ -376,11 +376,16 @@ public class TiktokServiceImpl implements TiktokService {
codes.add(e.getStr("encrypted_code"));
});
couponDto.setEncryptedCodes(codes);
verify(couponDto);
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(entries.getStr("encrypted_code"));
sConsumerCoupon.setCouponCode(originCode);
sConsumerCoupon.setEncryptedCode(entries.getStr("encrypted_code"));
sConsumerCoupon.setName(sku.getStr("title"));
sConsumerCoupon.setSourceType(SourceTypeEnum.CHECK.getCode());
sConsumerCoupon.setPlatformType(PlatformTypeEnum.TIKTOK.getCode());
......
......@@ -14,6 +14,7 @@
<result property="tiktokSkuId" column="tiktok_sku_id"/>
<result property="storeIds" column="store_ids"/>
<result property="couponCode" column="coupon_code" />
<result property="encryptedCode" column="encrypted_code"/>
<result property="name" column="name" />
<result property="couponType" column="coupon_type" />
<result property="couponTimeStart" column="coupon_time_start" />
......@@ -54,6 +55,7 @@
tiktok_sku_id,
store_ids,
coupon_code,
encrypted_code,
name,
coupon_type,
coupon_time_start,
......@@ -95,6 +97,7 @@
<if test="storeId !=null">and store_id = #{storeId}</if>
<if test="dealId !=null">and deal_id=#{dealId}</if>
<if test="couponCode != null and couponCode != ''"> and coupon_code = #{couponCode}</if>
<if test="encryptedCode != null and encryptedCode != ''">and encrypted_code = #{encryptedCode}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="couponType != null and couponType != ''"> and coupon_type = #{couponType}</if>
<if test="couponTimeStart != null "> and coupon_time_start = #{couponTimeStart}</if>
......@@ -149,6 +152,7 @@
<if test="storeId != null">store_id,</if>
<if test="dealId != null">deal_id,</if>
<if test="couponCode != null and couponCode != ''">coupon_code,</if>
<if test="encryptedCode != null and encryptedCode != ''">encrypted_code,</if>
<if test="name != null and name != ''">name,</if>
<if test="couponType != null">coupon_type,</if>
<if test="couponTimeStart != null">coupon_time_start,</if>
......@@ -187,6 +191,7 @@
<if test="storeId != null">#{storeId},</if>
<if test="dealId != null">#{dealId},</if>
<if test="couponCode != null and couponCode != ''">#{couponCode},</if>
<if test="encryptedCode != null and encryptedCode != ''">#{encryptedCode},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="couponType != null">#{couponType},</if>
<if test="couponTimeStart != null">#{couponTimeStart},</if>
......@@ -229,6 +234,7 @@
<if test="storeId != null">store_id = #{storeId}</if>
<if test="dealId != null">deal_id = #{dealId},</if>
<if test="couponCode != null and couponCode != ''">coupon_code = #{couponCode},</if>
<if test="encryptedCode != null and encryptedCode != ''">encrypted_code = #{encryptedCode},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="couponType != null">coupon_type = #{couponType},</if>
<if test="couponTimeStart != null">coupon_time_start = #{couponTimeStart},</if>
......
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