Browse Source

[砍价][新增]:砍价券支持两种支付方式,一种是全价立即支付,一种是砍价后低价支付

release_toaliyun_real
Stormeye Wu 7 years ago
parent
commit
ef8adf7666
3 changed files with 18 additions and 12 deletions
  1. +12
    -2
      mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxOrderService.java
  3. +5
    -9
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java

+ 12
- 2
mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java View File

@@ -84,7 +84,7 @@ public class WxOrderController extends BaseController {
}
}

@ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\"}")
@ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\"}")
@PostMapping("save")
public ResultData saveOrder(@RequestBody Map<String, String> paramMap) {
logger.info("OrderSave: " + paramMap.toString());
@@ -92,11 +92,13 @@ public class WxOrderController extends BaseController {
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
String couponChannelIdStr = paramMap.get("couponChannelId");
String couponIdStr = paramMap.get("couponId");
String pressStr = paramMap.get("press");

if (StringUtils.isBlank(couponChannelIdStr)) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空");
}
Long couponChannelId = 0L, couponId = 0L;
boolean isPress = false;

if (StringUtils.isNotBlank(couponChannelIdStr)) {
try {
@@ -132,10 +134,18 @@ public class WxOrderController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId或者couponId不能为空");
}

if(pressStr != null) {
try{
isPress = Boolean.valueOf(pressStr);
} catch (Exception e) {
logger.error("press转换失败");
}
}

WxCUser user = getUser();

try {
WxOrder order = wxOrderService.saveCouponOrder(user, couponChannelId, couponId);
WxOrder order = wxOrderService.saveCouponOrder(user, couponChannelId, couponId, isPress);
return new ResultData(order);
} catch (MallinkException e) {
logger.error(e.getMessage());


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/WxOrderService.java View File

@@ -39,7 +39,7 @@ public interface WxOrderService {
* @param couponId
* @return 订单id
*/
WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId);
WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress);

/**
* 付款码支付


+ 5
- 9
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java View File

@@ -312,7 +312,7 @@ public class WxOrderServiceImpl implements WxOrderService {

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId) {
public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress) {
// 检查用户
if (user == null) {
logger.error("用户不存在");
@@ -339,16 +339,11 @@ public class WxOrderServiceImpl implements WxOrderService {
// 减库存操作
stockReduce(user, coupon, couponIdStr);

boolean isPress = false;
if (coupon.getType().equals(EnumCouponType.COUPON_PRESS.getCode())) {
isPress = true;
}

Date curr = new Date();

int payment = coupon.getSalePrice();
if (isPress) {
// 砍价券
// 砍价券 初始是全价即面额
payment = coupon.getPrice();
}

@@ -379,7 +374,7 @@ public class WxOrderServiceImpl implements WxOrderService {
record.setDetail(bodyStr);
record.setCreateDate(curr);
record.setUpdateDate(curr);
if(isPress) {
if (isPress) {
// 初始砍价信息
record.setPressCurrentNum(0);
record.setPressEndDate(DateUtils.getHourTimeAfter(coupon.getPressLimitHours(), curr));
@@ -396,7 +391,8 @@ public class WxOrderServiceImpl implements WxOrderService {
throw new MallinkException(ErrorCode.ORDER_SAVE_ERR);
}

if(isPress) {
if (isPress) {
// 初始砍价
// 添加 wx_order_press
int total = coupon.getPrice() - coupon.getSalePrice();
int left_total = total;


Loading…
Cancel
Save