Explorar o código

经营报表修改

周箭河 %!s(int64=4) %!d(string=hai) anos
pai
achega
47945d88de

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/SubjectChangeService.java

@@ -28,7 +28,7 @@ public interface SubjectChangeService extends BaseService<Integer, SubjectChange
      * @param isUseBalancePayment
      * @return
      */
-    Map payChange(Integer id, BigDecimal amount, Boolean isUseBalancePayment) throws Exception;
+    Map payChange(Integer id, BigDecimal amount, Boolean isUseBalancePayment,Boolean isRepay) throws Exception;
 
     /**
      * 添加声部更换

+ 29 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -94,21 +94,32 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
     }
 
     @Override
-    public Map payChange(Integer id, BigDecimal viewAmount, Boolean isUseBalancePayment) throws Exception {
+    @Transactional(rollbackFor = Exception.class)
+    public Map payChange(Integer id, BigDecimal viewAmount, Boolean isUseBalancePayment, Boolean isRepay) throws Exception {
+        Date date = new Date();
         SubjectChange subjectChange = subjectChangeDao.get(id);
+        if (isRepay) {
+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.get(subjectChange.getOrganId().longValue());
+            studentPaymentOrder.setStatus(DealStatusEnum.CLOSE);
+            studentPaymentOrder.setUpdateTime(date);
+            studentPaymentOrderService.update(studentPaymentOrder);
+            subjectChange.setStatus(SubjectChangeStatusEnum.WAIT_PAY);
+        }
+
+        if (subjectChange.getStatus().equals(SubjectChangeStatusEnum.CANCELED)) {
+            throw new BizException("声部订单当前不可缴费");
+        }
+        if (subjectChange.getStatus().equals(SubjectChangeStatusEnum.SUCCESSED)) {
+            throw new BizException("声部更改已缴费,请勿重复缴费");
+        }
+
         MusicGroup musicGroup = musicGroupDao.get(subjectChange.getMusicGroupId());
-        if (musicGroup.getStatus().equals(MusicGroupStatusEnum.APPLY) && musicGroup.getStatus().equals(MusicGroupStatusEnum.PAY)) {
-            throw new BizException("乐团当前状态不能缴费");
+        if (!musicGroup.getStatus().equals(MusicGroupStatusEnum.APPLY) && !musicGroup.getStatus().equals(MusicGroupStatusEnum.PAY)) {
+            throw new BizException("乐团当前状态不能缴声部更改");
         }
         BigDecimal amount = subjectChange.getGoodsMargin().add(subjectChange.getCourseMargin());
 
-        Date date = new Date();
         studentDao.lockUser(subjectChange.getStudentId());
-        subjectChange.setUpdateTime(date);
-        subjectChange.setStatus(SubjectChangeStatusEnum.ING);
-        if (subjectChangeDao.update(subjectChange) <= 0) {
-            throw new BizException("下单失败,请重试");
-        }
 
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
@@ -129,10 +140,19 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         studentPaymentOrder.setRoutingOrganId(subjectChange.getOrganId());
 
         studentPaymentOrderService.insert(studentPaymentOrder);
+
+        subjectChange.setOrganId(studentPaymentOrder.getId().intValue());
+        subjectChange.setUpdateTime(date);
+        subjectChange.setStatus(SubjectChangeStatusEnum.ING);
+        if (subjectChangeDao.update(subjectChange) <= 0) {
+            throw new BizException("下单失败,请重试");
+        }
+
         studentPaymentOrder.setVersion(0);
         if (amount.compareTo(viewAmount) != 0) {
             throw new BizException("价格异常");
         }
+
         BigDecimal balance = BigDecimal.ZERO;
         if (isUseBalancePayment != null && isUseBalancePayment && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(subjectChange.getStudentId());

+ 13 - 4
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -128,14 +128,14 @@ public class StudentOrderController extends BaseController {
             orderDetail.put("goods", goodsList);
             orderDetail.put("course", musicGroup.getCourseForm());
             orderDetail.put("ownershipType", musicGroup.getOwnershipType());
-            orderDetail.put("detailType",orderDetailType);
+            orderDetail.put("detailType", orderDetailType);
         } else if (orderByOrderNo.getGroupType().equals(GroupType.VIP)) {
             VipBuyResultDto vipBuyResultInfo = vipGroupService.findVipBuyResultInfo(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
             orderDetail.put("detail", vipBuyResultInfo);
         } else if (orderByOrderNo.getGroupType().equals(GroupType.SPORADIC)) {
             SporadicChargeInfo info = sporadicChargeInfoService.get(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
             orderDetail.put("detail", info);
-        }else if(orderByOrderNo.getGroupType().equals(GroupType.GOODS_SELL)){
+        } else if (orderByOrderNo.getGroupType().equals(GroupType.GOODS_SELL)) {
             orderDetail.put("detail", studentGoodsSellDao.getStudentGoodsSellDto(orderNo));
         }
         return succeed(orderDetail);
@@ -151,7 +151,7 @@ public class StudentOrderController extends BaseController {
     public Object executePayment(BigDecimal amount, String orderNo, String payChannel, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sign, String code, String platform) throws Exception {
         Map<String, Object> signParams = new LinkedHashMap<>();
         signParams.put("appId", ConfigInit.appId);
-        signParams.put("amount", amount.setScale(2,BigDecimal.ROUND_HALF_UP));
+        signParams.put("amount", amount.setScale(2, BigDecimal.ROUND_HALF_UP));
         signParams.put("orderNo", orderNo);
 //        signParams.put("notifyUrl", notifyUrl);
 //        signParams.put("returnUrl", returnUrl);
@@ -190,6 +190,15 @@ public class StudentOrderController extends BaseController {
         if (studentPaymentOrder == null && tenantPaymentOrder == null) {
             return failed("订单不存在");
         }
+        if (studentPaymentOrder != null && !studentPaymentOrder.getStatus().equals(DealStatusEnum.ING)) {
+            String msg = studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS) ? "订单已支付,请勿重复支付" : "订单已关闭,不能支付";
+            return failed(msg);
+        }
+        if (tenantPaymentOrder != null && !tenantPaymentOrder.getStatus().equals(DealStatusEnum.ING)) {
+            String msg = tenantPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS) ? "订单已支付,请勿重复支付" : "订单已关闭,不能支付";
+            return failed(msg);
+        }
+
         if (studentPaymentOrder != null) {
             createTime = studentPaymentOrder.getCreateTime();
         } else {
@@ -210,7 +219,7 @@ public class StudentOrderController extends BaseController {
         paymentParams.put("app_id", ConfigInit.appId);
         paymentParams.put("order_no", orderNo);
         paymentParams.put("pay_channel", payChannel);
-        paymentParams.put("pay_amt", amount.setScale(2,BigDecimal.ROUND_HALF_UP));
+        paymentParams.put("pay_amt", amount.setScale(2, BigDecimal.ROUND_HALF_UP));
         paymentParams.put("goods_title", orderSubject);
         paymentParams.put("goods_desc", orderBody);
         paymentParams.put("time_expire", timeExpire);

+ 11 - 2
mec-student/src/main/java/com/ym/mec/student/controller/SubjectChangeController.java

@@ -1,6 +1,8 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.dao.SubjectChangeDao;
 import com.ym.mec.biz.dal.entity.SubjectChange;
+import com.ym.mec.biz.dal.enums.SubjectChangeStatusEnum;
 import com.ym.mec.biz.service.SubjectChangeService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -9,6 +11,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -25,6 +28,8 @@ public class SubjectChangeController extends BaseController {
 
     @Autowired
     private SubjectChangeService subjectChangeService;
+    @Autowired
+    private SubjectChangeDao subjectChangeDao;
 
 
     @ApiOperation(value = "获取更换详情")
@@ -43,8 +48,12 @@ public class SubjectChangeController extends BaseController {
             @ApiImplicitParam(name = "金额", value = "amount", required = true, dataType = "BigDecimal"),
             @ApiImplicitParam(name = "是否使余额", value = "isUseBalancePayment", required = true, dataType = "Boolean")
     })
-    public HttpResponseResult<Map> payChaange(Integer id, BigDecimal amount, Boolean isUseBalancePayment) throws Exception {
-        return succeed(subjectChangeService.payChange(id, amount, isUseBalancePayment));
+    public HttpResponseResult<Map> payChaange(Integer id, BigDecimal amount, Boolean isUseBalancePayment, Boolean isRepay) throws Exception {
+        SubjectChange subjectChange = subjectChangeDao.get(id);
+        if (!isRepay && subjectChange.getStatus().equals(SubjectChangeStatusEnum.ING)) {
+            return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+        }
+        return succeed(subjectChangeService.payChange(id, amount, isUseBalancePayment, isRepay));
     }
 
 

+ 7 - 1
mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportController.java

@@ -103,9 +103,15 @@ public class OperatingReportController extends BaseController {
         OutputStream outputStream = response.getOutputStream();
         try {
 
-            String[] header = {"分部","学校","销售收入(元)","服务收入(元)","业务退费(元)","收入合计(元)","销售成本(元)","固定支出(元)", "变动支出(元)", "分摊费用(元)", "成本费用合计(元)", "利润(元)"};
+            String[] header = {"分部","销售收入(元)","服务收入(元)","业务退费(元)","收入合计(元)","销售成本(元)","固定支出(元)", "变动支出(元)", "分摊费用(元)", "成本费用合计(元)", "利润(元)"};
             String[] body = {"organName", "schoolName", "sellAmount", "serviceAmount", "refundAmount", "incomeTotal", "sellCost","expensesAmount","variableCost","distributionAmount","costAmount","profit"};
             HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList.getRows());
+
+
+            String[] header2 = {"分部","学校","销售收入(元)","服务收入(元)","业务退费(元)","收入合计(元)","销售成本(元)","固定支出(元)", "变动支出(元)", "分摊费用(元)", "成本费用合计(元)", "利润(元)"};
+            String[] body2 = {"organName", "schoolName", "sellAmount", "serviceAmount", "refundAmount", "incomeTotal", "sellCost","expensesAmount","variableCost","distributionAmount","costAmount","profit"};
+            HSSFWorkbook workbook2 = POIUtil.exportExcel(header, body, pageList.getRows());
+
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=cooperationOrgan-" + DateUtil.getDate(new Date()) + ".xls");
             response.flushBuffer();