Commit 941000a0 by 吕明尚

修改用户验劵接口,团购绑定的id改为门店id

parent 82880f41
......@@ -3,15 +3,13 @@ package share.web.controller.system;
import com.dianping.openapi.sdk.api.tuangou.entity.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.domain.R;
import share.common.enums.ConsumerCouponStatusEnum;
import share.system.domain.vo.TuangouReceiptPrepareResponseEntityVo;
import share.system.service.QPService;
import share.system.service.TiktokService;
import java.util.List;
......@@ -21,6 +19,8 @@ import java.util.List;
public class QPController {
@Autowired
private QPService qpService;
@Autowired
private TiktokService tiktokService;
//输码验券校验接口
@GetMapping("/prepare")
......@@ -48,12 +48,13 @@ public class QPController {
//用户验券接口
@GetMapping("/consumeByUser")
public R<TuangouReceiptPrepareResponseEntityVo> consumeByUser(String code, String openShopUuid) {
TuangouReceiptPrepareResponseEntityVo tuangouReceiptPrepareResponseEntityVo = qpService.consumeByUser(code, openShopUuid, ConsumerCouponStatusEnum.CONTROLLER.getCode());
if (ObjectUtils.isEmpty(tuangouReceiptPrepareResponseEntityVo)) {
return R.fail(tuangouReceiptPrepareResponseEntityVo, "该券码已被使用");
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) {
return R.ok(tiktokService.consumeByUser(code, storeId));
} else {
return R.ok(tuangouReceiptPrepareResponseEntityVo);
return R.fail("请输入正确的券码");
}
}
......
......@@ -64,7 +64,7 @@ public class TiktokController {
//用户验券接口
@GetMapping("/consumeByUser")
public AjaxResult consumeByUser(String code, String poiId) {
return success(tiktokService.consumeByUser(code, poiId));
public AjaxResult consumeByUser(String code, String storeId) {
return success(tiktokService.consumeByUser(code, storeId));
}
}
......@@ -22,6 +22,7 @@ public class SStore extends BaseEntity
private static final long serialVersionUID = 1L;
/** 门店ID */
@Excel(name = "门店ID")
@TableId(type = IdType.AUTO)
private Long id;
......
package share.system.domain.vo;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptPrepareResponseEntity;
import lombok.Data;
@Data
public class TuangouReceiptPrepareResponseEntityVo extends TuangouReceiptPrepareResponseEntity {
private String expirationTime;
private Long consumerCouponId;
}
......@@ -4,7 +4,6 @@ import com.dianping.openapi.sdk.api.customerauth.session.entity.CustomerKeyShopS
import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
import com.dianping.openapi.sdk.api.tuangou.entity.*;
import share.system.domain.vo.SessionVo;
import share.system.domain.vo.TuangouReceiptPrepareResponseEntityVo;
import java.util.List;
......@@ -17,7 +16,7 @@ public interface QPService {
TuangouReceiptGetConsumedReponseEntity getconsumed(String code, String openShopUuid);
TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid, String status);
String consumeByUser(String code, String storeId, String status);
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsumeByUser(Long id);
......
......@@ -24,7 +24,7 @@ public interface TiktokService {
JSONObject onlineGet(String productIds, String accountId);
String consumeByUser(String code, String poiId);
String consumeByUser(String code, String storeId);
List<TiktokPoi> poiList();
}
......@@ -23,11 +23,8 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import share.common.core.redis.RedisUtil;
......@@ -39,7 +36,6 @@ import share.system.domain.SCoupon;
import share.system.domain.SStore;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SessionVo;
import share.system.domain.vo.TuangouReceiptPrepareResponseEntityVo;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.ISStoreService;
......@@ -47,7 +43,10 @@ import share.system.service.QPService;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Service
......@@ -91,16 +90,15 @@ public class QPServiceImpl implements QPService {
* 用户验卷接口
*/
@Override
public TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid, String status) {
public String consumeByUser(String code, String storeId, String status) {
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>();
sStoreLambdaQueryWrapper.eq(SStore::getOpenShopUuid, openShopUuid);
sStoreLambdaQueryWrapper.eq(SStore::getId, storeId);
SStore sStore = storeService.getOne(sStoreLambdaQueryWrapper);
if (ObjectUtils.isEmpty(sStore) || StoreStatusEnum.STOP.getIndex().equals(sStore.getStatus())) {
throw new RuntimeException("门店状态异常,请联系管理员");
}
//验券准备
TuangouReceiptPrepareResponseEntity prepare = prepare(code.trim(), openShopUuid, status);
TuangouReceiptPrepareResponseEntity prepare = prepare(code.trim(), sStore.getOpenShopUuid(), status);
//获取用户信息
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//查询领取记录表
......@@ -113,7 +111,6 @@ public class QPServiceImpl implements QPService {
throw new RuntimeException("该券已被领取");
}
//根据优惠卷名称查询优惠劵配置 查询list,取第一个
TuangouReceiptPrepareResponseEntityVo response = new TuangouReceiptPrepareResponseEntityVo();
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setDealId(prepare.getDeal_id());
......@@ -127,7 +124,7 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setCreateTime(new Date());
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(prepare.getDeal_marketprice()));
//查询美团团购信息
List<TuangouDealQueryShopDealResponseEntity> groupActivities = queryshopdeal(openShopUuid);
List<TuangouDealQueryShopDealResponseEntity> groupActivities = queryshopdeal(sStore.getOpenShopUuid());
groupActivities.forEach(o -> {
//套餐名称相同并且在售卖中
if (prepare.getDealgroup_id().equals(o.getDealgroup_id()) && saleStatusEnum.SELLING.getCode().equals(o.getSale_status())) {
......@@ -173,14 +170,9 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setRemark(sCoupon.getRemark());
}
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
response.setConsumerCouponId(sConsumerCoupon.getId());
String output1 = DateUtil.format(prepare.getReceiptEndDate(), DatePattern.NORM_DATETIME_PATTERN);
BeanUtils.copyProperties(prepare, response);
response.setExpirationTime(output1);
//核销美团券
consume(code.trim(), 1, openShopUuid, ConsumerCouponStatusEnum.ORDER.getCode());
return response;
consume(code.trim(), 1, sStore.getOpenShopUuid(), status);
return "验劵成功";
}
@Override
......
......@@ -302,9 +302,9 @@ public class TiktokServiceImpl implements TiktokService {
}
@Override
public String consumeByUser(String code, String poiId) {
public String consumeByUser(String code, String storeId) {
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>();
sStoreLambdaQueryWrapper.eq(SStore::getTiktokPoiId, poiId);
sStoreLambdaQueryWrapper.eq(SStore::getId, storeId);
SStore sStore = storeService.getOne(sStoreLambdaQueryWrapper);
if (ObjectUtils.isEmpty(sStore) || StoreStatusEnum.STOP.getIndex().equals(sStore.getStatus())) {
throw new RuntimeException("门店状态异常,请联系管理员");
......@@ -317,7 +317,7 @@ public class TiktokServiceImpl implements TiktokService {
} else {
tiktokCouponDto.setCode(code);
}
tiktokCouponDto.setPoiId(poiId);
tiktokCouponDto.setPoiId(sStore.getTiktokPoiId());
JSONObject prepare = prepare(tiktokCouponDto);
JSONArray certificates = prepare.getJSONArray("certificates");
Object o = certificates.get(0);
......@@ -388,7 +388,7 @@ public class TiktokServiceImpl implements TiktokService {
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
TiktokCouponDto couponDto = new TiktokCouponDto();
couponDto.setVerifyToken(prepare.getStr("verify_token"));
couponDto.setPoiId(poiId);
couponDto.setPoiId(sStore.getTiktokPoiId());
List<String> codes = new ArrayList<>();
List<JSONObject> list = certificates.toList(JSONObject.class);
//获取List中的encrypted_code
......
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