Просмотр исходного кода

fix 添加平台推送订单增加方式

release_toaliyun_real
winter 4 лет назад
Родитель
Сommit
67ed1ff352
10 измененных файлов: 252 добавлений и 39 удалений
  1. +21
    -0
      mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java
  2. +32
    -0
      mallinkService/src/main/java/com/iformall/domain/dto/PlatPushOrderSaveDto.java
  3. +6
    -2
      mallinkService/src/main/java/com/iformall/service/WxOrderService.java
  4. +127
    -31
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  5. +5
    -0
      mallinkService/src/main/java/com/iformall/service/order/OrderAdapterService.java
  6. +8
    -2
      mallinkService/src/main/java/com/iformall/service/order/impl/SingleOrderAdapterService.java
  7. +26
    -1
      mallinkService/src/main/java/com/iformall/service/order/impl/batch/BaseBatchOrderAdapterService.java
  8. +8
    -2
      mallinkService/src/main/java/com/iformall/service/order/impl/batch/CouponPackageOrderAdapterService.java
  9. +9
    -1
      mallinkService/src/main/java/com/iformall/service/order/impl/batch/MulityNumberOneOrderBatchOrderAdapterService.java
  10. +10
    -0
      mallinkService/src/main/java/com/iformall/service/order/impl/batch/OneNumberOneOrderBatchOrderAdapterService.java

+ 21
- 0
mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java Просмотреть файл

@@ -8,6 +8,7 @@ import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.OrderSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponCVo;
@@ -138,6 +139,26 @@ public class WxOrderController extends BaseController {
return wxOrderService.composeSaveOrder(false,EnumComposeOrder.SINGLE,list,memberId,getPayWay(),getTenantInfo());
}
@ApiOperation(value = "抖音支付2.0与下单回调推送订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}")
@PostMapping("save")
public ResultData douyinPushOrder(@RequestBody Map param) {
logger.info("save douyinPushOrder:"+param);
Long memberId;
try {
memberId = getMemberId();
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
List<PlatPushOrderSaveDto> list = new ArrayList<>();
PlatPushOrderSaveDto dto = new PlatPushOrderSaveDto();
//TODO 从抖音推送的订单中取信息
list.add(dto);
return wxOrderService.platPushSaveOrder(false,EnumComposeOrder.ONE_NUMBER_ORDER_BATCH,list,memberId,getPayWay(),getTenantInfo());
}
@ApiOperation(value = "取消订单", notes = "{\"orderId\":\"string\"}")
@PostMapping("cancel")
public ResultData cancelOrder(@RequestBody Map<String, String> paramMap) {


+ 32
- 0
mallinkService/src/main/java/com/iformall/domain/dto/PlatPushOrderSaveDto.java Просмотреть файл

@@ -0,0 +1,32 @@
package com.iformall.domain.dto;

import lombok.Data;
import java.io.Serializable;

import com.iformall.domain.po.UserBasicInfoAddress;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;

@Data
public class PlatPushOrderSaveDto implements Serializable {

private static final long serialVersionUID = 1L;

Long couponChannelId;//【传入参数】渠道商品编号,对饮我们系统的编号
int count;//【传入参数】购买数量

Long orderGroupId;//【传入参数】拼团主订单号
boolean isPress = false;//【传入参数】,是否砍价
String formId ; //【传入参数】,非必传
Integer shippingType = 0;//EnumOrderShopingType【传入参数】配送类型
UserBasicInfoAddress address;//【传入参数】配送地址
String extParam;//【传入参数】json,额外的信息,可能每个平台不一样
WxCoupon wxCoupon;//【非传入参数】。
WxCouponChannel wxCouponChannel;//【非传入参数】。

}

+ 6
- 2
mallinkService/src/main/java/com/iformall/service/WxOrderService.java Просмотреть файл

@@ -11,6 +11,7 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.OrderSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponSendVo;
@@ -215,8 +216,8 @@ public interface WxOrderService {
Integer shippingType, UserBasicInfoAddress address);

// 3. 创建有价订单
WxOrder saveNoFreeOrderForCoupon(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,WxCouponChannel couponChannel,
OrderComposeSaveDto orderdto,EnumPayWay payWay);
WxOrder saveNoFreeOrderForCoupon(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,
boolean isPressOrder,Long orderGroupId,String formId,Integer shippinType,UserBasicInfoAddress address,WxCouponChannel couponChannel,EnumPayWay payWay);

/**
* 下订单成功后处理
@@ -244,6 +245,9 @@ public interface WxOrderService {
//ResultData saveOrder(OrderSaveDto orderSaveDto,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity);
ResultData composeSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<OrderComposeSaveDto> composeOrderSaveDto,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity);
//平台推送订单,如抖音支付2.0
ResultData platPushSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<PlatPushOrderSaveDto> platPushOrderList,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity);

void sendInsideOrderPushMsg(TenantEntity tenantEntity,Long composeOrderId);



+ 127
- 31
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Просмотреть файл

@@ -57,6 +57,7 @@ import com.iformall.common.IdWorker;
import com.iformall.common.ResultData;
import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.OrderSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.domain.dto.WxSharingOrderDto;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.exception.MallinkException;
@@ -2765,6 +2766,51 @@ public class WxOrderServiceImpl implements WxOrderService {
@Autowired
@Qualifier("cUserBasicInfoRedisTemplate")
RedisTemplate<String, WxCUserBasicInfo> cUserBasicInfoRedisTemplate;
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxComposeOrder savePlatPushOrderForCoupon(TenantEntity tenantEntity,boolean allowUnPayOrder,EnumComposeOrder composeOrderType,WxCUserBasicInfo user,List<PlatPushOrderSaveDto> platPushOrderList,EnumPayWay payWay) {
WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy();
// 防止同一用户重复下单,1秒内
String key = new StringBuilder().append("savePlatPushOrder:").append(user.getId()).toString();
boolean hasKey = cUserBasicInfoRedisTemplate.hasKey(key);
if (hasKey) {
logger.error("用户正在下单,请求异常返回,user: {} " + JSON.toJSONString(user));
throw new MallinkException(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION);
}
cUserBasicInfoRedisTemplate.opsForValue().set(key, user, 1000, TimeUnit.MILLISECONDS);

OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrderType.getCode());
//从这里开始,就需要锁住渠道的价格,不能修改
WxComposeOrder composeOrder = orderAdapterService.createDBMainOrderByPushOrder(tenantEntity,user, platPushOrderList, payWay);
Date orderDate = new Date();
WxOrder lastOrder = null;
for (int i = 0 ; i < platPushOrderList.size(); i ++) {
PlatPushOrderSaveDto orderdto = platPushOrderList.get(i);
Map<Long,WxCouponChannel> couponChannelMap = composeOrder.getCouponChannelMap();
Long couponChannelId = orderdto.getCouponChannelId();
WxCouponChannel couponChannel = couponChannelMap.get(couponChannelId);
orderdto.setWxCouponChannel(couponChannel);
//券一个数量创建一个订单
boolean isOneNumberOneOrder = orderAdapterService.isOneNumberOneOrder();
if (isOneNumberOneOrder) {
for (int j = 0; j < orderdto.getCount(); j++) {
lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), 1,
orderdto.isPress(),orderdto.getOrderGroupId(),orderdto.getFormId(),orderdto.getShippingType(),orderdto.getAddress(),orderdto.getWxCouponChannel(), payWay);
}
}else {
lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), orderdto.getCount(),
orderdto.isPress(),orderdto.getOrderGroupId(),orderdto.getFormId(),orderdto.getShippingType(),orderdto.getAddress(),orderdto.getWxCouponChannel(), payWay);
}
}
//如果没有orderId,则用lastOrder的信息
if (EnumComposeOrder.isSingle(composeOrderType.getCode())) {
composeOrder.setSingleOrder(lastOrder);
}
return composeOrder;
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxComposeOrder saveOrderForCoupon(TenantEntity tenantEntity,boolean allowUnPayOrder,EnumComposeOrder composeOrderType,WxCUserBasicInfo user,List<OrderComposeSaveDto> orderSave,EnumPayWay payWay) {
@@ -2795,10 +2841,14 @@ public class WxOrderServiceImpl implements WxOrderService {
boolean isOneNumberOneOrder = orderAdapterService.isOneNumberOneOrder();
if (isOneNumberOneOrder) {
for (int j = 0; j < orderdto.getCount(); j++) {
lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), 1, orderdto, payWay);
lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), 1,
orderdto.getSignleOrder().isPressOrder(),orderdto.getSignleOrder().getOrderGroupId(),orderdto.getSignleOrder().getFormId(),
orderdto.getShippingType(),orderdto.getAddress(),orderdto.getWxCouponChannel(), payWay);
}
}else {
lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), orderdto.getCount(), orderdto, payWay);
lastOrder = proxy.handleSaveOrderForCouponSingle(orderDate,allowUnPayOrder,composeOrder, user, orderdto.getWxCoupon(), orderdto.getCount(),
orderdto.getSignleOrder().isPressOrder(),orderdto.getSignleOrder().getOrderGroupId(),orderdto.getSignleOrder().getFormId(),
orderdto.getShippingType(),orderdto.getAddress(),orderdto.getWxCouponChannel(), payWay);
}
}
//如果没有orderId,则用lastOrder的信息
@@ -2809,15 +2859,15 @@ public class WxOrderServiceImpl implements WxOrderService {
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxOrder handleSaveOrderForCouponSingle(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user,WxCoupon coupon,int perCouponNumber,OrderComposeSaveDto orderdto,EnumPayWay payWay) {
public WxOrder handleSaveOrderForCouponSingle(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user,WxCoupon coupon,int perCouponNumber,
boolean isPressOrder,Long orderGroupId,String formId,Integer shippinType,UserBasicInfoAddress address,WxCouponChannel couponChannel,EnumPayWay payWay) {
WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy();
// 是否砍价
WxOrder order = null;
WxCouponChannel couponChannel = orderdto.getWxCouponChannel();
if (checkCouponIsFree(coupon,couponChannel,orderdto.getShippingType())) {
if (checkCouponIsFree(coupon,couponChannel,shippinType)) {
// 免费券
order = proxy.saveFreeOrderForCoupon(orderDate,allowUnPayOrder,composeOrder,user, coupon,perCouponNumber,couponChannel,
orderdto.getSignleOrder().getFormId(),null,payWay,orderdto.getShippingType(),orderdto.getAddress());
formId,null,payWay,shippinType,address);
if (order != null) {
// 6. 下订单完成,发送内部消息
// 下订单完成,发送内部消息
@@ -2830,7 +2880,8 @@ public class WxOrderServiceImpl implements WxOrderService {
}
} else {
// 有价券
order = proxy.saveNoFreeOrderForCoupon(orderDate,allowUnPayOrder,composeOrder,user, orderdto.getWxCoupon(),perCouponNumber,couponChannel,orderdto,payWay);
order = proxy.saveNoFreeOrderForCoupon(orderDate,allowUnPayOrder,composeOrder,user, coupon,perCouponNumber,isPressOrder,
orderGroupId,formId,shippinType,address,couponChannel,payWay);
}
// couponActionLog
// try {
@@ -2936,7 +2987,8 @@ public class WxOrderServiceImpl implements WxOrderService {

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxOrder saveNoFreeOrderForCoupon(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,WxCouponChannel couponChannel,OrderComposeSaveDto orderdto,EnumPayWay payWay) {
public WxOrder saveNoFreeOrderForCoupon(Date orderDate,boolean allowUnPayOrder,WxComposeOrder composeOrder,WxCUserBasicInfo user, WxCoupon coupon,int couponNumber,
boolean isPressOrder,Long orderGroupId,String formId,Integer shippinType,UserBasicInfoAddress address,WxCouponChannel couponChannel,EnumPayWay payWay) {
WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy();
// 3. 减库存操作。所有的订单都跟减库存操作时的订单详情保持一致
@@ -2970,22 +3022,22 @@ public class WxOrderServiceImpl implements WxOrderService {
Long orderNumber;
// 4.1 价格 渠道/券
WxComposeChildOrderPrice price = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType())
.getChildCouponOrderPrice(orderdto,coupon,couponChannel, orderdto.getSignleOrder().isPressOrder(), orderdto.getSignleOrder().getOrderGroupId(), couponNumber);
.getChildCouponOrderPrice(shippinType,coupon,couponChannel, isPressOrder, orderGroupId, couponNumber);
Integer orderStatus = OrderHelper.getOrderStatusWxCoupon(coupon, orderdto.getSignleOrder().getOrderGroupId());
Integer orderStatus = OrderHelper.getOrderStatusWxCoupon(coupon, orderGroupId);

// 4.2 保存订单
WxOrder record = new WxOrder();
record.setType(orderType);
record.setPayVendor(payWay.getCode());
record.setCouponChannelId(orderdto.getSignleOrder().getCouponChannelId());
record.setOrderGroupId(orderdto.getSignleOrder().getOrderGroupId());
record.setFormId(orderdto.getSignleOrder().getFormId());
record.setCouponChannelId(couponChannel.getId());
record.setOrderGroupId(orderGroupId);
record.setFormId(formId);
record.setPayment(price.getRealPayMent());
record.setShippingType(orderdto.getShippingType());
if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(orderdto.getShippingType())){
record.setShippingType(shippinType);
if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(shippinType)){
record.setFreightPrice(coupon.getFreightPrice());
record.setShippingAddress(JSON.toJSONString(orderdto.getAddress()));
record.setShippingAddress(JSON.toJSONString(address));
}

record.setOrderStatus(orderStatus);
@@ -2998,13 +3050,13 @@ public class WxOrderServiceImpl implements WxOrderService {
record.setCouponNumber(couponNumber);
try {
orderNumber = proxy.saveNoFreeOrder(orderDate,record, user, coupon, orderdto.getSignleOrder().isPressOrder());
orderNumber = proxy.saveNoFreeOrder(orderDate,record, user, coupon, isPressOrder);
} catch (Exception e) {
logger.error("保存订单:" + e.getMessage(),e);
throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(),"["+coupon.getTitle()+"]订单保存错误,"+e.getMessage());
}

if (orderdto.getSignleOrder().isPressOrder()) {
if (isPressOrder) {
// 5. 第一次砍价
try {
proxy.firstPress(orderDate,record, user, coupon, orderNumber);
@@ -3315,7 +3367,8 @@ public class WxOrderServiceImpl implements WxOrderService {
for ( int i =0 ; i< composeOrderSaveDto.size(); i++ ) {
OrderComposeSaveDto ocsd = composeOrderSaveDto.get(i);
WxCoupon coupon = singleOrderCheck(ocsd.getSignleOrder(),ocsd.getCount(),wxCUserBasicInfo,payWay,tenantEntity,i+1,singleProduct);
WxCoupon coupon = singleOrderCheck(ocsd.getSignleOrder().getCouponChannelId(),ocsd.getSignleOrder().getOrderGroupId(),ocsd.getCount(),
wxCUserBasicInfo,payWay,tenantEntity,i+1,singleProduct);
ocsd.setWxCoupon(coupon);
}
WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy();
@@ -3338,6 +3391,50 @@ public class WxOrderServiceImpl implements WxOrderService {
}

}
@Override
public ResultData platPushSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<PlatPushOrderSaveDto> platPushOrderList,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity) {
try {
if (null == platPushOrderList || platPushOrderList.size() <= 0 ) {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"无商品信息");
}
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUserId,tenantEntity.getFinalTenantId());
if (wxCUserBasicInfo != null && wxCUserBasicInfo.getStatus().equals(EnumCUserBasicInfoStatus.LOCKED.getCode())) {
logger.info("会员权益被锁定:cUserId:" + cUserId);
return new ResultData(ErrorCode.MEMBER_IS_LOCKED);
}
boolean singleProduct = false;
if (platPushOrderList.size() == 1) {
singleProduct = true;
}
for ( int i =0 ; i< platPushOrderList.size(); i++ ) {
PlatPushOrderSaveDto ocsd = platPushOrderList.get(i);
WxCoupon coupon = singleOrderCheck(ocsd.getCouponChannelId(),ocsd.getOrderGroupId(),ocsd.getCount(),wxCUserBasicInfo,payWay,tenantEntity,i+1,singleProduct);
ocsd.setWxCoupon(coupon);
}
WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy();
try {
WxComposeOrder order = proxy.savePlatPushOrderForCoupon(tenantEntity,allowUnPayOrder,composeOrderType,wxCUserBasicInfo, platPushOrderList, payWay);
return new ResultData(order);
} catch (MallinkException e) {
logger.error("saveOrderForCoupon error.",e);
throw new MallinkException(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error("saveOrderForCoupon error.",e);
throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), e.getMessage());
}
}catch(MallinkException me) {
return new ResultData(me.getErrorCode(),me.getMessage());
}catch(Exception e) {
logger.error("composeSaveOrder error.",e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}

}

@Override
public void sendInsideOrderPushMsg(TenantEntity tenantEntity,Long composeOrderId) {
@@ -3459,26 +3556,25 @@ public class WxOrderServiceImpl implements WxOrderService {
// }
private WxCoupon singleOrderCheck(OrderSaveDto orderSaveDto,int productCount,WxCUserBasicInfo wxCUserBasicInfo,EnumPayWay payWay,TenantEntity tenantEntity,int curindex,boolean singleProduct) {
logger.info("OrderSave: " + orderSaveDto);
private WxCoupon singleOrderCheck(Long couponChannelId,Long orderGroupId,int productCount,WxCUserBasicInfo wxCUserBasicInfo,EnumPayWay payWay,TenantEntity tenantEntity,int curindex,boolean singleProduct) {
String premsg = "";
if (singleProduct) {
premsg = "此券";
}else {
premsg = "第["+curindex+"]张券";
}
if (orderSaveDto.getCouponChannelId() == null) {
if (couponChannelId == null) {
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), premsg+"couponChannelId不能为空");
}
WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(orderSaveDto.getCouponChannelId(),tenantEntity.getTenantId());
WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId,tenantEntity.getTenantId());
if (wxCouponChannel == null) {
logger.error("couponChannelId find error, " + orderSaveDto.getCouponChannelId());
logger.error("couponChannelId find error, " + couponChannelId);
throw new MallinkException(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF.getCode(),premsg+"投放渠道不存在");
}
if (!singleProduct) {
premsg = premsg+"【"+wxCouponChannel.getTitle()+"】";
}
couponChannelCheck(orderSaveDto, wxCouponChannel,premsg);
couponChannelCheck(wxCouponChannel,premsg);

WxCoupon coupon = wxCouponService.getById(wxCouponChannel.getCouponId(),wxCouponChannel.getTenantId());
if (null == coupon) {
@@ -3499,7 +3595,7 @@ public class WxOrderServiceImpl implements WxOrderService {

WxCouponCVo wxCouponCVo = null;

String key = "cc:" + orderSaveDto.getCouponChannelId();
String key = "cc:" + couponChannelId;
ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue();
// 缓存
boolean hasKey = cdRedisTemplate.hasKey(key);
@@ -3508,7 +3604,7 @@ public class WxOrderServiceImpl implements WxOrderService {
wxCouponCVo = operations.get(key);
} else {
// 游戏没有入缓存,需要从数据库中读取
wxCouponCVo = wxCouponChannelService.findDetailVo(orderSaveDto.getCouponChannelId(),wxCouponChannel.getTenantId(),false);
wxCouponCVo = wxCouponChannelService.findDetailVo(couponChannelId,wxCouponChannel.getTenantId(),false);
if (wxCouponCVo != null) {
// 游戏优化,进缓存
cdRedisTemplate.opsForValue().set(key, wxCouponCVo, 3600, TimeUnit.SECONDS);
@@ -3565,7 +3661,7 @@ public class WxOrderServiceImpl implements WxOrderService {

couponUserCheck(wxCUserBasicInfo, wxCouponCVo,premsg);

Long couponId = orderSaveDto.getCouponId() == null ? wxCouponChannel.getCouponId() : orderSaveDto.getCouponId();
Long couponId = wxCouponChannel.getCouponId();
if (couponId == null) {
logger.error("couponChannelId或者couponId不能为空");
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), premsg+"couponChannelId或者couponId不能为空");
@@ -3582,14 +3678,14 @@ public class WxOrderServiceImpl implements WxOrderService {
if (!checkCouponIsFree(coupon,wxCouponChannel,null)) {
// 有价,拼团检查
if (isOrderGroup(orderSaveDto.getOrderGroupId())) {
checkOrderGroup(wxCUserBasicInfo, orderSaveDto.getOrderGroupId(),coupon,premsg);
if (isOrderGroup(orderGroupId)) {
checkOrderGroup(wxCUserBasicInfo, orderGroupId,coupon,premsg);
}
}
return coupon;
}

private void couponChannelCheck(OrderSaveDto orderSaveDto, WxCouponChannel wxCouponChannel,String premsg) {
private void couponChannelCheck(WxCouponChannel wxCouponChannel,String premsg) {
if (wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) {
Date now = new Date();
if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) {


+ 5
- 0
mallinkService/src/main/java/com/iformall/service/order/OrderAdapterService.java Просмотреть файл

@@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List;

import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumPayWay;
@@ -20,6 +21,9 @@ public interface OrderAdapterService {
WxComposeOrder createDBMainOrder(TenantEntity tenantEntity,WxCUserBasicInfo user,int payment,EnumPayWay payWay);
//第三方平台推送过来的订单
WxComposeOrder createDBMainOrderByPushOrder(TenantEntity tenantEntity,WxCUserBasicInfo user,List<PlatPushOrderSaveDto> platPushOrderList,EnumPayWay payWay);
/**
* 获取支付时商品名称,供服务商API使用
* @param lastCoupon
@@ -39,6 +43,7 @@ public interface OrderAdapterService {
* @return
*/
WxComposeChildOrderPrice getChildCouponOrderPrice(OrderComposeSaveDto orderdto,WxCoupon coupon,WxCouponChannel couponChannel,boolean isPress,Long orderGroupId,Integer couponNumber);
WxComposeChildOrderPrice getChildCouponOrderPrice(Integer shippingType,WxCoupon coupon,WxCouponChannel couponChannel,boolean isPress,Long orderGroupId,Integer couponNumber);
/**
* 计算每一个子订单的补贴


+ 8
- 2
mallinkService/src/main/java/com/iformall/service/order/impl/SingleOrderAdapterService.java Просмотреть файл

@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;

import com.iformall.common.IdWorker;
import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.enums.EnumComposeOrder;
import com.iformall.enums.EnumOrderShopingType;
import com.iformall.enums.EnumPayWay;
@@ -51,6 +52,13 @@ public class SingleOrderAdapterService extends BaseBatchOrderAdapterService {
return super.createDBMainOrder(tenantEntity,user, payment, payWay, EnumComposeOrder.SINGLE,null);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
public WxComposeOrder createDBMainOrderByPushOrder(TenantEntity tenantEntity, WxCUserBasicInfo user,
List<PlatPushOrderSaveDto> platPushOrderList, EnumPayWay payWay) {
return super.createDBMainOrderForPushOrders(tenantEntity, user, platPushOrderList, payWay, EnumComposeOrder.SINGLE);
}
@Override
public boolean isOneNumberOneOrder() {
return true;
@@ -88,6 +96,4 @@ public class SingleOrderAdapterService extends BaseBatchOrderAdapterService {
return lastCoupon.getTitle();
}



}

+ 26
- 1
mallinkService/src/main/java/com/iformall/service/order/impl/batch/BaseBatchOrderAdapterService.java Просмотреть файл

@@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.domain.po.WxBatchOrder;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxCoupon;
@@ -60,15 +61,21 @@ public abstract class BaseBatchOrderAdapterService implements OrderAdapterServic

@Override
public WxComposeChildOrderPrice getChildCouponOrderPrice(OrderComposeSaveDto orderdto,WxCoupon coupon,WxCouponChannel couponChannel,boolean isPress,Long orderGroupId,Integer couponNumber) {
return getChildCouponOrderPrice(orderdto.getShippingType(),coupon,couponChannel,isPress,orderGroupId,couponNumber);
}
@Override
public WxComposeChildOrderPrice getChildCouponOrderPrice(Integer shippingType,WxCoupon coupon,WxCouponChannel couponChannel,boolean isPress,Long orderGroupId,Integer couponNumber) {
Integer perPrice = OrderHelper.getCouponPerPayment(coupon,couponChannel, isPress, orderGroupId);
Integer freightPrice = 0;
//在线配送加上运费
if (EnumOrderShopingType.DISTRIBUTION.getCode().equals(orderdto.getShippingType())) {
if (EnumOrderShopingType.DISTRIBUTION.getCode().equals(shippingType)) {
freightPrice = coupon.getFreightPrice();
}
return new WxComposeChildOrderPrice(perPrice, couponNumber, freightPrice, coupon.getId());
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
protected WxComposeOrder createDBMainOrder(TenantEntity tenantEntity,WxCUserBasicInfo user,List<OrderComposeSaveDto> orderSave,EnumPayWay payWay,EnumComposeOrder composeOrderType) {
int payment = 0;
@@ -87,6 +94,24 @@ public abstract class BaseBatchOrderAdapterService implements OrderAdapterServic
return createDBMainOrder(tenantEntity, user, payment, payWay, composeOrderType,couponChannelMap);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
protected WxComposeOrder createDBMainOrderForPushOrders(TenantEntity tenantEntity,WxCUserBasicInfo user,List<PlatPushOrderSaveDto> platPushOrderList,EnumPayWay payWay,EnumComposeOrder composeOrderType) {
int payment = 0;
Map<Long,WxCouponChannel> couponChannelMap = new HashMap<Long,WxCouponChannel>();
for (PlatPushOrderSaveDto ocsd : platPushOrderList) {
WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(ocsd.getCouponChannelId(),tenantEntity.getTenantId());
if (null == wxCouponChannel) {
throw new MallinkException(ErrorCode.MSG_INSIDE_ERROR.getCode(),"渠道不存在:"+ocsd.getCouponChannelId());
}
boolean isPress = ocsd.isPress();
WxComposeChildOrderPrice price = getChildCouponOrderPrice(ocsd.getShippingType(),ocsd.getWxCoupon(),wxCouponChannel, isPress, ocsd.getOrderGroupId(), ocsd.getCount());
payment = payment+price.getRealPayMent();
couponChannelMap.put(wxCouponChannel.getId(), wxCouponChannel);
}
return createDBMainOrder(tenantEntity, user, payment, payWay, composeOrderType,couponChannelMap);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
protected WxComposeOrder createDBMainOrder(TenantEntity tenantEntity,WxCUserBasicInfo user,int payment,EnumPayWay payWay,EnumComposeOrder composeOrderType,Map<Long,WxCouponChannel> couponChannelMap) {
//判断是否poi订单


+ 8
- 2
mallinkService/src/main/java/com/iformall/service/order/impl/batch/CouponPackageOrderAdapterService.java Просмотреть файл

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.service.order.entity.WxComposeOrder;
/**
* 券包批量下单
@@ -40,6 +41,13 @@ public class CouponPackageOrderAdapterService extends BaseBatchOrderAdapterServi
EnumPayWay payWay) {
return super.createDBMainOrder(tenantEntity, user, payment, payWay, EnumComposeOrder.PACKAGECOUPON,null);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
public WxComposeOrder createDBMainOrderByPushOrder(TenantEntity tenantEntity, WxCUserBasicInfo user,
List<PlatPushOrderSaveDto> platPushOrderList, EnumPayWay payWay) {
return super.createDBMainOrderForPushOrders(tenantEntity, user, platPushOrderList, payWay, EnumComposeOrder.PACKAGECOUPON);
}

@Override
public WxComposeOrder getComposeOrder(Long mainOrderId, String tenantId) {
@@ -73,6 +81,4 @@ public class CouponPackageOrderAdapterService extends BaseBatchOrderAdapterServi
return "[券包]"+lastCoupon.getTitle();
}



}

+ 9
- 1
mallinkService/src/main/java/com/iformall/service/order/impl/batch/MulityNumberOneOrderBatchOrderAdapterService.java Просмотреть файл

@@ -11,6 +11,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.enums.EnumComposeOrder;
import com.iformall.enums.EnumPayWay;
import com.iformall.service.order.entity.WxComposeOrder;
@@ -42,6 +43,14 @@ public class MulityNumberOneOrderBatchOrderAdapterService extends BaseBatchOrder
return super.createDBMainOrder(tenantEntity,user, payment, payWay, EnumComposeOrder.MULITY_NUMBER_ORDER_BATCH,null);
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
public WxComposeOrder createDBMainOrderByPushOrder(TenantEntity tenantEntity, WxCUserBasicInfo user,
List<PlatPushOrderSaveDto> platPushOrderList, EnumPayWay payWay) {
return super.createDBMainOrderForPushOrders(tenantEntity, user, platPushOrderList, payWay, EnumComposeOrder.MULITY_NUMBER_ORDER_BATCH);
}
@Override
public WxComposeOrder getComposeOrder(Long mainOrderId, String tenantId) {
return super.getComposeOrder(mainOrderId, tenantId, EnumComposeOrder.MULITY_NUMBER_ORDER_BATCH);
@@ -61,6 +70,5 @@ public class MulityNumberOneOrderBatchOrderAdapterService extends BaseBatchOrder
return "批量支付商品";
}


}

+ 10
- 0
mallinkService/src/main/java/com/iformall/service/order/impl/batch/OneNumberOneOrderBatchOrderAdapterService.java Просмотреть файл

@@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.iformall.domain.dto.OrderComposeSaveDto;
import com.iformall.domain.dto.PlatPushOrderSaveDto;
import com.iformall.enums.EnumComposeOrder;
import com.iformall.enums.EnumPayWay;
import com.iformall.service.order.entity.WxComposeOrder;
@@ -40,6 +41,13 @@ public class OneNumberOneOrderBatchOrderAdapterService extends BaseBatchOrderAda
EnumPayWay payWay) {
return super.createDBMainOrder(tenantEntity,user, payment, payWay, EnumComposeOrder.ONE_NUMBER_ORDER_BATCH,null);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
public WxComposeOrder createDBMainOrderByPushOrder(TenantEntity tenantEntity, WxCUserBasicInfo user,
List<PlatPushOrderSaveDto> platPushOrderList, EnumPayWay payWay) {
return super.createDBMainOrderForPushOrders(tenantEntity, user, platPushOrderList, payWay, EnumComposeOrder.ONE_NUMBER_ORDER_BATCH);
}

@Override
public WxComposeOrder getComposeOrder(Long mainOrderId, String tenantId) {
@@ -62,5 +70,7 @@ public class OneNumberOneOrderBatchOrderAdapterService extends BaseBatchOrderAda
}




}

Загрузка…
Отмена
Сохранить