From eb6b6dbb35a9f029e0b7d269773685c19fd40976 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 11 七月 2024 10:47:51 +0800
Subject: [PATCH] 玩湃微信商户认证代码

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponExamineController.java |  166 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 156 insertions(+), 10 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponExamineController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponExamineController.java
index c27a8fc..bed990f 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponExamineController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TCouponExamineController.java
@@ -1,22 +1,37 @@
 package com.dsh.guns.modular.system.controller.code;
 
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dsh.course.feignClient.activity.CouponClient;
 import com.dsh.course.feignClient.activity.model.Coupon;
+import com.dsh.course.feignClient.activity.model.CouponCity;
 import com.dsh.course.feignClient.activity.model.CouponExamineListSearch;
 import com.dsh.course.feignClient.activity.model.CouponListOfSearch;
+import com.dsh.guns.config.UserExt;
 import com.dsh.guns.core.base.controller.BaseController;
 import com.dsh.guns.core.common.constant.factory.PageFactory;
 import com.dsh.guns.core.exception.GunsException;
 import com.dsh.guns.core.util.ToolUtil;
+import com.dsh.guns.modular.system.model.TOperator;
+import com.dsh.guns.modular.system.model.TStore;
+import com.dsh.guns.modular.system.model.User;
+import com.dsh.guns.modular.system.service.IStoreService;
+import com.dsh.guns.modular.system.service.IUserService;
+import com.dsh.guns.modular.system.service.TOperatorService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -33,6 +48,12 @@
 
     @Resource
     private CouponClient client;
+    @Autowired
+    private IUserService userService;
+    @Autowired
+    private TOperatorService operatorService;
+    @Autowired
+    private IStoreService storeService;
 
     /**
      * 优惠券审核列表页
@@ -43,7 +64,15 @@
     }
 
 
-
+    /**
+     * 获取根据门店id 获取店长信息
+     */
+    @RequestMapping(value = "/getStoreInfo")
+    @ResponseBody
+    public String getStoreInfo(@RequestBody Integer id) {
+        User byId = userService.getById(id);
+        return byId.getName() + "-" + byId.getAccount();
+    }
     /**
      * 获取 优惠券审核列表
      */
@@ -58,17 +87,135 @@
         ofSearch.setDistributionMethod(distributionMethod);
         ofSearch.setUserPopulation(userPopulation);
         ofSearch.setAuditStatus(auditStatus);
-        return client.getCouponExamineListOfSearch(ofSearch);
+        List<Map<String, Object>> res = client.getCouponExamineListOfSearch(ofSearch);
+        for (Map<String, Object> re : res) {
+            if (re.get("publisherType")!=null){
+
+            }
+            switch (Integer.valueOf(re.get("publisherType").toString())){
+                case 1:
+                    // 运营商添加
+                    if (re.get("cityManagerId")!=null){
+                        TOperator one = operatorService.getOne(new QueryWrapper<TOperator>()
+                                .eq("id", Integer.valueOf(re.get("cityManagerId").toString())));
+                        if (one!=null){
+                            User id = userService.getOne(new QueryWrapper<User>().eq("id", one.getUserId()));
+                            if (id!=null){
+                                re.put("account",one.getName()+"-"+id.getPhone());
+                            }
+                        }
+                    }
+                    break;
+                case 2:
+                    re.put("account","平台");
+                    // 平台添加
+                    break;
+                case 3:
+                    // 门店添加
+                    if (re.get("cityManagerId")!=null){
+                        TStore one = storeService.getOne(new QueryWrapper<TStore>()
+                                .eq("id", Integer.valueOf(re.get("cityManagerId").toString())));
+                        if (one!=null){
+                            User id = userService.getOne(new QueryWrapper<User>().eq("id", one.getStoreStaffId()));
+                            if (id!=null){
+                                re.put("account",one.getName()+"-"+id.getPhone());
+                            }
+                        }
+                    }
+                    break;
+            }
+        }
+        return res;
     }
 
     /**
      * 获取 优惠券审核详情
      */
     @RequestMapping(value = "/couponOfDetail/{id}")
-    @ResponseBody
     public String detailOfCoupon(@PathVariable Integer id, Model model){
-        Map<String, Object> stringObjectMap = client.queryCouponExamineDetail(id);
-        model.addAttribute(stringObjectMap);
+        model.addAttribute("id",id);
+        Coupon coupon = client.queryCouponById(id);
+        Integer auditStatus1 = coupon.getAuditStatus();
+        model.addAttribute("state",auditStatus1);
+        String content = coupon.getContent();
+        JSONObject jsonObject = JSONObject.parseObject(content);
+        String one ="";
+        String two ="";
+        String three ="";
+        if(coupon.getType()==1){
+            one = jsonObject.get("conditionalAmount").toString();
+            two = jsonObject.get("deductionAmount").toString();
+        }
+        if(coupon.getType()==2){
+            one = jsonObject.get("conditionalAmount").toString();
+        }
+        if(coupon.getType()==3){
+            three = jsonObject.get("experienceName").toString();
+        }
+        List<CouponCity> list = new ArrayList<>();
+        List<Integer> list1=null;
+        List<TStore> list2=new ArrayList<>();
+        if(coupon.getUseScope()==2){
+            list = client.queryCity(coupon.getId());
+        }
+        if(coupon.getUseScope()==3){
+            // 门店ids
+            list1 = client.queryStore(coupon.getId());
+            // 门店集合
+            list2 = storeService.list(new LambdaQueryWrapper<TStore>().in(TStore::getId, list1));
+            for (TStore tStore : list2) {
+                if (coupon.getPublisherType() == 1){
+                    // 获取运营商id
+                    Integer operatorId = tStore.getOperatorId();
+                    TOperator operator = operatorService.getById(operatorId);
+                    User user = userService.getById(operator.getUserId());
+                    if (ToolUtil.isNotEmpty(user)){
+                        tStore.setProvince(tStore.getProvince()+tStore.getCity());
+                        tStore.setPhone(user.getName()+"-"+user.getPhone());
+                    }
+                }
+                if (coupon.getPublisherType() == 2) {
+                    User byId = userService.getById(tStore.getStoreStaffId());
+
+                    tStore.setProvince(tStore.getProvince() + tStore.getCity());
+                    tStore.setPhone(byId.getName() + "-" + byId.getPhone());
+
+                }
+            }
+        }
+        model.addAttribute("city",list);
+        model.addAttribute("store",list2);
+        model.addAttribute("s",new SimpleDateFormat("yyyy-MM-dd").format(coupon.getStartTime()));
+        model.addAttribute("e",new SimpleDateFormat("yyyy-MM-dd").format(coupon.getEndTime()));
+        model.addAttribute("one",one);
+        model.addAttribute("two",two);
+        model.addAttribute("three",three);
+        ArrayList<String> strings = new ArrayList<>();
+        String productImages = coupon.getProductImages();
+        for (String s : productImages.split(",")) {
+            strings.add(s);
+        }
+        model.addAttribute("integral",coupon.getIntegral());
+        model.addAttribute("cash",coupon.getCash());
+        model.addAttribute("img",strings);
+        Integer objectType = UserExt.getUser().getObjectType();
+        System.out.println(objectType);
+        model.addAttribute("item",coupon);
+        model.addAttribute("objectType",objectType);
+        Integer auditStatus = coupon.getAuditStatus();
+        switch (auditStatus){
+            case 1:
+                model.addAttribute("state","待审核");
+                break;
+            case 2:
+                model.addAttribute("state","已拒绝");
+                break;
+            case 3:
+                model.addAttribute("state","未通过");
+                break;
+        }
+        model.addAttribute("cover",coupon.getCover());
+        model.addAttribute("productImages",coupon.getProductImages());
         return PREFIX + "TCouponExamineInfo.html";
     }
 
@@ -77,7 +224,6 @@
      * 获取 优惠券审核详情
      */
     @RequestMapping(value = "/couponExaminePage/{id}")
-    @ResponseBody
     public String couponExaminePage(@PathVariable Integer id, Model model){
         model.addAttribute("id",id);
         return PREFIX + "TCouponExamine.html";
@@ -87,13 +233,13 @@
 
     @RequestMapping(value = "/examine")
     @ResponseBody
-    public Object examine(Integer couponOfId, Integer state, String remark) {
-        Coupon coupon = client.queryCouponById(couponOfId);
+    public Object examine(Integer id, Integer state, String remark) {
+        Coupon coupon = client.queryCouponById(id);
         try {
-            if (state == 1) {
+            if (state == 2) {
                 coupon.setAuditStatus(2);
             }
-            if (state == 2) {
+            if (state == 3) {
                 coupon.setAuditStatus(3);
                 coupon.setAuditRemark(remark);
             }

--
Gitblit v1.7.1