Commit 561dfd83 by 吕明尚

验劵准备和验劵接口增加记录

parent 279c77bd
...@@ -19,6 +19,8 @@ import com.dianping.openapi.sdk.api.tuangou.entity.*; ...@@ -19,6 +19,8 @@ import com.dianping.openapi.sdk.api.tuangou.entity.*;
import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient; import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -49,7 +51,7 @@ public class QPServiceImpl implements QPService { ...@@ -49,7 +51,7 @@ public class QPServiceImpl implements QPService {
private String APP_KEY; private String APP_KEY;
@Value("${dianping.appSecret}") @Value("${dianping.appSecret}")
private String APP_SECRET; private String APP_SECRET;
private static final Logger logger = LoggerFactory.getLogger(QPServiceImpl.class);
@Autowired @Autowired
private ISCouponService isCouponService; private ISCouponService isCouponService;
...@@ -208,6 +210,8 @@ public class QPServiceImpl implements QPService { ...@@ -208,6 +210,8 @@ public class QPServiceImpl implements QPService {
if (Boolean.FALSE.equals(b)) { if (Boolean.FALSE.equals(b)) {
throw new RuntimeException("请联系管理员"); throw new RuntimeException("请联系管理员");
} }
logger.info("code:{}", code);
logger.info("验卷准备开始");
String o = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue()); String o = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
JSONObject sessionKey = new JSONObject(o); JSONObject sessionKey = new JSONObject(o);
String session = (String) sessionKey.get("access_token"); String session = (String) sessionKey.get("access_token");
...@@ -216,8 +220,10 @@ public class QPServiceImpl implements QPService { ...@@ -216,8 +220,10 @@ public class QPServiceImpl implements QPService {
DefaultOpenAPIClient client = new DefaultOpenAPIClient(); DefaultOpenAPIClient client = new DefaultOpenAPIClient();
TuangouReceiptPrepareResponse invoke = client.invoke(tuangouReceiptPrepare); TuangouReceiptPrepareResponse invoke = client.invoke(tuangouReceiptPrepare);
if (invoke.getCode() != 200) { if (invoke.getCode() != 200) {
logger.error("验卷准备失败:{}", invoke.getMsg());
throw new RuntimeException(invoke.getMsg()); throw new RuntimeException(invoke.getMsg());
} }
logger.info("验卷准备结束:{}", invoke.getData());
return invoke.getData(); return invoke.getData();
} }
...@@ -228,6 +234,8 @@ public class QPServiceImpl implements QPService { ...@@ -228,6 +234,8 @@ public class QPServiceImpl implements QPService {
@Override @Override
public List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid) { public List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid) {
String o = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue()); String o = redisUtil.get(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
logger.info("code:{}", code);
logger.info("验卷开始");
JSONObject sessionKey = new JSONObject(o); JSONObject sessionKey = new JSONObject(o);
String session = (String) sessionKey.get("access_token"); String session = (String) sessionKey.get("access_token");
SConsumer user = FrontTokenComponent.getWxSConsumerEntry(); SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
...@@ -238,9 +246,11 @@ public class QPServiceImpl implements QPService { ...@@ -238,9 +246,11 @@ public class QPServiceImpl implements QPService {
TuangouReceiptConsume tuangouReceiptConsume = new TuangouReceiptConsume(request); TuangouReceiptConsume tuangouReceiptConsume = new TuangouReceiptConsume(request);
TuangouReceiptConsumeResponse invoke = openAPIClient.invoke(tuangouReceiptConsume); TuangouReceiptConsumeResponse invoke = openAPIClient.invoke(tuangouReceiptConsume);
if (invoke.getCode() != 200) { if (invoke.getCode() != 200) {
logger.error("验卷失败:{}", invoke.getMsg());
throw new RuntimeException(invoke.getMsg()); throw new RuntimeException(invoke.getMsg());
} }
redisUtil.delete(ReceiptRdeisEnum.PREPARE.getValue() + code); redisUtil.delete(ReceiptRdeisEnum.PREPARE.getValue() + code);
logger.info("验卷结束:{}", invoke.getData());
return invoke.getData(); return invoke.getData();
} }
......
...@@ -722,11 +722,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -722,11 +722,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
SStore sStore = storeService.getById(sOrder.getStoreId()); SStore sStore = storeService.getById(sOrder.getStoreId());
if (couponId != null && couponId > 0) { if (couponId != null && couponId > 0) {
SConsumerCoupon consumerCoupon = consumerCouponService.getById(couponId); SConsumerCoupon consumerCoupon = consumerCouponService.getById(couponId);
if (consumerCoupon != null) { if (ObjectUtil.isNotEmpty(consumerCoupon)) {
if (consumerCoupon.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
qpService.consume(consumerCoupon.getCouponCode(), 1, sStore.getOpenShopUuid()); qpService.consume(consumerCoupon.getCouponCode(), 1, sStore.getOpenShopUuid());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode()); consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon); consumerCouponService.updateById(consumerCoupon);
}
} }
} }
//续费成功语音播报 //续费成功语音播报
......
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