|
@@ -5,18 +5,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
|
|
|
import com.ym.mec.biz.dal.dto.PageInfoOrder;
|
|
|
import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
|
|
|
-import com.ym.mec.biz.service.MusicGroupCalenderRefundPeriodService;
|
|
|
-import com.ym.mec.biz.service.SellOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
|
|
|
-import com.ym.mec.common.api.CommonResult;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
-import com.ym.mec.common.dto.OrderCreate;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
@@ -24,7 +20,6 @@ import com.ym.mec.common.page.QueryInfo;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
-import com.ym.mec.mall.MallFeignService;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.excel.POIUtil;
|
|
@@ -54,6 +49,8 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
@Resource
|
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
@Resource
|
|
|
+ private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
|
|
|
+ @Resource
|
|
|
private IdGeneratorService idGeneratorService;
|
|
|
@Resource
|
|
|
private SellOrderDao sellOrderDao;
|
|
@@ -71,8 +68,6 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
|
|
|
@Resource
|
|
|
private MusicGroupCalenderRefundPeriodService musicGroupCalenderRefundPeriodService;
|
|
|
- @Resource
|
|
|
- private MallFeignService mallFeignService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentPaymentRouteOrder> getDAO() {
|
|
@@ -231,57 +226,19 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
|
|
|
|
|
|
studentPaymentRouteOrderDao.insertOrder(studentPaymentOrder);
|
|
|
|
|
|
- if (StringUtils.isNoneBlank(studentPaymentRouteOrder.getGoodsJson())) {
|
|
|
- BigDecimal goodsTotalPrice = BigDecimal.ZERO;
|
|
|
|
|
|
- List<Integer> goodsIdList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNoneBlank(studentPaymentRouteOrder.getGoodsJson())) {
|
|
|
JSONObject jsonObj = JSON.parseObject(studentPaymentRouteOrder.getGoodsJson());
|
|
|
+ List<GoodsSellDto> goodsSellDtos = new ArrayList<>();
|
|
|
for (Entry<String, Object> goodsMap : jsonObj.entrySet()) {
|
|
|
- Integer goodsId = Integer.parseInt(goodsMap.getKey());
|
|
|
- Integer nums = Integer.parseInt(goodsMap.getValue().toString());
|
|
|
- Goods goods = goodsDao.get(goodsId);
|
|
|
- goodsTotalPrice = goodsTotalPrice.add(goods.getGroupPurchasePrice().multiply(new BigDecimal(nums)));
|
|
|
- for (int i = 0; i < nums; i++) {
|
|
|
- goodsIdList.add(goodsId);
|
|
|
- }
|
|
|
- }
|
|
|
- List<SellOrder> sellOrders = sellOrderService.initSellOrder(studentPaymentOrder, null, goodsIdList, null, false);
|
|
|
- sellOrderService.batchInsert(sellOrders);
|
|
|
- if(calender == null || calender.getPaymentType() != MusicGroupPaymentCalender.PaymentType.GOODS_PURCHASE){
|
|
|
- OrderCreate mallOrder = new OrderCreate();
|
|
|
- mallOrder.setOrchestraId(studentPaymentOrder.getMusicGroupId());
|
|
|
- mallOrder.setStatus(1);
|
|
|
- mallOrder.setOrderNo(studentPaymentRouteOrder.getOrderNo());
|
|
|
- mallOrder.setTotalAmount(studentPaymentOrder.getExpectAmount());
|
|
|
- String paymentBusinessChannel = studentPaymentOrder.getPaymentBusinessChannel();
|
|
|
- if (StringUtils.endsWithIgnoreCase(paymentBusinessChannel, "wx_pub") ||
|
|
|
- StringUtils.endsWithIgnoreCase(paymentBusinessChannel, "WECHAT") ||
|
|
|
- StringUtils.endsWithIgnoreCase(paymentBusinessChannel, "WXPay")) {
|
|
|
- mallOrder.setPayType(2);
|
|
|
- } else {
|
|
|
- mallOrder.setPayType(1);
|
|
|
- }
|
|
|
- if (studentPaymentRouteOrder.getType() == OrderTypeEnum.SCHOOL){
|
|
|
- mallOrder.setMemberId(studentPaymentRouteOrder.getSchoolId().longValue());
|
|
|
- mallOrder.setPlatformType("SCHOOL");
|
|
|
- mallOrder.setSourceType(2);
|
|
|
- }else {
|
|
|
- mallOrder.setMemberId(studentPaymentOrder.getUserId().longValue());
|
|
|
- mallOrder.setPlatformType("STUDENT");
|
|
|
- mallOrder.setSourceType(3);
|
|
|
- }
|
|
|
- if(studentPaymentRouteOrder.getType() == OrderTypeEnum.OTHER){
|
|
|
- mallOrder.setSourceType(4);
|
|
|
- }
|
|
|
- List<OrderCreate.OrderItem> items = sellOrderService.convertMallOrder(sellOrders);
|
|
|
- mallOrder.setOrderItemList(items);
|
|
|
- CommonResult<Boolean> result = mallFeignService.productOrderCreate(mallOrder);
|
|
|
- if (result.getCode() != 200) {
|
|
|
- throw new BizException("同步商城订单失败: {}",result.getMessage());
|
|
|
- }
|
|
|
+ GoodsSellDto goodsSellDto = new GoodsSellDto();
|
|
|
+ goodsSellDto.setGoodsId(Integer.parseInt(goodsMap.getKey()));
|
|
|
+ goodsSellDto.setGoodsNum(Integer.parseInt(goodsMap.getValue().toString()));
|
|
|
+ goodsSellDtos.add(goodsSellDto);
|
|
|
}
|
|
|
+ List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.initStudentPaymentOrderDetail(studentPaymentOrder, goodsSellDtos);
|
|
|
+ sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, studentPaymentOrder.getMusicGroupId());
|
|
|
}
|
|
|
-
|
|
|
if (studentPaymentRouteOrder.getCalenderId() == null) {
|
|
|
return true;
|
|
|
}
|