Browse Source

Merge branch 'zx_saas_goods' into test

刘俊驰 1 year ago
parent
commit
0897436aac
17 changed files with 225 additions and 125 deletions
  1. 30 1
      mec-application/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java
  2. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderAddress.java
  3. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java
  4. 4 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  5. 10 18
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  6. 4 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java
  7. 0 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java
  8. 103 90
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  9. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  10. 3 0
      mec-common/common-core/src/main/java/com/ym/mec/common/dto/OrderCreate.java
  11. 11 0
      mec-common/common-core/src/main/java/com/ym/mec/common/entity/OrderCancelModel.java
  12. 3 0
      mec-common/common-core/src/main/java/com/ym/mec/common/entity/OrderSkuSync.java
  13. 3 0
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dto/OrderCreate.java
  14. 12 0
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderServiceImpl.java
  15. 3 2
      mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java
  16. 4 3
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java
  17. 9 5
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayPaymentService.java

+ 30 - 1
mec-application/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -1,6 +1,9 @@
 package com.ym.mec.web.controller.education;
 
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
@@ -12,21 +15,26 @@ import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.dto.BrandDto;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.mall.MallFeignService;
 import com.ym.mec.util.date.DateUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang.math.NumberUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.web:}/eduRepair")
 @Api(tags = "教务维修服务")
@@ -53,6 +61,8 @@ public class EduRepairController extends BaseController {
     private StudentInstrumentService studentInstrumentService;
     @Autowired
     private StudentInstrumentDao studentInstrumentDao;
+    @Resource
+    private MallFeignService mallFeignService;
 
     @ApiOperation("获取学生列表")
     @GetMapping(value = "/getStudents")
@@ -113,7 +123,26 @@ public class EduRepairController extends BaseController {
     public HttpResponseResult getStudentRepairList(RepairStudentQueryInfo queryInfo) {
         queryInfo.setEmployeeId(sysUserService.getUserId());
         queryInfo.setPayStatus(2);
-        return succeed(studentRepairService.queryPage(queryInfo));
+        PageInfo<StudentRepair> repairPageInfo = studentRepairService.queryPage(queryInfo);
+        List<StudentRepair> rows = repairPageInfo.getRows();
+        if (!rows.isEmpty()) {
+            Map<Long, String> brandIdNameMap = mallFeignService.getList().stream().collect(Collectors.toMap(BrandDto::getId, BrandDto::getName));
+            rows.forEach(row -> {
+                String goodsJson = row.getGoodsJson();
+                if (StringUtils.isNotEmpty(goodsJson)) {
+                    JSONArray goods = JSON.parseArray(goodsJson);
+                    for (Object good : goods) {
+                        JSONObject goodObject = (JSONObject) good;
+                        String brand = goodObject.getString("brand");
+                        if (Objects.nonNull(brand) && NumberUtils.isNumber(brand)) {
+                            goodObject.put("brandName", brandIdNameMap.getOrDefault(Long.valueOf(brand), ""));
+                        }
+                    }
+                    row.setGoodsJson(JSON.toJSONString(goods));
+                }
+            });
+        }
+        return succeed(repairPageInfo);
     }
 
     @ApiOperation("获取乐器种类")

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderAddress.java

@@ -58,6 +58,10 @@ public class MusicGroupPaymentCalenderAddress implements Serializable {
     @ApiModelProperty(value = "详细地址")
     private String address;
 
+    @TableField("delivery_detail_")
+    @ApiModelProperty(value = "商品发货明细,用于同步订单的发货信息")
+    private String deliveryDetail;
+
     @TableField("create_time_")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -139,4 +140,7 @@ public class StudentPaymentOrder extends BaseEntity {
 	private Long calenderId;
 
 	private Integer cooperationId;
+
+	// 需要关闭的订单号
+	private List<String> closeOrderNoList;
 }

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -29,6 +29,7 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.WrapperUtil;
 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.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
@@ -491,7 +492,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         Organization organization = organizationDao.get(musicGroup.getOrganId());
         sendSeoMessageSource.sendSeoMessage(musicGroup.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER},
                 null, null, MessageTypeEnum.BACKSTAGE_PAYMENT_CALENDER_AUDIT, organization.getName(), musicGroup.getName());
-        
+        TenantContextHolder.setTenantId(organization.getTenantId());
         if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT && musicGroupPaymentCalender.getStatus() != AUDITING ){
             addStudent(musicGroupPaymentCalender, musicGroup);
             //将0元未缴费学员缴费状态更新为已缴费
@@ -513,6 +514,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         }
         ModelMap map = new ModelMap(1);
         map.put("musicGroupPaymentCalenderBatchNo", batchNo);
+        TenantContextHolder.clearTenantId();
         return BaseController.succeed(map);
     }
 
@@ -1003,7 +1005,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         Date date = new Date();
         for (String batchNo : split) {
             List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
-            if (musicGroupPaymentCalenders == null || musicGroupPaymentCalenders.size() == 0) {
+            if (CollectionUtils.isEmpty(musicGroupPaymentCalenders)) {
                 throw new BizException("缴费项目不存在");
             }
             MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);

+ 10 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -288,23 +288,14 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         }
         //获取总金额
         BigDecimal detailTotalPrice = goodsOrderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-        BigDecimal balancePaymentAmount = studentPaymentOrder.getBalancePaymentAmount();
-        if (balancePaymentAmount.compareTo(BigDecimal.ZERO) > 0) {
-            BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
-            BigDecimal organShareProfit = orderDetails.stream().filter(o -> o.getType() == ORGAN_SHARE_PROFIT).map(StudentPaymentOrderDetail::getPrice)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add);
-            if(organShareProfit != null){
-                expectAmount = expectAmount.subtract(organShareProfit);
-            }
-            //获取比例
-            BigDecimal ratioAmount = BigDecimal.ZERO;
-            if(expectAmount.compareTo(BigDecimal.ZERO) > 0){
-                ratioAmount = balancePaymentAmount.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
-            }
-            //获取分配的减免金额
-            balancePaymentAmount = balancePaymentAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+        //获取比例
+        BigDecimal totalRatioAmount = BigDecimal.ZERO;
+        if(studentPaymentOrder.getExpectAmount().compareTo(BigDecimal.ZERO) > 0){
+            totalRatioAmount = detailTotalPrice.divide(studentPaymentOrder.getExpectAmount(), 6, BigDecimal.ROUND_HALF_UP);
         }
-        //获取总减免金额
+        //获取分配的余额
+        BigDecimal balancePaymentAmount = studentPaymentOrder.getBalancePaymentAmount().multiply(totalRatioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+        //获取总优惠券金额
         BigDecimal detailTotalRemitPrice = goodsOrderDetails.stream().map(StudentPaymentOrderDetail::getRemitFee).reduce(BigDecimal.ZERO, BigDecimal::add);
 
         List<SellOrder> sellOrders = new ArrayList<>();
@@ -497,7 +488,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    @Transactional(rollbackFor = Exception.class)
     public List<SellOrder> refund(List<SellOrder> sellOrders, Boolean reBackFee) {
         Date nowDate = new Date();
         for (SellOrder sellOrder : sellOrders) {
@@ -646,7 +637,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         mallOrder.setSourceType(1);
 
         // 乐团学生报名默认收货地址
-        if (studentPaymentOrder.getType() == OrderTypeEnum.APPLY && StringUtils.isNotBlank(mallOrder.getOrchestraId())) {
+        if ((studentPaymentOrder.getType() == OrderTypeEnum.APPLY || studentPaymentOrder.getType() == OrderTypeEnum.SUBJECT_CHANGE)
+            && StringUtils.isNotBlank(mallOrder.getOrchestraId())) {
 
             // 查询乐团默认收货地址
             MusicGroupShippingAddressQueryInfo queryInfo = new MusicGroupShippingAddressQueryInfo();

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -3,7 +3,10 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dao.GoodsDao;
+import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.dao.SysCouponCodeDao;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
@@ -33,8 +36,6 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
     @Autowired
     private StudentGoodsSellDao studentGoodsSellDao;
     @Autowired
-    private SysConfigDao sysConfigDao;
-    @Autowired
     private SysTenantConfigService sysTenantConfigService;
     @Autowired
     private TenantInfoService tenantInfoService;

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -689,7 +689,6 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
         //销售订单详情
         if (allDetails.size() > 0 && (detailTypeEnums.contains(MUSICAL) || detailTypeEnums.contains(ACCESSORIES) || detailTypeEnums.contains(TEACHING))) {
             sellOrderService.addOrderDetail2SellOrder(allDetails, studentPaymentOrder, musicGroup.getId());
-
         }
 
         //活动小课包处理

+ 103 - 90
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -19,8 +19,10 @@ import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.entity.OrderSkuSync;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -56,21 +58,6 @@ import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
-import com.ym.mec.biz.dal.entity.ActivityUserMapper;
-import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.GoodsProcurement;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.SellOrder;
-import com.ym.mec.biz.dal.entity.StudentGoodsSell;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
-import com.ym.mec.biz.dal.entity.VipGroupActivity;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
@@ -115,92 +102,101 @@ import com.ym.mec.thirdparty.yqpay.YqPayUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 
+import javax.annotation.Resource;
+
 @Service
 public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrder> implements StudentPaymentOrderService {
 
-    @Autowired
+    @Resource
     private StudentPaymentOrderDao studentPaymentOrderDao;
-    @Autowired
+    @Resource
     private YqPayFeignService yqPayFeignService;
-    @Autowired
+    @Resource
     private StudentRegistrationService studentRegistrationService;
-    @Autowired
+    @Resource
     @Lazy
     private VipGroupService vipGroupService;
-    @Autowired
+    @Resource
     private MusicGroupService musicGroupService;
-    @Autowired
+    @Resource
     private SporadicChargeInfoService sporadicChargeInfoService;
-    @Autowired
+    @Resource
     private PracticeGroupService practiceGroupService;
-    @Autowired
+    @Resource
     private SysUserCashAccountDao sysUserCashAccountDao;
-    @Autowired
+    @Resource
     private StudentRepairService studentRepairService;
-    @Autowired
+    @Resource
     private SysUserCashAccountService sysUserCashAccountService;
-    @Autowired
+    @Resource
     private SubjectChangeService subjectChangeService;
-    @Autowired
+    @Resource
     private DegreeRegistrationService degreeRegistrationService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    @Autowired
+    @Resource
     private IdGeneratorService idGeneratorService;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private GoodsDao goodsDao;
-    @Autowired
+    @Resource
     private GoodsService goodsService;
-    @Autowired
+    @Resource
     private StudentInstrumentService studentInstrumentService;
-    @Autowired
+    @Resource
     private ReplacementInstrumentActivityService replacementInstrumentActivityService;
-    @Autowired
+    @Resource
     private ChildrenDayReserveService childrenDayReserveService;
-    @Autowired
+    @Resource
     private MemberRankSettingService memberRankSettingService;
-    @Autowired
+    @Resource
     private PayService payService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
-    @Autowired
+    @Resource
     private CloudTeacherOrderService cloudTeacherOrderService;
-    @Autowired
+    @Resource
     private SysCouponCodeService sysCouponCodeService;
-    @Autowired
+    @Resource
     private VipGroupActivityService vipGroupActivityService;
-    @Autowired
+    @Resource
     private ActivityUserMapperService activityUserMapperService;
-    @Autowired
+    @Resource
     private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
-    @Autowired
+    @Resource
     private TenantConfigService tenantConfigService;
-    @Autowired
+    @Resource
     private GoodsProcurementDao goodsProcurementDao;
-    @Autowired
+    @Resource
     private SysPaymentConfigService sysPaymentConfigService;
-    @Autowired
+    @Resource
     private SellOrderDao sellOrderDao;
     @Lazy
-    @Autowired
+    @Resource
     private ContractService contractService;
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
-    @Autowired
+    @Resource
     private StudentDao studentDao;
-    @Autowired
+    @Resource
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
-    
-    @Autowired
+    @Resource
     private YeepayPaymentService yeepayPaymentService;
-    @Autowired
+    @Resource
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Resource
+    private MusicGroupPaymentCalenderAddressService musicGroupPaymentCalenderAddressService;
+    @Resource
+    private StudentRepairDao studentRepairDao;
+    @Resource
+    private MusicGroupDao musicGroupDao;
+    @Resource
+    private StudentGoodsSellDao studentGoodsSellDao;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     @Override
@@ -485,11 +481,11 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void updateOrder(Map<String, String> rpMap) throws Exception {
-        DealStatusEnum status = "1".equals(rpMap.get("tradeState")) ? DealStatusEnum.SUCCESS : DealStatusEnum.FAILED;
+        DealStatusEnum status = "1".equals(rpMap.get("tradeState")) ? SUCCESS : DealStatusEnum.FAILED;
         StudentPaymentOrder order = findOrderByOrderNo(rpMap.get("merOrderNo"));
         //关闭或失败的订单查询订单成功,订单改成成功,钱退到余额
-        if (order != null && (order.getStatus().equals(DealStatusEnum.CLOSE) || order.getStatus().equals(DealStatusEnum.FAILED)) && status.equals(DealStatusEnum.SUCCESS)) {
-            String memo = order.getStatus().equals(DealStatusEnum.CLOSE) ? "关闭订单" : "失败订单";
+        if (order != null && (order.getStatus().equals(CLOSE) || order.getStatus().equals(DealStatusEnum.FAILED)) && status.equals(SUCCESS)) {
+            String memo = order.getStatus().equals(CLOSE) ? "关闭订单" : "失败订单";
             memo = memo + ",实际支付成功,退到用户余额";
             //更新订单状态
             order.setStatus(status);
@@ -516,7 +512,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             return;
         }
 
-        if (status.equals(DealStatusEnum.SUCCESS)) {
+        if (status.equals(SUCCESS)) {
             order.setPayTime(new Date());
         } else {
             order.setMemo(rpMap.get("remarks"));
@@ -534,7 +530,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
         callOrderCallBack(order);
 
-        if (status.equals(DealStatusEnum.SUCCESS)
+        if (status.equals(SUCCESS)
                 && StringUtils.isNotBlank(order.getPaymentChannel())
                 && (order.getPaymentChannel().equals(PaymentChannelEnum.ADAPAY.getCode()) || order.getPaymentChannel().equals(PaymentChannelEnum.YEEPAY.getCode()))
                 && !rpMap.containsKey("simulation")) {
@@ -897,7 +893,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         List<StudentPaymentOrderExportDto> orders = studentPaymentOrderDao.getUserApplyOrders(studentId, musicGroupId);
         StudentRegistration studentRegister = studentRegistrationService.getStudentRegister(musicGroupId, studentId);
         for (StudentPaymentOrderExportDto order : orders) {
-            if ((DealStatusEnum.ING.equals(order.getStatus()) || DealStatusEnum.SUCCESS.equals(order.getStatus())) &&
+            if ((DealStatusEnum.ING.equals(order.getStatus()) || SUCCESS.equals(order.getStatus())) &&
                     studentRegister.getPayingStatus().equals(2)) {
                 order.setPayingStatus(2);
             }
@@ -1142,7 +1138,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             return BaseController.failed(HttpStatus.CONTINUE, "您有支付中的订单,是否继续支付");
         }
         //处理关闭订单
-        order.setStatus(DealStatusEnum.CLOSE);
+        order.setStatus(CLOSE);
         order.setMemo("关闭订单");
 
         
@@ -1215,7 +1211,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             StudentRegistration studentRegistration = studentRegistrationService.getStudentRegister(musicGroupId, userId);
             //获取学员在乐团的状态,如果是在读,那么不处理人数
             if (studentRegistration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.APPLY) {
-                List<StudentPaymentOrder> oldStudentPaymentOrderList = this.queryByCondition(GroupType.MUSIC, musicGroupId, userId, DealStatusEnum.SUCCESS, OrderTypeEnum.APPLY);
+                List<StudentPaymentOrder> oldStudentPaymentOrderList = this.queryByCondition(GroupType.MUSIC, musicGroupId, userId, SUCCESS, OrderTypeEnum.APPLY);
                 //判断是否有成功的订单,如果有,表示已经处理过人数
                 if (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0) {
                     List<StudentPaymentOrderDetail> orderDetail = studentPaymentOrderDetailService.getOrderDetail(order.getId());
@@ -1305,14 +1301,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         return studentPaymentOrderDao.getMemberIngOrder(member, status);
     }
 
-    @Autowired
-    private StudentRepairDao studentRepairDao;
-    @Autowired
-    private MusicGroupDao musicGroupDao;
-
-    @Autowired
-    private StudentGoodsSellDao studentGoodsSellDao;
-
     @Override
     @Transactional
     public Map createOrder(MallCreateOrderModel model) throws Exception {
@@ -1382,7 +1370,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         if (studentPaymentOrder.getActualAmount().compareTo(BigDecimal.ZERO) == 0) {
-            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+            studentPaymentOrder.setStatus(SUCCESS);
         }
         studentPaymentOrder.setGroupType(GroupType.MALL_SELL);
         studentPaymentOrder.setUserId(model.getUserId());
@@ -1503,7 +1491,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         Map<Integer, String> map = new HashMap<>();
         map.put(userId, userId.toString());
 
-        if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
+        if (studentPaymentOrder.getStatus() == SUCCESS) {
             try {
                 contractService.transferProduceContract(userId, null, studentPaymentOrder.getType());
             } catch (Exception e) {
@@ -1627,7 +1615,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             rechargeDetail.setAmount(amount);
             rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
             rechargeDetail.setComment("缴费前充值");
-            rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
+            rechargeDetail.setStatus(SUCCESS);
             rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
             rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
             rechargeDetail.setUserId(userId);
@@ -1642,12 +1630,12 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             paymentDetail.setAmount(amount.negate());
             paymentDetail.setBalance(cashAccount.getBalance());
             paymentDetail.setComment("商品销售");
-            paymentDetail.setStatus(DealStatusEnum.SUCCESS);
+            paymentDetail.setStatus(SUCCESS);
             paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
             paymentDetail.setType(PlatformCashAccountDetailTypeEnum.GOODS_SELL);
             paymentDetail.setUserId(userId);
             sysUserCashAccountDetailService.insert(paymentDetail);
-        } else if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
+        } else if (studentPaymentOrder.getStatus() == CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
 
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                 sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "商城购买支付失败");
@@ -1795,6 +1783,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Transactional
     public OrderCancelModel cancelOrder(StudentPaymentOrder order, String reason) {
         OrderCancelModel model = new OrderCancelModel();
+        model.setSuccess(true);
         try {
             HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
             if(hfMerchantConfig == null){
@@ -1831,22 +1820,28 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 model.setStatus(false);
                 order.setStatus(CLOSE);
                 order.setMemo(reason);
-            } else {
+            } else if (status.equals("pending")){
                 // 执行关单操作
+                Map<String, String> closeInfo = new HashMap<>();
                 if(StringUtils.equals(order.getPaymentChannel(), PaymentChannelEnum.ADAPAY.getCode())) {
-                    Payment.closeWithKey(order.getTransNo(),"", hfMerchantConfig.getMerKey());
+                    closeInfo = Payment.closeWithKey(order.getTransNo(), "", hfMerchantConfig.getMerKey());
                 }else if(StringUtils.equals(order.getPaymentChannel(), PaymentChannelEnum.YEEPAY.getCode())) {
-                    yeepayPaymentService.close(hfMerchantConfig, order.getTransNo(),"", order.getOrderNo());
+                    closeInfo = yeepayPaymentService.close(hfMerchantConfig, order.getTransNo(), "", order.getOrderNo());
                 }
+                boolean success = "success".equals(closeInfo.get("status"));
                 model.setStatus(false);
                 order.setStatus(CLOSE);
+                model.setSuccess(success);
+                model.setMessage(closeInfo.get("msg"));
+            }
+            if (model.getSuccess()) {
+                TenantContextHolder.setTenantId(order.getTenantId());
+                callOrderCallBack(order);
+                TenantContextHolder.clearTenantId();
             }
-            TenantContextHolder.setTenantId(order.getTenantId());
-            callOrderCallBack(order);
-            TenantContextHolder.clearTenantId();
-            model.setSuccess(true);
-        } catch (Exception e) {
+        }catch (Exception e) {
             model.setSuccess(false);
+            model.setMessage(e.getMessage());
             logger.error("订单[{}]取消失败", order.getTransNo(), e);
         }
         return model;
@@ -2218,9 +2213,27 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             return;
         }
         List<String> orderNos = orderSkuSyncs.stream().map(e -> e.getOrderNo()).collect(Collectors.toList());
+        Map<String, List<OrderSkuSync.SkuSync>> skuMap = orderSkuSyncs.stream().collect(Collectors.toMap(OrderSkuSync::getOrderNo, OrderSkuSync::getSkuSyncList));
         List<SellOrder> sellOrders = sellOrderDao.queryByOrganNos(orderNos);
+        //检查学校商品采购订单
+        List<MusicGroupPaymentCalenderAddress> calenderAddresses = musicGroupPaymentCalenderAddressService.lambdaQuery().
+                in(MusicGroupPaymentCalenderAddress::getOrderNo, orderNos).
+                eq(MusicGroupPaymentCalenderAddress::getDeliveryFlag, false).list();
+        if (CollectionUtils.isNotEmpty(calenderAddresses)) {
+            Map<String, MusicGroupPaymentCalenderAddress> addressMap = calenderAddresses.stream().
+                    collect(Collectors.toMap(MusicGroupPaymentCalenderAddress::getOrderNo, e -> e));
+            List<String> addressOrders = calenderAddresses.stream().map(MusicGroupPaymentCalenderAddress::getOrderNo).collect(Collectors.toList());
+            for (String addressOrder : addressOrders) {
+                MusicGroupPaymentCalenderAddress address = addressMap.get(addressOrder);
+                address.setDeliveryDetail(JSON.toJSONString(skuMap.get(addressOrder)));
+                address.setDeliveryFlag(true);
+            }
+            musicGroupPaymentCalenderAddressService.updateBatchById(calenderAddresses);
+            //如果有审核通过的外部订单,更新对应的商品信息
+
+        }
         if (CollectionUtils.isEmpty(sellOrders)) {
-            throw new BizException("订单不存在");
+            return;
         }
         sellOrders = sellOrders.stream().filter(e -> e.getDeliveryTime() == null).collect(Collectors.toList());
         if(CollectionUtils.isEmpty(sellOrders)){
@@ -2234,10 +2247,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 continue;
             }
             //获取sku平均成本价
-            Map<Long,List<OrderSkuSync.SkuSync>> skuMap = orderSkuSync.getSkuSyncList().stream().collect(Collectors.groupingBy(OrderSkuSync.SkuSync::getSku));
-            Map<Long,BigDecimal> costMap = new HashMap<>(skuMap.keySet().size());
-            for (Long skuId : skuMap.keySet()) {
-                List<OrderSkuSync.SkuSync> skuSyncs = skuMap.get(skuId);
+            Map<Long,List<OrderSkuSync.SkuSync>> skuDetailMap = orderSkuSync.getSkuSyncList().stream().collect(Collectors.groupingBy(OrderSkuSync.SkuSync::getSku));
+            Map<Long,BigDecimal> costMap = new HashMap<>(skuDetailMap.keySet().size());
+            for (Long skuId : skuDetailMap.keySet()) {
+                List<OrderSkuSync.SkuSync> skuSyncs = skuDetailMap.get(skuId);
                 //汇总成本价
                 BigDecimal costPrice = skuSyncs.stream().map(e -> e.getPrice().multiply(new BigDecimal(e.getCount()))).reduce(BigDecimal.ZERO, BigDecimal::add);
                 //获取总数

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -14,7 +14,10 @@ import java.util.stream.Collectors;
 
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.*;
+import com.ym.mec.common.dto.BrandDto;
+import com.ym.mec.mall.MallFeignService;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.math.NumberUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -115,6 +118,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     private SysCouponCodeService sysCouponCodeService;
     @Autowired
     private TeacherService teacherService;
+    @Autowired
+    private MallFeignService mallFeignService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -886,6 +891,19 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             List<Integer> collect = Arrays.stream(couponIds.split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
             repairInfo.setCouponCodeDtos(sysCouponCodeService.findByIdList(collect));
         }
+        String goodsJson = repairInfo.getGoodsJson();
+        if (StringUtils.isNotEmpty(goodsJson)) {
+            JSONArray goods = JSON.parseArray(repairInfo.getGoodsJson());
+            Map<Long, String> brandIdNameMap = mallFeignService.getList().stream().collect(Collectors.toMap(BrandDto::getId, BrandDto::getName));
+            for (Object good : goods) {
+                JSONObject goodObject = (JSONObject) good;
+                String brand = goodObject.getString("brand");
+                if (Objects.nonNull(brand) && NumberUtils.isNumber(brand)) {
+                    goodObject.put("brandName", brandIdNameMap.getOrDefault(Long.valueOf(brand), ""));
+                }
+            }
+            repairInfo.setGoodsJson(JSON.toJSONString(goods));
+        }
         return repairInfo;
     }
 

+ 3 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/dto/OrderCreate.java

@@ -68,6 +68,9 @@ public class OrderCreate {
 
 //    @ApiModelProperty(value = "订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
     private Integer status;
+
+    // 需要关闭的订单号
+    private List<String> closeOrderNoList;
     @Data
     public static class OrderItem implements Serializable {
 

+ 11 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/OrderCancelModel.java

@@ -17,6 +17,17 @@ public class OrderCancelModel {
     // 调用状态  true:成功  false 失败
     private Boolean success;
 
+    private String message;
+
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
     public String getPayChannel() {
         return payChannel;
     }

+ 3 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/OrderSkuSync.java

@@ -33,5 +33,8 @@ public class OrderSkuSync {
 
         // 批次号
         private Long recordId;
+
+        // 内部库存 INTERNAL, 税务库存 TAX
+        private String type;
     }
 }

+ 3 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/dto/OrderCreate.java

@@ -68,6 +68,9 @@ public class OrderCreate {
     @ApiModelProperty("商品详情")
     private List<OrderItem> orderItemList;
 
+    // 需要关闭的订单号
+    private List<String> closeOrderNoList;
+
     @Data
     public static class OrderItem implements Serializable {
 

+ 12 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/OmsOrderServiceImpl.java

@@ -220,6 +220,7 @@ public class OmsOrderServiceImpl implements OmsOrderService {
                     if (skuStockRecord.getInternalStock() > 0) {
                         OrderSkuSync.SkuSync sync = new OrderSkuSync.SkuSync();
                         sync.setSku(skuStockRecord.getProductSkuId());
+                        sync.setType("INTERNAL");
 
 
                         int stock = skuStockRecord.getInternalStock() - skuStockRecord.getInternalSaleStock();
@@ -254,6 +255,7 @@ public class OmsOrderServiceImpl implements OmsOrderService {
                         sync.setSku(skuStockRecord.getProductSkuId());
                         sync.setPrice(skuStockRecord.getPrice());
                         sync.setRecordId(skuStockRecord.getId());
+                        sync.setType("TAX");
 
                         int stock = skuStockRecord.getTaxStock() - skuStockRecord.getTaxSaleStock();
                         if (stock > 0) {
@@ -767,6 +769,16 @@ public class OmsOrderServiceImpl implements OmsOrderService {
         if (!CollectionUtils.isEmpty(orderItemList)) {
             omsOrderItemMapper.insertList(orderItemList);
         }
+
+        // 关闭需要关闭的订单
+        if(!CollectionUtils.isEmpty(order.getCloseOrderNoList())) {
+            OmsOrderExample example = new OmsOrderExample();
+            example.createCriteria().andOrderSnIn(order.getCloseOrderNoList());
+            OmsOrder record = new OmsOrder();
+            record.setStatus(4);
+            orderMapper.updateByExampleSelective(record, example);
+        }
+
         // 如果订单状态是已发货,扣减库存
         if (order.getStatus() ==2 || order.getStatus() == 3) {
 

+ 3 - 2
mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -595,12 +595,13 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
                     cancelOrder.getOrderSn());
             if (userOrderPayment != null) {
                 HttpResponseResult<OrderCancelModel> responseResult = webFeignService.cancelOrder(userOrderPayment.getAdapayNo(),message);
+                LOG.info("管乐迷取消订单返回结果:{}",JSON.toJSONString(responseResult));
                 if (!responseResult.getStatus()) {
-                    throw new BizException("远程取消失败");
+                    throw new BizException("订单取消失败");
                 }
                 OrderCancelModel data = responseResult.getData();
                 if (!data.getSuccess()) {
-                    throw new BizException("远程取消失败");
+                    throw new BizException("订单取消失败:"+data.getMessage());
                 }
                 if (data.getStatus() !=null && data.getStatus()) {
                     LOG.info("订单支付成功,修改订单状态");

+ 4 - 3
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -217,10 +217,10 @@ public class Payment {
      * @param merchantKey 商户Key
      * @return Map<String, Object>
      */
-    public static Map<String ,Object> closeWithKey(String transNo, String reason, String merchantKey) {
+    public static Map<String ,String> closeWithKey(String transNo, String reason, String merchantKey) {
 
 
-        Map<String, Object> result = new HashMap<>();
+        Map<String, String> result = new HashMap<>();
 
         Map<String, Object> params = new HashMap<>();
 
@@ -234,6 +234,7 @@ public class Payment {
         } catch (BaseAdaPayException e) {
             LOGGER.info("请求汇付[关单]接口失败:{}", e.getMessage());
             result.put("status", "failed");
+            result.put ("msg",e.getMessage());
             return result;
         }
         if (StringUtils.equals(paymentClose.get("status").toString(), "failed")) {
@@ -250,7 +251,7 @@ public class Payment {
                 result.put("status", "success");
             }
             result.put("status", "failed");
-            // throw new PaymentException(paymentClose.get("error_msg").toString());
+            result.put ("msg",paymentClose.get("error_msg").toString());
         }
 
         return result;

+ 9 - 5
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayPaymentService.java

@@ -113,11 +113,11 @@ public class YeepayPaymentService {
      * @param reason 原因
      * @return Map<String, Object>
      */
-    public Map<String,Object> close(HfMerchantConfig hfMerchantConfig,String transNo, String reason, String outTransNo) {
+    public Map<String,String> close(HfMerchantConfig hfMerchantConfig,String transNo, String reason, String outTransNo) {
 
 
-        Map<String, Object> result = new HashMap<>();
-        result.put("status", "failed");
+        Map<String, String> result = new HashMap<>();
+        result.put("status", "success");
         try {
 
             // 订单参数
@@ -135,12 +135,15 @@ public class YeepayPaymentService {
 
             // 关闭订单异常消息
             if (Objects.nonNull(ret.getError())) {
-                LOGGER.error("易宝[关闭订单]接口失败:transNo={}, reason={}", transNo, reason, ret.getError());
-                result.put("status", "failed");
+                LOGGER.error("易宝[关闭订单]接口失败:transNo={}, reason={}", transNo, ret.getError());
+                result.put("msg", ret.getError().getSubMessage());
+                result.put("status","failed");
             }
 
             JSONObject jsonObject = JSON.parseObject(ret.getStringResult());
 
+            // 响应参数
+
             // 关闭订单成功
             // OPR00000	成功
             // OPR18015	已拒绝支付,不必关闭订单
@@ -153,6 +156,7 @@ public class YeepayPaymentService {
         } catch (Exception e) {
             LOGGER.error("易宝[关闭订单]接口失败:transNo={}, reason={}", transNo, reason, e);
             result.put("status", "failed");
+            result.put("msg", e.getMessage());
 
         }