Browse Source

机构画像调试

huangzhiguo 2 years ago
parent
commit
071ffae0db

+ 13 - 8
src/main/java/com/caimei/modules/user/service/ClubPortraitService.java

@@ -11,6 +11,7 @@ import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.NumberFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -88,7 +89,10 @@ public class ClubPortraitService {
             ArrayList<OrderPortrait> orderPortraits = new ArrayList<>();
             OrderPortrait orderPortrait = new OrderPortrait();
             List<NewOrder> orderList = cmPortraitDao.selOrderList(cmPortrait);
-            if (orderList.size() != 0) {
+            int length = orderList.size();
+            NumberFormat instance = NumberFormat.getInstance();
+            instance.setMaximumFractionDigits(2);
+            if (length != 0) {
                 for (NewOrder order : orderList) {
                     // 普通订单
                     if (("0".equals(order.getSecondHandOrderFlag()) || StringUtils.isEmpty(order.getSecondHandOrderFlag()))
@@ -122,10 +126,11 @@ public class ClubPortraitService {
                 }
                 /*cmPortrait.setOrderTotalAmount(orderList.get(0).getTotalMoney());
                 cmPortrait.setOrderTotal(orderList.get(0).getNumbers());*/
-                cmPortrait.setOrderTotal(orderList.size());
+                cmPortrait.setOrderTotal(length);
+
                 orderPortrait.setValue(ordinary);
                 if (ordinary != 0) {
-                    orderPortrait.setName("普通订单 【" + ordinary / orderList.size() * 100 + "%】 【" + ordinary + "个】");
+                    orderPortrait.setName("普通订单 【" + instance.format((float)ordinary / (float) length * 100) + "%】 【" + ordinary + "个】");
                 } else {
                     orderPortrait.setName("普通订单 【 0 】 【" + ordinary + "个】");
                 }
@@ -133,7 +138,7 @@ public class ClubPortraitService {
                 orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(secondHand);
                 if (secondHand != 0) {
-                    orderPortrait.setName("二手订单 【" + secondHand / orderList.size() * 100 + "%】 【" + secondHand + "个】");
+                    orderPortrait.setName("二手订单 【" + instance.format((float)secondHand / (float) length * 100) + "%】 【" + secondHand + "个】");
                 } else {
                     orderPortrait.setName("二手订单 【 0 】 【" + secondHand + "个】");
                 }
@@ -141,7 +146,7 @@ public class ClubPortraitService {
                 orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(rebate);
                 if (rebate != 0) {
-                    orderPortrait.setName("返佣订单 【" + rebate / orderList.size() * 100 + "%】 【" + rebate + "个】");
+                    orderPortrait.setName("返佣订单 【" + instance.format((float)rebate / (float) length * 100) + "%】 【" + rebate + "个】");
                 } else {
                     orderPortrait.setName("返佣订单 【 0 】 【" + rebate + "个】");
                 }
@@ -149,7 +154,7 @@ public class ClubPortraitService {
                 orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(partialRefund);
                 if (partialRefund != 0) {
-                    orderPortrait.setName("部分退款订单 【" + partialRefund / orderList.size() * 100 + "%】 【" + partialRefund + "个】");
+                    orderPortrait.setName("部分退款订单 【" + instance.format((float)partialRefund / (float) length * 100) + "%】 【" + partialRefund + "个】");
                 } else {
                     orderPortrait.setName("部分退款订单 【 0 】 【" + partialRefund + "个】");
                 }
@@ -157,7 +162,7 @@ public class ClubPortraitService {
                 orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(fullRefund);
                 if (fullRefund != 0) {
-                    orderPortrait.setName("全部退款订单 【" + fullRefund / orderList.size() * 100 + "%】 【" + fullRefund + "个】");
+                    orderPortrait.setName("全部退款订单 【" + instance.format((float)fullRefund / (float) length * 100) + "%】 【" + fullRefund + "个】");
                 } else {
                     orderPortrait.setName("全部退款订单 【 0 】 【" + fullRefund + "个】");
                 }
@@ -165,7 +170,7 @@ public class ClubPortraitService {
                 orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(closed);
                 if (closed != 0) {
-                    orderPortrait.setName("已关闭订单 【" + closed / orderList.size() * 100 + "%】 【" + closed + "个】");
+                    orderPortrait.setName("已关闭订单 【" + instance.format((float)closed / (float) length * 100) + "%】 【" + closed + "个】");
                 } else {
                     orderPortrait.setName("已关闭订单 【 0 】 【" + closed + "个】");
                 }

+ 23 - 4
src/main/java/com/caimei/modules/user/web/newUser/AgencyController.java

@@ -26,6 +26,7 @@ import com.google.common.collect.Maps;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.utils.Encodes;
+import com.thinkgem.jeesite.common.utils.ObjectUtils;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.thinkgem.jeesite.common.web.BaseController;
 import com.thinkgem.jeesite.modules.sys.security.SystemAuthorizingRealm;
@@ -1426,20 +1427,38 @@ public class AgencyController extends BaseController {
             }
             order.setOrderTotalNum(portrait.getOrderTotal());
 
+            if (order.getOrderTotalNum() == 0) {
+                map.put("order",null);
+            } else {
+                map.put("order",order);
+            }
             behavior.setName(portrait.getBehaviorType());
             behavior.setValue(portrait.getBehaviorValue());
 
+            if (ObjectUtils.isEmpty(behavior.getValue())) {
+                map.put("behavior",null);
+            } else {
+                map.put("behavior",behavior);
+            }
             remarks.setName(portrait.getRemarksType());
             remarks.setValue(portrait.getRemarksValue());
-
+            if (ObjectUtils.isEmpty(remarks.getValue())) {
+                map.put("remarks",null);
+            } else {
+                map.put("remarks",remarks);
+            }
             pageType.setName(portrait.getPageType());
             pageType.setValue(portrait.getPageTypeValue());
-
+            if (ObjectUtils.isEmpty(pageType.getValue())) {
+                map.put("pageType",null);
+            } else {
+                map.put("pageType",pageType);
+            }
             map.put("portrait",portrait);
-            map.put("behavior",behavior);
+            /*map.put("behavior",behavior);
             map.put("remarks",remarks);
             map.put("pageType",pageType);
-            map.put("order",order);
+            map.put("order",order);*/
             map.put("code",0);
         } catch (Exception e) {
             e.printStackTrace();

+ 0 - 1
src/main/resources/mappings/modules/user/CmPortraitMapper.xml

@@ -33,7 +33,6 @@
 
     <select id="selBehaviorList" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
         SELECT
-               (SELECT COUNT(cbr.recordID) FROM cm_behavior_record cbr LEFT JOIN club c ON cbr.userID = c.userID WHERE cbr.pageType IN (8, 9) AND c.clubID = #{clubID}) as numbers,
                c.clubID,
                COUNT(cbr.pageLabel) as number,
                cbr.pageLabel,

+ 17 - 0
src/main/webapp/static/modules/cmClubPortrait/cmClubEacths.js

@@ -45,6 +45,8 @@ const getInfoOrderDate = function () {
             $('#orderTimeEnd').val(s2);
             if (defaultParams.startTime && defaultParams.endTime) {
                 getClubEacthsData(0,0)
+                defaultParams.startTime = '';
+                defaultParams.endTime = '';
             }
         }
     });
@@ -73,6 +75,8 @@ const getInfoKeyWordsDate = function () {
             $('#keyWordsTimeEnd').val(s2);
             if (defaultParams.startTime && defaultParams.endTime) {
                 getClubEacthsData(1,0)
+                defaultParams.startTime = '';
+                defaultParams.endTime = '';
             }
         }
     });
@@ -101,6 +105,8 @@ const getInfoServiceDate = function () {
             $('#serviceTimeEnd').val(s2);
             if (defaultParams.startTime && defaultParams.endTime) {
                 getClubEacthsData(2,0)
+                defaultParams.startTime = '';
+                defaultParams.endTime = '';
             }
         }
     });
@@ -129,6 +135,9 @@ const getInfoVisitDate = function () {
             $('#visitTimeEnd').val(s2);
             if (defaultParams.startTime && defaultParams.endTime) {
                 getClubEacthsData(3,0)
+                defaultParams.startTime = '';
+                defaultParams.endTime = '';
+
             }
         }
     });
@@ -153,6 +162,8 @@ const  getClubEacthsData = function (type,dateType) {
                             $('#orderEacths').hide();
                             $('.eachts-total').hide();
                         }else{
+                            $('#orderEacths').show();
+                            $('#orderEacthsNone').hide();
                             getOrderEacths(data.order.orderList);
                             $('#orderTotalNum').text(`${data.order.orderTotalNum}个`);
                         }
@@ -162,6 +173,8 @@ const  getClubEacthsData = function (type,dateType) {
                             $('#keyWordsEacthsNone').show();
                             $('#keyWordsEacths').hide();
                         }else{
+                            $('#keyWordsEacths').show();
+                            $('#keyWordsEacthsNone').hide();
                             setOtherData(type,data)
                         }
                         break;
@@ -170,6 +183,8 @@ const  getClubEacthsData = function (type,dateType) {
                             $('#serviceEacthsNone').show();
                             $('#serviceEacths').hide();
                         }else{
+                            $('#serviceEacths').show();
+                            $('#serviceEacthsNone').hide();
                             setOtherData(type,data)
                         }
                         break;
@@ -178,6 +193,8 @@ const  getClubEacthsData = function (type,dateType) {
                             $('#visitEacthsNone').show();
                             $('#visitEacths').hide();
                         }else{
+                            $('#visitEacths').show();
+                            $('#visitEacthsNone').hide();
                             setOtherData(type,data)
                         }
                         break;