Commit af9a3b54 by 吕明尚

更改下单逻辑

parent 9b4257b8
......@@ -7,7 +7,7 @@ package share.common.enums;
public enum CouponTypeEnum {
//1:折扣券,2,团购券,3:满减券,4:套餐劵
DISCOUNT(1,"1","折扣券"),
CASH(2,"2","满减券(现金券)"),
CASH(2, "2", "团购券"),
DURATION(3, "3", "时长券"),
PACKAGE(4, "4", "套餐劵"),
;
......
......@@ -5,13 +5,10 @@ import java.util.List;
import java.util.stream.Collectors;
public enum RoomType {
//1:标间,2:豪华间,3:总统套房,4:商务套房,5:行政套房,6:其他
STANDARD("1", "标准间"),
HIGH("2", "豪华间"),
TOTAL("3", "总统套房"),
BUSINESS("4", "商务套房"),
ADMINISTRATIVE("5", "行政套房"),
OTHER("6", "其他"),
//1:中、2:大、3:豪华包
STANDARD("1", "中包"),
HIGH("2", "大包"),
TOTAL("3", "豪华包")
;
private String code;
private String name;
......
......@@ -5,11 +5,10 @@ import java.util.List;
import java.util.stream.Collectors;
public enum StoreType {
//1:标准店,2:外卖店,3:酒店,4:其他
//1:标准店 2: 形象店 3:旗舰店
STANDARD("1", "标准店"),
OUT_DELIVERY("2", "外卖店"),
HOTEL("3", "酒店"),
OTHER("4", "其他")
OUT_DELIVERY("2", "形象店"),
HOTEL("3", "旗舰店")
;
private String code;
private String name;
......
......@@ -21,32 +21,32 @@ public class QPController {
//输码验券校验接口
@GetMapping("/prepare")
public R<TuangouReceiptPrepareResponseEntity> prepare(String code) {
return R.ok(qpService.prepare(code));
public R<TuangouReceiptPrepareResponseEntity> prepare(String code, String openShopUuid) {
return R.ok(qpService.prepare(code, openShopUuid));
}
//验券接口
@GetMapping("/consume")
public R<List<TuangouReceiptConsumeResponseEntity>> consume(String code, int count) {
return R.ok(qpService.consume(code, count));
public R<List<TuangouReceiptConsumeResponseEntity>> consume(String code, int count, String openShopUuid) {
return R.ok(qpService.consume(code, count, openShopUuid));
}
//撤销验券接口
@GetMapping("/reverseconsume")
public R<List<TuangouReceiptReverseConsumeResponseEntity>> reverseconsume(String code, Long appDealId) {
return R.ok(qpService.reverseconsume(code, appDealId));
public R<List<TuangouReceiptReverseConsumeResponseEntity>> reverseconsume(String code, Long appDealId, String openShopUuid) {
return R.ok(qpService.reverseconsume(code, appDealId, openShopUuid));
}
//查询已验券信息接口
@GetMapping("/getconsumed")
public R<TuangouReceiptGetConsumedReponseEntity> getconsumed(String code) {
return R.ok(qpService.getconsumed(code));
public R<TuangouReceiptGetConsumedReponseEntity> getconsumed(String code, String openShopUuid) {
return R.ok(qpService.getconsumed(code, openShopUuid));
}
//用户验券接口
@GetMapping("/consumeByUser")
public R<TuangouReceiptPrepareResponseEntityVo> consumeByUser(String code) {
return R.ok(qpService.consumeByUser(code));
public R<TuangouReceiptPrepareResponseEntityVo> consumeByUser(String code, String openShopUuid) {
return R.ok(qpService.consumeByUser(code, openShopUuid));
}
//用户销券接口
......@@ -63,7 +63,7 @@ public class QPController {
//获取商家所有的团购信息
@GetMapping("/queryshopdeal")
public R<List<TuangouDealQueryShopDealResponseEntity>> queryshopdeal() {
return R.ok(qpService.queryshopdeal());
public R<List<TuangouDealQueryShopDealResponseEntity>> queryshopdeal(String openShopUuid) {
return R.ok(qpService.queryshopdeal(openShopUuid));
}
}
......@@ -46,14 +46,14 @@ public class SConsumerCoupon extends BaseEntity
@Excel(name = "优惠券名称")
private String name;
//房间类型
@Excel(name = "房间类型(1:标间,2:豪华间,3:总统套房,4:商务套房,5:行政套房,6:其他)")
private String roomType;
//门店类型
@Excel(name = "门店类型(1:标准店,2:外卖店,3:酒店,4:其他)")
@Excel(name = "门店类型(1:标准店 2: 形象店 3:旗舰店)")
private String storeType;
//房间类型
@Excel(name = "房间类型(1:中、2:大、3:豪华包)")
private String roomType;
//优惠开始(有效)时段
@Excel(name = "优惠开始(有效)时段")
private String couponTimeStart;
......
......@@ -46,11 +46,11 @@ public class SCoupon extends BaseEntity
private String validEndTime;
//门店类型
@Excel(name = "门店类型(1:标准店,2:外卖店,3:酒店,4:其他)")
@Excel(name = "门店类型(1:标准店 2: 形象店 3:旗舰店)")
private String storeType;
//房间类型
@Excel(name = "房间类型(1:标间,2:豪华间,3:总统套房,4:商务套房,5:行政套房,6:其他)")
@Excel(name = "房间类型(1:中、2:大、3:豪华包)")
private String roomType;
/** 优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额) */
......
......@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import share.common.annotation.Excel;
import java.math.BigDecimal;
import java.util.Date;
......@@ -161,4 +162,28 @@ public class SOrderVo
@ApiModelProperty(value = "门店地址")
private String address;
/**
* 经度
*/
@ApiModelProperty(name = "经度")
private String longitude;
/**
* 纬度
*/
@ApiModelProperty(name = "纬度")
private String latitude;
/**
* 联系人
*/
@ApiModelProperty(name = "联系人")
private String manager;
/**
* 联系人电话
*/
@ApiModelProperty(name = "联系人电话")
private String phone;
}
......@@ -76,4 +76,8 @@ public class CreateOrderRequest {
@ApiModelProperty(value = "实际支付金额")
@NotNull(message = "实际支付金额不能为空")
private BigDecimal payFee;
@ApiModelProperty(value = "劵码")
private String code;
}
......@@ -6,19 +6,19 @@ import share.system.domain.vo.TuangouReceiptPrepareResponseEntityVo;
import java.util.List;
public interface QPService {
TuangouReceiptPrepareResponseEntity prepare(String code);
TuangouReceiptPrepareResponseEntity prepare(String code, String openShopUuid);
List<TuangouReceiptConsumeResponseEntity> consume(String code, int count);
List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid);
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume(String code, Long appDealId);
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume(String code, Long appDealId, String openShopUuid);
TuangouReceiptGetConsumedReponseEntity getconsumed(String code);
TuangouReceiptGetConsumedReponseEntity getconsumed(String code, String openShopUuid);
TuangouReceiptPrepareResponseEntityVo consumeByUser(String code);
TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid);
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsumeByUser(Long id);
String oauthToken(String authCode);
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal();
List<TuangouDealQueryShopDealResponseEntity> queryshopdeal(String openShopUuid);
}
......@@ -18,8 +18,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.common.enums.PlatformTypeEnum;
import share.common.enums.SourceTypeEnum;
import share.common.enums.*;
import share.system.domain.Device;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
......@@ -54,9 +53,9 @@ public class QPServiceImpl implements QPService {
* 用户验卷接口
*/
@Override
public TuangouReceiptPrepareResponseEntityVo consumeByUser(String code) {
public TuangouReceiptPrepareResponseEntityVo consumeByUser(String code, String openShopUuid) {
//验券准备
TuangouReceiptPrepareResponseEntity prepare = prepare(code);
TuangouReceiptPrepareResponseEntity prepare = prepare(code, "");
SCoupon sCoupon = isCouponService.selectSCouponByName(prepare.getDeal_title());
if (sCoupon == null) {
throw new RuntimeException("未找到对应的优惠券");
......@@ -65,17 +64,28 @@ public class QPServiceImpl implements QPService {
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)) {
throw new RuntimeException("该优惠券以领取");
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setDealId(prepare.getDeal_id());
sConsumerCoupon.setName(prepare.getDeal_title());
sConsumerCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
sConsumerCoupon.setStoreType(StoreType.getCodeList());
sConsumerCoupon.setRoomType(RoomType.getCodeList());
sConsumerCoupon.setEndDate(prepare.getReceiptEndDate());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
} else {
}
//执行验券
// List<TuangouReceiptConsumeResponseEntity> consume = consume(code, count);
// consume.forEach(item -> {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
//取订单ID,如果为空,则取套餐ID
sConsumerCoupon.setCouponId(prepare.getDeal_id());
sConsumerCoupon.setDealId(prepare.getDeal_id());
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponCode(code);
sConsumerCoupon.setName(prepare.getDeal_title());
sConsumerCoupon.setCouponType(sCoupon.getCouponType());
......@@ -94,8 +104,6 @@ public class QPServiceImpl implements QPService {
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();
......@@ -113,11 +121,11 @@ public class QPServiceImpl implements QPService {
if (StringUtils.isBlank(byId.getCouponCode())) {
throw new RuntimeException("未找到对应的券码");
}
TuangouReceiptGetConsumedReponseEntity getconsumed = getconsumed(byId.getCouponCode());
TuangouReceiptGetConsumedReponseEntity getconsumed = getconsumed(byId.getCouponCode(), "");
if (getconsumed == null) {
isConsumerCouponService.removeById(id);
} else {
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume = reverseconsume(byId.getCouponCode(), byId.getCouponId());
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume = reverseconsume(byId.getCouponCode(), byId.getCouponId(), "");
if (reverseconsume == null) {
throw new RuntimeException("未找到对应的券码");
}
......@@ -132,8 +140,8 @@ public class QPServiceImpl implements QPService {
* 根据团购券码,查询券码对应的dealid下,该用户可使用的券数据量
*/
@Override
public TuangouReceiptPrepareResponseEntity prepare(String code) {
TuangouReceiptPrepareRequest request = new TuangouReceiptPrepareRequest(APP_KEY, APP_SECRET, "04bdcb2ccac3075eac0f60680587be2138c6c362", code, "", OPEN_SHOP_UUID);
public TuangouReceiptPrepareResponseEntity prepare(String code, String openShopUuid) {
TuangouReceiptPrepareRequest request = new TuangouReceiptPrepareRequest(APP_KEY, APP_SECRET, "04bdcb2ccac3075eac0f60680587be2138c6c362", code, "", openShopUuid);
TuangouReceiptPrepare tuangouReceiptPrepare = new TuangouReceiptPrepare(request);
DefaultOpenAPIClient client = new DefaultOpenAPIClient();
TuangouReceiptPrepareResponse invoke = client.invoke(tuangouReceiptPrepare);
......@@ -148,11 +156,11 @@ public class QPServiceImpl implements QPService {
* 根据团购券码,一次性验证同一订单下的若干团购券 同一个用户,同一个dealid下的券码
*/
@Override
public List<TuangouReceiptConsumeResponseEntity> consume(String code, int count) {
public List<TuangouReceiptConsumeResponseEntity> consume(String code, int count, String openShopUuid) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
String requestid = UUID.randomUUID().toString();
TuangouReceiptConsumeRequest request = new TuangouReceiptConsumeRequest(APP_KEY, APP_SECRET, "04bdcb2ccac3075eac0f60680587be2138c6c362",
requestid, code, count, OPEN_SHOP_UUID,
requestid, code, count, openShopUuid,
user.getAccount(), user.getNickName());
DefaultOpenAPIClient openAPIClient = new DefaultOpenAPIClient();
TuangouReceiptConsume tuangouReceiptConsume = new TuangouReceiptConsume(request);
......@@ -168,10 +176,10 @@ public class QPServiceImpl implements QPService {
* 撤销已经核销的券码(只可撤销当天核销且未超过10分钟的团购券)
*/
@Override
public List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume(String code, Long appDealId) {
public List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume(String code, Long appDealId, String openShopUuid) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
TuangouReceiptReverseConsumeRequest tuangouReceiptReverseConsumeRequest = new TuangouReceiptReverseConsumeRequest(APP_KEY, APP_SECRET, "04bdcb2ccac3075eac0f60680587be2138c6c362",
String.valueOf(appDealId), code, OPEN_SHOP_UUID,
String.valueOf(appDealId), code, openShopUuid,
user.getAccount(), user.getNickName());
DefaultOpenAPIClient openAPIClient = new DefaultOpenAPIClient();
TuangouReceiptReverseConsume tuangouReceiptReverseConsume = new TuangouReceiptReverseConsume(tuangouReceiptReverseConsumeRequest);
......@@ -187,10 +195,10 @@ public class QPServiceImpl implements QPService {
* 查询已经验证的券码信息,仅支持已经验证的券码
*/
@Override
public TuangouReceiptGetConsumedReponseEntity getconsumed(String code) {
public TuangouReceiptGetConsumedReponseEntity getconsumed(String code, String openShopUuid) {
DefaultOpenAPIClient openAPIClient = new DefaultOpenAPIClient();
TuangouReceiptGetConsumedRequest request = new TuangouReceiptGetConsumedRequest(APP_KEY, APP_SECRET,
"04bdcb2ccac3075eac0f60680587be2138c6c362", code, OPEN_SHOP_UUID);
"04bdcb2ccac3075eac0f60680587be2138c6c362", code, openShopUuid);
TuangouReceiptGetConsumed tuangouReceiptGetConsumed = new TuangouReceiptGetConsumed(request);
TuangouReceiptGetConsumedReponse response = openAPIClient.invoke(tuangouReceiptGetConsumed);
if (response.getCode() != 200) {
......@@ -213,7 +221,7 @@ public class QPServiceImpl implements QPService {
}
//获取团购信息接口
public List<TuangouDealQueryShopDealResponseEntity> queryshopdeal() {
public List<TuangouDealQueryShopDealResponseEntity> queryshopdeal(String openShopUuid) {
/**
* @param app_key
* @param app_secret
......@@ -221,7 +229,7 @@ public class QPServiceImpl implements QPService {
* @param app_shop_id
*/
DefaultOpenAPIClient openAPIClient = new DefaultOpenAPIClient();
TuangouDealQueryShopDealRequest request = new TuangouDealQueryShopDealRequest(APP_KEY, APP_SECRET, "04bdcb2ccac3075eac0f60680587be2138c6c362", OPEN_SHOP_UUID, 1, 100);
TuangouDealQueryShopDealRequest request = new TuangouDealQueryShopDealRequest(APP_KEY, APP_SECRET, "04bdcb2ccac3075eac0f60680587be2138c6c362", "", 1, 100, openShopUuid);
TuangouDealQueryShopDeal tuangouDealQueryShopDeal = new TuangouDealQueryShopDeal(request);
TuangouDealQueryShopDealResponse response = openAPIClient.invoke(tuangouDealQueryShopDeal);
if (response.getCode() != 200) {
......@@ -237,4 +245,5 @@ public class QPServiceImpl implements QPService {
CustomerRefreshTokenResponse response = openAPIClient.invoke(refreshToken);
return response.getAccess_token();
}
}
......@@ -176,6 +176,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
if (ObjectUtil.isNull(user)) {
throw new BaseException("您的登录已过期,请先登录");
}
//验劵
SOrder sOrder = generatSOrder(request,user);
//校验订单金额
checkOrderPrice(sOrder,user);
......@@ -254,12 +256,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
sOrder.setPayStatus(YesNoEnum.no.getIndex());
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
sOrder.setRefundStatus(RefundStatusEnum.UNREFUND.getCode());
sOrder.setPackId(request.getPackId());
//计算订单时长
sOrder.setTimeLong(DateUtils.differentHour(sOrder.getPreStartDate(),sOrder.getPreEndDate()).toString());
if(Objects.nonNull(sOrder.getPackId())&& sOrder.getPackId() != 0){
// 套餐订单,设置套餐金额
SPack pack = packService.getById(sOrder.getPackId());
SPack pack = packService.getById(request.getPackId());
sOrder.setPackPrice(pack.getPrice());
}
sOrder.setCreateTime(DateUtils.getNowDate());
......@@ -411,6 +412,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
vo.setStoreName(store.getName());
vo.setAddress(store.getAddress());
vo.setRoomName(room.getName());
vo.setLongitude(store.getLongitude());
vo.setLatitude(store.getLatitude());
vo.setManager(store.getManager());
vo.setPhone(store.getPhone());
return vo;
}
......
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