瀏覽代碼

fix 分部订单不存在,显示订单和金额都为0

周箭河 5 年之前
父節點
當前提交
efe341b1ad

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OrganizationDao.java

@@ -36,4 +36,6 @@ public interface OrganizationDao extends BaseDAO<Integer, Organization> {
      * @return
      */
     List<Map<Integer,String>> findOrganNameMap(String organIds);
+
+    List<Organization> findAllOrgans();
 }

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/OrganizationMapper.xml

@@ -120,4 +120,7 @@
     <select id="findOrganNameMap" resultType="java.util.Map">
         SELECT o.id_ 'key',o.name_ 'value' FROM organization o WHERE FIND_IN_SET(o.id_,#{organIds})
     </select>
+    <select id="findAllOrgans" resultMap="Organization">
+        SELECT * from organization where del_flag_=0 ORDER BY id_ ASC;
+    </select>
 </mapper>

+ 26 - 10
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -1,9 +1,10 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.dao.OrganizationDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.LuckStatisDto;
 import com.ym.mec.biz.dal.dto.OrderStatisDto;
-import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -37,9 +38,6 @@ import com.huifu.adapay.model.payment.PayChannelEnum;
 import com.huifu.adapay.model.payment.Payment;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dto.VipBuyResultDto;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.controller.BaseController;
@@ -78,6 +76,8 @@ public class StudentOrderController extends BaseController {
     private SysConfigDao sysConfigDao;
     @Autowired
     private SporadicChargeInfoService sporadicChargeInfoService;
+    @Autowired
+    private OrganizationDao organizationDao;
 
     @PostMapping("/notify")
     public Msg notify(@ModelAttribute Msg msg) throws Exception {
@@ -131,7 +131,7 @@ public class StudentOrderController extends BaseController {
         } 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)){
+        } else if (orderByOrderNo.getGroupType().equals(GroupType.SPORADIC)) {
             SporadicChargeInfo info = sporadicChargeInfoService.get(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
             orderDetail.put("detail", info);
         }
@@ -288,21 +288,37 @@ public class StudentOrderController extends BaseController {
     public void paymentResult(HttpServletResponse response, String orderNo) {
         try {
             String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-            response.sendRedirect(baseApiUrl+"/#/paymentresult?orderNo=" + orderNo);
+            response.sendRedirect(baseApiUrl + "/#/paymentresult?orderNo=" + orderNo);
         } catch (IOException e) {
             e.printStackTrace();
         }
     }
 
     @GetMapping("/getLuckStatis")
-    public HttpResponseResult getLuckStatis(){
+    public HttpResponseResult getLuckStatis() {
+        List<Organization> organs = organizationDao.findAllOrgans();
         List<OrderStatisDto> orders = studentPaymentOrderDao.getLuckStatis();
+
         BigDecimal totalMoney = BigDecimal.ZERO;
         Integer totalNum = 0;
-        for (OrderStatisDto order : orders) {
-            totalMoney = totalMoney.add(order.getMoney());
-            totalNum += order.getNums();
+        for (Organization organ : organs) {
+            boolean flag = false;
+            for (OrderStatisDto order : orders) {
+                totalMoney = totalMoney.add(order.getMoney());
+                totalNum += order.getNums();
+                if (organ.getName().equals(order.getOrganName())) {
+                    flag = true;
+                }
+            }
+            if (!flag) {
+                OrderStatisDto orderStatisDto = new OrderStatisDto();
+                orderStatisDto.setOrganName(organ.getName());
+                orderStatisDto.setMoney(BigDecimal.ZERO);
+                orderStatisDto.setNums(0);
+                orders.add(orderStatisDto);
+            }
         }
+
         LuckStatisDto luckStatisDto = new LuckStatisDto();
         luckStatisDto.setOrderStatisDtoList(orders);
         luckStatisDto.setTotalNum(totalNum);