Commit 81caf6da by 吕明尚

订单表增加商户订单号字段,增加验券逻辑

parent 589e0cb7
......@@ -6,20 +6,22 @@ import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.domain.vo.FrontTokenComponent;
import share.system.service.ISConsumerCouponService;
import java.util.List;
/**
* 优惠券领取记录Controller
*
*
* @author wuwenlong
* @date 2023-10-12
*/
@RestController
@RequestMapping("/front/consumerCoupon")
public class SConsumerCouponController extends BaseController
{
public class SConsumerCouponController extends BaseController {
@Autowired
private ISConsumerCouponService sConsumerCouponService;
......@@ -28,8 +30,9 @@ public class SConsumerCouponController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:coupon:list')")
@GetMapping("/list")
public TableDataInfo list(SConsumerCoupon sConsumerCoupon)
{
public TableDataInfo list(SConsumerCoupon sConsumerCoupon) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setConsumerId(user.getId());
startPage();
List<SConsumerCoupon> list = sConsumerCouponService.selectSConsumerCouponList(sConsumerCoupon);
return getDataTable(list);
......@@ -40,9 +43,18 @@ public class SConsumerCouponController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:coupon:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(sConsumerCouponService.selectSConsumerCouponById(id));
}
@PreAuthorize("@ss.hasPermi('system:coupon:list')")
@GetMapping("/query")
public List<SConsumerCoupon> query(SConsumerCoupon sConsumerCoupon) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sConsumerCoupon.setConsumerId(user.getId());
return sConsumerCouponService.selectSConsumerCouponList(sConsumerCoupon);
}
}
......@@ -2,6 +2,8 @@ package share.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -16,6 +18,8 @@ import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.common.enums.RoomType;
import share.common.enums.StoreType;
import share.system.domain.SCoupon;
import share.system.service.ISCouponService;
import share.common.utils.poi.ExcelUtil;
......@@ -77,6 +81,12 @@ public class SCouponController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SCoupon sCoupon)
{
if (StringUtils.isNotBlank(sCoupon.getRoomType())){
sCoupon.setRoomType(String.valueOf(RoomType.getCodeList()));
}
if (StringUtils.isNotBlank(sCoupon.getStoreType())){
sCoupon.setStoreType(String.valueOf(StoreType.getCodeList()));
}
return toAjax(sCouponService.insertSCoupon(sCoupon));
}
......
......@@ -22,18 +22,29 @@ import javax.validation.constraints.NotBlank;
* @date 2023-10-09
*/
@Data
public class SOrder extends BaseEntity
{
public class SOrder extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 订单ID */
/**
* 订单ID
*/
private Long id;
/** 订单流水号 */
/**
* 订单流水号
*/
@Excel(name = "订单编号")
private String orderNo;
/** 订单类型(0:订房订单,1:续房订单,2:充值订单) */
/**
* 订单流水号
*/
@Excel(name = "订单编号")
private String outTradeNo;
/**
* 订单类型(0:订房订单,1:续房订单,2:充值订单)
*/
@Excel(name = "订单类型(0:订房订单,1:续房订单,2:充值订单)")
private Integer orderType;
......@@ -49,15 +60,21 @@ public class SOrder extends BaseEntity
@Excel(name = "房间ID")
private Long roomId;
/** 用户ID */
/**
* 用户ID
*/
@Excel(name = "用户ID")
private Long consumerId;
/** 用户名称 */
/**
* 用户名称
*/
@Excel(name = "用户名称")
private String consumerName;
/** 用户手机号 */
/**
* 用户手机号
*/
@Excel(name = "用户手机号")
private String consumerPhone;
......@@ -67,7 +84,9 @@ public class SOrder extends BaseEntity
@ApiModelProperty(value = "套餐金额")
private BigDecimal packPrice;
/** 优惠券id */
/**
* 优惠券id
*/
@Excel(name = "优惠券id")
private String couponId;
......@@ -86,27 +105,37 @@ public class SOrder extends BaseEntity
@Excel(name = "订单时长(H)")
private String timeLong;
/** 预约开始时间 */
/**
* 预约开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "预约开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date preStartDate;
/** 预约结束时间 */
/**
* 预约结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "预约结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date preEndDate;
/** 开始时间 */
/**
* 开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date startDate;
/** 结束时间 */
/**
* 结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
private Date endDate;
/** 订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/退款中) */
/**
* 订单状态(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/退款中)
*/
@Excel(name = "订单状态(0:待使用/已预约,1:使用中,2:已使用)")
private Integer status;
......
......@@ -15,8 +15,10 @@ import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdRes
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SCoupon;
import share.system.domain.vo.FrontTokenComponent;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.MTService;
......@@ -39,16 +41,17 @@ public class MTServiceImpl implements MTService {
//执行验券
@Override
public MeituanResponse verificationVouchers(String code, int num) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
//验券准备
MeituanResponse preparation = preparation(code);
//验券准备失败
if(!preparation.isSuccess()){
if (!preparation.isSuccess()) {
throw new RuntimeException(preparation.getMsg());
}
//返回验券准备数据
MsSuperPrepareResponse data = (MsSuperPrepareResponse)preparation.getData();
SCoupon sCoupon = isCouponService.selectSCouponByName(data.getDealTitle());
if(sCoupon == null){
MsSuperPrepareResponse data = (MsSuperPrepareResponse) preparation.getData();
SCoupon sCoupon = isCouponService.selectSCouponByName(data.getDealTitle());
if (sCoupon == null) {
throw new RuntimeException("未找到对应的优惠券");
}
//执行验券
......@@ -65,12 +68,28 @@ public class MTServiceImpl implements MTService {
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
if (response.isSuccess()){
//验券成功
if (response.isSuccess()) {
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(user.getId());
sConsumerCoupon.setCouponId(sCoupon.getId());
sConsumerCoupon.setCouponCode(code);
sConsumerCoupon.setName(sCoupon.getName());
sConsumerCoupon.setCouponType(String.valueOf(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("3");
sConsumerCoupon.setPlatformType("2");
sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(sCoupon.getEndDate());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
}else{
} else {
return response;
}
return response;
......@@ -79,7 +98,7 @@ public class MTServiceImpl implements MTService {
//撤销验券
@Override
public MeituanResponse revoke(String ERPId, String ERPName, String couponCode) {
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId,signKey).build();
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
CouponCancelRequest couponCancelRequest = new CouponCancelRequest();
couponCancelRequest.setEId(ERPId);
couponCancelRequest.setEName(ERPName);
......@@ -91,7 +110,7 @@ public class MTServiceImpl implements MTService {
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
return response;
return response;
}
//验券准备
......@@ -102,7 +121,7 @@ public class MTServiceImpl implements MTService {
msSuperPrepareRequest.setCode(code);
MeituanResponse<MsSuperPrepareResponse> response = null;
try {
response = meituanClient.invokeApi(msSuperPrepareRequest,appAuthToken);
response = meituanClient.invokeApi(msSuperPrepareRequest, appAuthToken);
} catch (MtSdkException e) {
throw new RuntimeException(e);
}
......
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