Commit 97d8f520 by 吕明尚

更新下单逻辑

parent af9a3b54
package share.common.enums;
public enum saleStatusEnum {
//1-未开始售卖,2-售卖中,3-售卖结束
NOT_START("1", "未开始售卖"),
SELLING("2", "售卖中"),
END("3", "售卖结束"),
;
private String code;
private String name;
saleStatusEnum() {
}
saleStatusEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -77,9 +77,21 @@ public class SStore extends BaseEntity
@Excel(name = "门店类型 1:标准店 2: 形象店 3:旗舰店")
private String storeType;
@Excel(name = "美团点评店铺id")
private String openShopUuid;
@TableField(exist = false)
private List<SRoom> roolList;
public String getOpenShopUuid() {
return openShopUuid;
}
public void setOpenShopUuid(String openShopUuid) {
this.openShopUuid = openShopUuid;
}
public List<SRoom> getRoolList() {
return roolList;
}
......
......@@ -6,4 +6,5 @@ import lombok.Data;
@Data
public class TuangouReceiptPrepareResponseEntityVo extends TuangouReceiptPrepareResponseEntity {
private String expirationTime;
private Long consumerCouponId;
}
......@@ -60,15 +60,12 @@ public class QPServiceImpl implements QPService {
if (sCoupon == null) {
throw new RuntimeException("未找到对应的优惠券");
}
TuangouReceiptPrepareResponseEntityVo response = new TuangouReceiptPrepareResponseEntityVo();
//查询领取记录表
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SConsumerCoupon::getCouponId, prepare.getDeal_title());
SConsumerCoupon one = isConsumerCouponService.getOne(queryWrapper);
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal = queryshopdeal(openShopUuid);
queryshopdeal.stream().forEach(o -> {
});
if (ObjectUtils.isNotEmpty(one)) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setDealId(prepare.getDeal_id());
......@@ -78,35 +75,47 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setRoomType(RoomType.getCodeList());
sConsumerCoupon.setEndDate(prepare.getReceiptEndDate());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
//根据门店id查询门店信息
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal = queryshopdeal(openShopUuid);
queryshopdeal.stream().forEach(o -> {
//套餐名称相同并且在售卖中
if (prepare.getDeal_title().equals(o.getTitle()) && o.getSale_status().equals(saleStatusEnum.SELLING.getCode())) {
sConsumerCoupon.setCouponTimeStart(o.getReceipt_begin_date());
sConsumerCoupon.setCouponTimeEnd(o.getReceipt_end_date());
}
});
sConsumerCoupon.setCreateTime(new Date());
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
response.setConsumerCouponId(sConsumerCoupon.getId());
} else {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setDealId(prepare.getDeal_id());
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponCode(code);
sConsumerCoupon.setName(prepare.getDeal_title());
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.setSubPrice(sCoupon.getSubPrice());
sConsumerCoupon.setSourceType(SourceTypeEnum.CHECK.getCode());
sConsumerCoupon.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(prepare.getReceiptEndDate());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setCreateTime(new Date());
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
response.setConsumerCouponId(sConsumerCoupon.getId());
}
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setDealId(prepare.getDeal_id());
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponCode(code);
sConsumerCoupon.setName(prepare.getDeal_title());
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.setSubPrice(sCoupon.getSubPrice());
sConsumerCoupon.setSourceType(SourceTypeEnum.CHECK.getCode());
sConsumerCoupon.setPlatformType(PlatformTypeEnum.MEITUAN.getCode());
sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(prepare.getReceiptEndDate());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String output1 = format2.format(prepare.getReceiptEndDate());
TuangouReceiptPrepareResponseEntityVo response = new TuangouReceiptPrepareResponseEntityVo();
BeanUtils.copyProperties(prepare, response);
response.setExpirationTime(output1);
return response;
......
......@@ -81,6 +81,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Autowired
private DeviceOpService deviceOpService;
@Autowired
private QPService qpService;
/**
* 查询订单
......@@ -176,8 +178,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
if (ObjectUtil.isNull(user)) {
throw new BaseException("您的登录已过期,请先登录");
}
SStore sStore = storeService.getById(request.getStoreId());
//验劵
TuangouReceiptPrepareResponseEntityVo tuangouReceiptPrepareResponseEntityVo = qpService.consumeByUser(request.getCode(), sStore.getOpenShopUuid());
SOrder sOrder = generatSOrder(request,user);
//校验订单金额
checkOrderPrice(sOrder,user);
......@@ -195,8 +198,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
// 加入自动未支付自动取消队列
redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, sOrder.getOrderNo());
}
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
SConsumerCoupon consumerCoupon = new SConsumerCoupon();
consumerCoupon.setId(tuangouReceiptPrepareResponseEntityVo.getConsumerCouponId());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
} else {
consumerCouponService.deleteSConsumerCouponById(tuangouReceiptPrepareResponseEntityVo.getConsumerCouponId());
}
save(sOrder);
return response;
}
......
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