Commit 589e0cb7 by 吕明尚

修改优惠卷表字段

parent 526d8d18
...@@ -2,6 +2,8 @@ package share.web.controller.system; ...@@ -2,6 +2,8 @@ package share.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -16,6 +18,8 @@ import share.common.annotation.Log; ...@@ -16,6 +18,8 @@ import share.common.annotation.Log;
import share.common.core.controller.BaseController; import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult; import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType; import share.common.enums.BusinessType;
import share.common.enums.RoomType;
import share.common.enums.StoreType;
import share.system.domain.SCoupon; import share.system.domain.SCoupon;
import share.system.service.ISCouponService; import share.system.service.ISCouponService;
import share.common.utils.poi.ExcelUtil; import share.common.utils.poi.ExcelUtil;
...@@ -77,6 +81,12 @@ public class SCouponController extends BaseController ...@@ -77,6 +81,12 @@ public class SCouponController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SCoupon sCoupon) 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)); return toAjax(sCouponService.insertSCoupon(sCoupon));
} }
......
...@@ -18,27 +18,27 @@ public class MTController { ...@@ -18,27 +18,27 @@ public class MTController {
@GetMapping("/verificationVouchers") @GetMapping("/verificationVouchers")
@Log(title = "执行验券") @Log(title = "执行验券")
public String verificationVouchers(String code, int num){ public String verificationVouchers(String code, int num){
return mtService.verificationVouchers(code, num); return mtService.verificationVouchers(code, num).getMsg();
} }
@GetMapping("/revoke") @GetMapping("/revoke")
@Log(title = "撤销验券") @Log(title = "撤销验券")
public String revoke(String ERPId ,String ERPName ,String couponCode){ public String revoke(String ERPId ,String ERPName ,String couponCode){
return mtService.revoke(ERPId, ERPName, couponCode); return mtService.revoke(ERPId, ERPName, couponCode).getMsg();
} }
@GetMapping("/preparation") @GetMapping("/preparation")
@Log(title = "验券准备") @Log(title = "验券准备")
public String preparation(String code){ public String preparation(String code){
return mtService.preparation(code); return mtService.preparation(code).getMsg();
} }
@GetMapping("/consume") @GetMapping("/consume")
@Log(title = "已验券码查询") @Log(title = "已验券码查询")
public String verified(String code){ public String verified(String code){
return mtService.verified(code); return mtService.verified(code).getMsg();
} }
} }
...@@ -27,6 +27,34 @@ public class SCoupon extends BaseEntity ...@@ -27,6 +27,34 @@ public class SCoupon extends BaseEntity
@Excel(name = "优惠券名称") @Excel(name = "优惠券名称")
private String name; private String name;
/** 有效期开始 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效期开始", width = 30, dateFormat = "yyyy-MM-dd")
private Date startDate;
/** 有效期结束 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效期结束", width = 30, dateFormat = "yyyy-MM-dd")
private Date endDate;
/** 有效开始时段 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效开始时段", width = 30, dateFormat = "yyyy-MM-dd")
private Date validStartTime;
/** 有效结束时段 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效结束时段", width = 30, dateFormat = "yyyy-MM-dd")
private Date validEndTime;
//门店类型
@Excel(name = "门店类型(1:标准店,2:外卖店,3:酒店,4:其他)")
private String storeType;
//房间类型
@Excel(name = "房间类型(1:标间,2:豪华间,3:总统套房,4:商务套房,5:行政套房,6:其他)")
private String roomType;
/** 优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额) */ /** 优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额) */
@Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额)") @Excel(name = "优惠券类型(1:折扣券,2,团购券,3:满减券,4:核销券,5:充值送金额)")
private Integer couponType; private Integer couponType;
...@@ -44,28 +72,22 @@ public class SCoupon extends BaseEntity ...@@ -44,28 +72,22 @@ public class SCoupon extends BaseEntity
private String duration; private String duration;
/** 满减最小可使用金额 */ /** 满减最小可使用金额 */
@Excel(name = "满减最小可使用金额") @Excel(name = "门槛金额")
private BigDecimal minPrice; private BigDecimal minPrice;
/** 减去金额(满减券单位:元,折扣为系数) */ /** 减去金额(满减券单位:元,折扣为系数) */
@Excel(name = "减去金额(满减券单位:元,折扣为系数)") @Excel(name = "减去金额(满减券单位:元,折扣为系数)")
private BigDecimal subPrice; private BigDecimal subPrice;
/** 第三方平台名称 */ /** 是否可叠加使用(0:不可叠加,1:可叠加) */
@Excel(name = "第三方平台名称") @Excel(name = "是否可叠加使用(0:不可叠加,1:可叠加)")
private String platform; private Integer isOverlay;
/** 第三方平台类型(1:美团,2,大众点评) */ /** 第三方平台类型(1:美团,2,大众点评) */
@Excel(name = "第三方平台类型(1:美团,2,大众点评)") @Excel(name = "第三方平台类型(1:美团,2,大众点评)")
private Integer platformType; private Integer platformType;
/** 有效期开始 */ /** 优惠券数量 */
@JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "优惠券数量")
@Excel(name = "有效期开始", width = 30, dateFormat = "yyyy-MM-dd") private Integer number;
private Date startDate;
/** 有效期结束 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效期结束", width = 30, dateFormat = "yyyy-MM-dd")
private Date endDate;
} }
...@@ -58,4 +58,6 @@ public interface SCouponMapper ...@@ -58,4 +58,6 @@ public interface SCouponMapper
* @return 结果 * @return 结果
*/ */
public int deleteSCouponByIds(Long[] ids); public int deleteSCouponByIds(Long[] ids);
SCoupon selectSCouponByName(String dealTitle);
} }
...@@ -58,4 +58,11 @@ public interface ISCouponService ...@@ -58,4 +58,11 @@ public interface ISCouponService
* @return 结果 * @return 结果
*/ */
public int deleteSCouponById(Long id); public int deleteSCouponById(Long id);
/**
* 根据优惠券名称查询优惠券
* @param dealTitle 优惠券名称
* @return 结果
*/
SCoupon selectSCouponByName(String dealTitle);
} }
package share.system.service; package share.system.service;
import com.meituan.sdk.MeituanResponse;
public interface MTService { public interface MTService {
public String verificationVouchers(String code, int num); MeituanResponse verificationVouchers(String code, int num);
public String revoke (String ERPId ,String ERPName ,String couponCode); MeituanResponse revoke (String ERPId ,String ERPName ,String couponCode);
String preparation (String code); MeituanResponse preparation (String code);
String verified (String code); MeituanResponse verified (String code);
} }
...@@ -12,8 +12,13 @@ import com.meituan.sdk.model.tuangouNg.coupon.msSuperPrepare.MsSuperPrepareReque ...@@ -12,8 +12,13 @@ import com.meituan.sdk.model.tuangouNg.coupon.msSuperPrepare.MsSuperPrepareReque
import com.meituan.sdk.model.tuangouNg.coupon.msSuperPrepare.MsSuperPrepareResponse; import com.meituan.sdk.model.tuangouNg.coupon.msSuperPrepare.MsSuperPrepareResponse;
import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdRequest; import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdRequest;
import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdResponse; import com.meituan.sdk.model.tuangouNg.coupon.queryCouponById.QueryCouponByIdResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SCoupon;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.MTService; import share.system.service.MTService;
@Service @Service
...@@ -24,9 +29,29 @@ public class MTServiceImpl implements MTService { ...@@ -24,9 +29,29 @@ public class MTServiceImpl implements MTService {
private String appAuthToken; private String appAuthToken;
@Value("${meituan.developerId}") @Value("${meituan.developerId}")
private Long developerId; private Long developerId;
@Autowired
private ISCouponService isCouponService;
@Autowired
private ISConsumerCouponService isConsumerCouponService;
//执行验券 //执行验券
@Override @Override
public String verificationVouchers(String code, int num) { public MeituanResponse verificationVouchers(String code, int num) {
//验券准备
MeituanResponse preparation = preparation(code);
//验券准备失败
if(!preparation.isSuccess()){
throw new RuntimeException(preparation.getMsg());
}
//返回验券准备数据
MsSuperPrepareResponse data = (MsSuperPrepareResponse)preparation.getData();
SCoupon sCoupon = isCouponService.selectSCouponByName(data.getDealTitle());
if(sCoupon == null){
throw new RuntimeException("未找到对应的优惠券");
}
//执行验券
//developerId 服务商身份标识 signKey 服务商签名密钥 //developerId 服务商身份标识 signKey 服务商签名密钥
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build(); MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
MsSuperConsumeRequest msSuperConsumeRequest = new MsSuperConsumeRequest(); MsSuperConsumeRequest msSuperConsumeRequest = new MsSuperConsumeRequest();
...@@ -40,18 +65,20 @@ public class MTServiceImpl implements MTService { ...@@ -40,18 +65,20 @@ public class MTServiceImpl implements MTService {
} catch (MtSdkException e) { } catch (MtSdkException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (response.isSuccess()) { if (response.isSuccess()){
MsSuperConsumeResponse resp = response.getData(); SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
return resp.toString(); sConsumerCoupon.setStoreType(sCoupon.getStoreType());
} else { sConsumerCoupon.setRoomType(sCoupon.getRoomType());
System.out.println("调用失败"); isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
}else{
return response;
} }
return null; return response;
} }
//撤销验券 //撤销验券
@Override @Override
public String revoke(String ERPId, String ERPName, String couponCode) { 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 couponCancelRequest = new CouponCancelRequest();
couponCancelRequest.setEId(ERPId); couponCancelRequest.setEId(ERPId);
...@@ -64,18 +91,12 @@ public class MTServiceImpl implements MTService { ...@@ -64,18 +91,12 @@ public class MTServiceImpl implements MTService {
} catch (MtSdkException e) { } catch (MtSdkException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (response.isSuccess()) { return response;
CouponCancelResponse resp = response.getData();
return resp.toString();
} else {
System.out.println("调用失败");
}
return null;
} }
//验券准备 //验券准备
@Override @Override
public String preparation(String code) { public MeituanResponse preparation(String code) {
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build(); MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
MsSuperPrepareRequest msSuperPrepareRequest = new MsSuperPrepareRequest(); MsSuperPrepareRequest msSuperPrepareRequest = new MsSuperPrepareRequest();
msSuperPrepareRequest.setCode(code); msSuperPrepareRequest.setCode(code);
...@@ -85,18 +106,12 @@ public class MTServiceImpl implements MTService { ...@@ -85,18 +106,12 @@ public class MTServiceImpl implements MTService {
} catch (MtSdkException e) { } catch (MtSdkException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (response.isSuccess()) { return response;
MsSuperPrepareResponse resp = response.getData();
return resp.toString();
} else {
System.out.println("调用失败");
}
return null;
} }
//已验券码查询 //已验券码查询
@Override @Override
public String verified(String code) { public MeituanResponse verified(String code) {
MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build(); MeituanClient meituanClient = DefaultMeituanClient.builder(developerId, signKey).build();
QueryCouponByIdRequest queryCouponByIdRequest = new QueryCouponByIdRequest(); QueryCouponByIdRequest queryCouponByIdRequest = new QueryCouponByIdRequest();
queryCouponByIdRequest.setCouponCode(code); queryCouponByIdRequest.setCouponCode(code);
...@@ -106,14 +121,7 @@ public class MTServiceImpl implements MTService { ...@@ -106,14 +121,7 @@ public class MTServiceImpl implements MTService {
} catch (MtSdkException e) { } catch (MtSdkException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return response;
if (response.isSuccess()) {
QueryCouponByIdResponse resp = response.getData();
return resp.toString();
} else {
System.out.println("调用失败");
}
return null;
} }
} }
...@@ -93,4 +93,14 @@ public class SCouponServiceImpl implements ISCouponService ...@@ -93,4 +93,14 @@ public class SCouponServiceImpl implements ISCouponService
{ {
return sCouponMapper.deleteSCouponById(id); return sCouponMapper.deleteSCouponById(id);
} }
/**
* 根据优惠券名称查询优惠券
* @param dealTitle
* @return
*/
@Override
public SCoupon selectSCouponByName(String dealTitle) {
return sCouponMapper.selectSCouponByName(dealTitle);
}
} }
...@@ -101,35 +101,35 @@ ...@@ -101,35 +101,35 @@
<insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_order insert into s_order
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderNo != null"> order_no = #{orderNo},</if> <if test="orderNo != null and orderNo != ''"> order_no,</if>
<if test="orderType != null"> order_type = #{orderType},</if> <if test="orderType != null and orderType != ''"> order_type,</if>
<if test="payType != null"> pay_type = #{payType},</if> <if test="payType != null and payType != ''"> pay_type,</if>
<if test="payStatus != null"> pay_status = #{payStatus},</if> <if test="payStatus != null and payStatus != ''"> pay_status,</if>
<if test="storeId != null"> store_id = #{storeId},</if> <if test="storeId != null and storeId != ''"> store_id,</if>
<if test="roomId != null"> room_id = #{roomId},</if> <if test="roomId != null and roomId != ''"> room_id,</if>
<if test="consumerId != null"> consumer_id = #{consumerId},</if> <if test="consumerId != null and consumerId != ''"> consumer_id,</if>
<if test="consumerName != null"> consumer_name = #{consumerName},</if> <if test="consumerName != null and consumerName != ''"> consumer_name,</if>
<if test="consumerPhone != null"> consumer_phone = #{consumerPhone},</if> <if test="consumerPhone != null and consumerPhone != ''"> consumer_phone,</if>
<if test="packId != null"> pack_id = #{packId},</if> <if test="packId != null and packId != ''"> pack_id,</if>
<if test="packPrice != null"> pack_price = #{packPrice},</if> <if test="packPrice != null and packPrice != ''"> pack_price,</if>
<if test="couponId != null"> coupon_id = #{couponId},</if> <if test="couponId != null and couponId != ''"> coupon_id,</if>
<if test="couponPrice != null"> coupon_price = #{couponPrice},</if> <if test="couponPrice != null and couponPrice != ''"> coupon_price,</if>
<if test="totalPrice != null"> total_price = #{totalPrice},</if> <if test="totalPrice != null and totalPrice != ''"> total_price,</if>
<if test="payPrice != null"> pay_price = #{payPrice},</if> <if test="payPrice != null and payPrice != ''"> pay_price,</if>
<if test="payTime != null"> pay_time = #{payTime},</if> <if test="payTime != null and payTime != ''"> pay_time,</if>
<if test="timeLong != null"> time_long = #{timeLong},</if> <if test="timeLong != null and timeLong != ''"> time_long,</if>
<if test="preStartDate != null"> pre_start_date = #{preStartDate},</if> <if test="preStartDate != null and preStartDate != ''"> pre_start_date,</if>
<if test="preEndDate != null"> pre_end_date = #{preEndDate},</if> <if test="preEndDate != null and preEndDate != ''"> pre_end_date,</if>
<if test="startDate != null"> start_date = #{startDate},</if> <if test="startDate != null and startDate != ''"> start_date,</if>
<if test="endDate != null"> end_date = #{endDate},</if> <if test="endDate != null and endDate != ''"> end_date,</if>
<if test="status != null"> status = #{status},</if> <if test="status != null and status != ''"> status,</if>
<if test="refundStatus != null"> refund_status = #{refundStatus},</if> <if test="refundStatus != null and refundStatus != ''"> refund_status,</if>
<if test="refundReason != null"> refund_reason = #{refundReason},</if> <if test="refundReason != null and refundReason != ''"> refund_reason,</if>
<if test="refundReasonTime != null"> refund_reason_time = #{refundReasonTime},</if> <if test="refundReasonTime != null and refundReasonTime != ''"> refund_reason_time,</if>
<if test="refundPrice != null"> refund_price = #{refundPrice},</if> <if test="refundPrice != null and refundPrice != ''"> refund_price,</if>
<if test="isDelete != null"> is_delete = #{isDelete},</if> <if test="isDelete != null and isDelete != ''"> is_delete,</if>
<if test="createBy != null"> create_by = #{createBy},</if> <if test="createBy != null and createBy != ''"> create_by,</if>
<if test="createTime != null"> create_time = #{createTime},</if> <if test="createTime != null and createTime != ''"> create_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null"> #{orderNo},</if> <if test="orderNo != null"> #{orderNo},</if>
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
<if test="refundPrice != null"> #{refundPrice},</if> <if test="refundPrice != null"> #{refundPrice},</if>
<if test="isDelete != null"> 0,</if> <if test="isDelete != null"> 0,</if>
<if test="createBy != null"> #{createBy},</if> <if test="createBy != null"> #{createBy},</if>
<if test="createTime != null"> NOW(),</if> <if test="createTime != null"> #{createTime},</if>
</trim> </trim>
</insert> </insert>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> <component name="AdditionalModuleElements">
<output url="file://$MODULE_DIR$/target/classes" /> <content url="file://$MODULE_DIR$" dumb="true">
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>
\ No newline at end of file
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