Commit 941000a0 by 吕明尚

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

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