From 9486766c806fe1d9e082b2fd02ea1cc558f1b443 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 08 五月 2025 09:21:57 +0800
Subject: [PATCH] bug修改

---
 cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TGoodsController.java |  218 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 190 insertions(+), 28 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TGoodsController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TGoodsController.java
index 7c36464..cb753c5 100644
--- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TGoodsController.java
+++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TGoodsController.java
@@ -14,6 +14,9 @@
 import com.dsh.course.feignClient.activity.PointMercharsClient;
 import com.dsh.course.feignClient.activity.model.*;
 import com.dsh.course.feignClient.course.CourseClient;
+import com.dsh.course.feignClient.course.CoursePackageClient;
+import com.dsh.course.feignClient.course.model.CoursePackagePaymentConfig;
+import com.dsh.course.feignClient.course.model.TCoursePackage;
 import com.dsh.guns.config.UserExt;
 import com.dsh.guns.core.base.controller.BaseController;
 import com.dsh.guns.core.base.tips.ErrorTip;
@@ -24,10 +27,12 @@
 import com.dsh.guns.modular.system.service.ICityService;
 import com.dsh.guns.modular.system.service.IRegionService;
 import com.dsh.guns.modular.system.service.IStoreService;
+import com.dsh.guns.modular.system.service.ITSiteService;
 import com.dsh.guns.modular.system.util.OBSUploadUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -51,11 +56,13 @@
 
 
     private String PREFIX = "/system/tGoods/";
+    private String PREFIX1 = "/system/tGoodsAudit/";
 
 
     @Resource
     private IRegionService regiService;
-
+    @Autowired
+    private ITSiteService siteService;
     @Resource
     private IStoreService storeService;
 
@@ -72,6 +79,8 @@
 
     @Autowired
     private CourseClient courseClient;
+    @Autowired
+    private CoursePackageClient coursePackageClient;
 
     @Resource
     private PointMercharsClient pointMercharsClient;
@@ -85,6 +94,11 @@
     public String index(Model model) {
 
         return PREFIX + "TGoods.html";
+    }
+    @RequestMapping("/audit")
+    public String audit(Model model) {
+
+        return PREFIX1 + "TGoodsAudit.html";
     }
 
     /**
@@ -131,11 +145,17 @@
             model.addAttribute("shopName",byId.getName());
             Integer coursePackageId = pointMercharsVo.getCoursePackageId();
             List<String> name = courseClient.queryPackageById(coursePackageId);
+            if(null != name){
+                model.addAttribute("typeName",name.get(0));
+                model.addAttribute("pageName",name.get(1));
+            }else{
+                model.addAttribute("typeName", "");
+                model.addAttribute("pageName", "");
+            }
             Integer coursePackageId1 = pointMercharsVo.getCoursePackageId();
-            String classHours = courseClient.getHours(coursePackageId1);
-            model.addAttribute("typeName",name.get(0));
-            model.addAttribute("pageName",name.get(1));
-            model.addAttribute("classHours",classHours);
+            List<CoursePackagePaymentConfig> hoursByPackageId = courseClient.getHoursByPackageId(coursePackageId1);
+
+            model.addAttribute("classHours",hoursByPackageId);
             String productImages = pointMercharsVo.getProductImages();
             ArrayList<String> strings = new ArrayList<>();
             for (String s : productImages.split(",")) {
@@ -153,29 +173,28 @@
                 List<StoreVos> provinces = pointMercharsClient.getProvinces(id);
                 model.addAttribute("city",provinces);
             }
-            if (infoOneVo.getUseScope() == 2){
+            if (infoOneVo.getUseScope() == 3){
                 List<StoreVos> storeVos = pointMercharsClient.getStoreList(id);
                 model.addAttribute("store",storeVos);
+            }
+            // 门票选的指定场地
+            if (infoOneVo.getUseScope() == 4){
+                List<StoreVos> storeVos = pointMercharsClient.getStoreList(id);
+                model.addAttribute("sites",storeVos);
             }
             model.addAttribute("pictures",list);
             model.addAttribute("exchangeMethod",infoOneVo.getExchangeMethod());
             return PREFIX + "TGoods_detail_one.html";
         }
-
-
     }
-
 
     @RequestMapping("/coupon_record/{id}")
     public String memberCouponAdd(@PathVariable Integer id,Model model) {
         Coupon coupon = client.queryCouponById(id);
-
         model.addAttribute("id",id);
         model.addAttribute("type",coupon.getType());
         return PREFIX + "TCouponRecord.html";
     }
-
-
 
     @RequestMapping("/coupon_detail/{id}")
     public String memberCouponDetail(@PathVariable Integer id,Model model) {
@@ -240,7 +259,27 @@
      */
     @RequestMapping("/storeList")
     public String storePage(Model model) {
+        List<TCity> provinceList = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",provinceList);
         return PREFIX + "TStoreList.html";
+    }
+
+
+    /**
+     * 跳转到门店管理列表页
+     */
+    @RequestMapping("/storeList1")
+    public String storePage1(Model model) {
+        List<TCity> provinceList = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",provinceList);
+        return PREFIX + "TStoreListOne.html";
+    }
+    // 场地列表
+    @RequestMapping("/siteList1")
+    public String storePage2(Model model) {
+        List<TCity> provinceList = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
+        model.addAttribute("list",provinceList);
+        return PREFIX + "TSiteListOne.html";
     }
     @RequestMapping("/updateType")
     @ResponseBody
@@ -383,8 +422,10 @@
      */
     @PostMapping(value = "/update")
     @ResponseBody
-    public Object update( Integer pointMerchandiseId,Integer quantityIssued,Integer pickUpQuantity,String redemptionInstructions,String cover,String productImages,Integer sort){
+    public Object update(String name, Integer pointMerchandiseId,Integer quantityIssued,Integer pickUpQuantity,
+                          String redemptionInstructions,String cover,String productImages,Integer sort){
         Map<String, Object> stringObjectHashMap = new HashMap<>();
+        stringObjectHashMap.put("name",name);
         stringObjectHashMap.put("pointMerchandiseId",pointMerchandiseId);
         stringObjectHashMap.put("quantityIssued",quantityIssued);
         stringObjectHashMap.put("pickUpQuantity",pickUpQuantity);
@@ -392,6 +433,7 @@
         stringObjectHashMap.put("cover",cover);
         stringObjectHashMap.put("productImages",productImages);
         stringObjectHashMap.put("sort",sort);
+        stringObjectHashMap.put("type",UserExt.getUser().getObjectType());
         System.out.println(stringObjectHashMap);
         pointMercharsClient.updateGoodsDetail(stringObjectHashMap);
         return new SuccessTip<>();
@@ -424,9 +466,31 @@
     @ResponseBody
     public Object add( Integer typeAll,String provinceCode,String cityCode,Integer storeId,Integer coursePackageTypeId,Integer coursePackageId,Integer coursePackageConfigId,
                        Double price,Integer type,Integer integral,Double cash,String cover,String imgOne,Integer userPopulation,Integer quantityIssued,Integer pickUpQuantity,
-                       String startTime,String text,Integer sort,String name,Integer useScope,String cityIds,String storeIds,Integer cardType
+                       String startTime,String text,Integer sort,String name,Integer useScope,String cityIds,String storeIds,String sites,Integer cardType
     ) throws ParseException {
+        // 判断当前选择的课包 是不是假期课 然后判断选择的有效期是否在假期课有效期内
+        if (coursePackageId!=null){
+            TCoursePackage tCoursePackage = coursePackageClient.queryById(coursePackageId);
+            if (tCoursePackage.getType()==2){
+                // 如果是假期课 获取到当前课包的开始时间和结束时间
+                Date endTime = tCoursePackage.getEndTime();
+                Date startTime1 = tCoursePackage.getStartTime();
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+                Date s = format.parse(startTime.split(" - ")[0]);
+                Date e = format.parse(startTime.split(" - ")[1]);
+                if (s.before(startTime1)){
+                    // 有效期开始时间小于假期课开始时间
+                    return 5009;
+                }
+                if (e.after(endTime)){
+                    // 有效期结束时间大于假期课结束时间
+                    return 5008;
+                }
+            }
+        }
         PointsMerchandise pointsMerchandise = new PointsMerchandise();
+        pointsMerchandise.setAddUserId(UserExt.getUser().getObjectId());
+        pointsMerchandise.setAddType(UserExt.getUser().getObjectType());
         pointsMerchandise.setType(typeAll);
         pointsMerchandise.setName(name);
         pointsMerchandise.setCoursePackageId(coursePackageId);
@@ -447,7 +511,19 @@
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         pointsMerchandise.setStartTime(format.parse(startTime.split(" - ")[0]));
         pointsMerchandise.setEndTime(format.parse(startTime.split(" - ")[1]));
-        pointsMerchandise.setUseScope(useScope);
+        if (UserExt.getUser().getObjectType()==3){
+            if (StringUtils.hasLength(sites)){
+                useScope = 4;
+                storeIds="";
+                pointsMerchandise.setUseScope(4);
+            }else{
+                useScope = 3;
+                pointsMerchandise.setUseScope(3);
+            }
+        }else{
+            pointsMerchandise.setUseScope(useScope);
+
+        }
         if(ToolUtil.isNotEmpty(provinceCode)){
             TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, provinceCode));
             pointsMerchandise.setProvinceCode(provinceCode);
@@ -463,9 +539,11 @@
         pointsMerchandise.setState(1);
         pointsMerchandise.setInsertTime(new Date());
         pointsMerchandise.setCoursePackageConfigId(coursePackageConfigId);
+        if(UserExt.getUser().getObjectType()!=1){
+            pointsMerchandise.setStatus(2);
+        }
         // 代替storeId
-        pointsMerchandise.setShelves(storeId);
-        Integer id = pointMercharsClient.add(pointsMerchandise);
+        pointsMerchandise.setShelves(1);
         if(typeAll!=2){
             if(useScope==2){
                 ArrayList<Map<String,String>> objects = new ArrayList<>();
@@ -477,20 +555,49 @@
                     map.put("pCode",pCity.getCode());
                     map.put("cName",tCity.getName());
                     map.put("cCode",tCity.getCode());
-                    map.put("id",id.toString());
+                    map.put("id","0");
                     objects.add(map);
                 }
                 pointMercharsClient.addCitys(objects);
-            }else if(useScope==3){
-                String pam = id+"_"+storeIds;
-                // 添加多个城市 门店
+            }else if(useScope==3||useScope==4){
+                if(UserExt.getUser().getObjectType()==3){
+                    storeIds=UserExt.getUser().getObjectId().toString();
+                }
+                if (useScope==4){
+                    storeIds ="";
+                }
+                if (useScope==3){
+                    sites ="";
+                }
+                if (StringUtils.hasLength(storeIds)){
+                Integer oid=null;
+                String[] split = storeIds.split(",");
+                for (int i = 0; i < split.length; i++) {
+                    if(i==0){
+                        Integer operatorId = storeService.getById(split[0]).getOperatorId();
+                        oid=operatorId;
+                    }
+                    Integer operatorId = storeService.getById(split[i]).getOperatorId();
+                    if(oid!=operatorId){
+                        return "5003";
+                    }
+                }
+                }
+                Integer id = pointMercharsClient.add(pointsMerchandise);
+                String pam = id+"_"+storeIds+"_"+sites;
+                // 添加多个城市 门店 场地
                 try{
                     pointMercharsClient.addOther(pam);
-
                 }catch (Exception e){
                     e.printStackTrace();
                 }
+            }else if(useScope==1){
+                Integer id = pointMercharsClient.add(pointsMerchandise);
             }
+        }else {
+            pointsMerchandise.setShelves(storeId);
+            pointsMerchandise.setUseScope(3);
+            Integer id = pointMercharsClient.add(pointsMerchandise);
         }
         return new SuccessTip<>();
 
@@ -516,6 +623,33 @@
         System.out.println(ofSearch);
         return pointMercharsClient.getIntegralGoodsListOfSearch(ofSearch);
     }
+    @RequestMapping(value = "/listAudit")
+    @ResponseBody
+    public Object listOfIntegralGoodsAudit(String name, Integer type, Integer redemptionMethod , Integer userPopulation, Integer activeStatus) {
+        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
+        IntegralGoodsOfSearch ofSearch = new IntegralGoodsOfSearch();
+        ofSearch.setPage(page);
+        ofSearch.setName(name);
+        ofSearch.setType(type);
+        ofSearch.setRedemptionMethod(redemptionMethod);
+        ofSearch.setUserPopulation(userPopulation);
+        ofSearch.setActiveStatus(activeStatus);
+        return pointMercharsClient.getIntegralGoodsListOfSearchAudit(ofSearch);
+    }
+
+
+
+
+
+
+
+
+    @RequestMapping(value = "/updateTypeOne")
+    @ResponseBody
+    public Object updateTypeOne(Integer id, Integer type, String remark) {
+        Object o = pointMercharsClient.updateType(id + "_" + type + "_" + remark);
+        return SUCCESS_TIP;
+    }
 
 
 
@@ -526,13 +660,21 @@
     public String tCityUpdate(@PathVariable Integer id, Model model) {
         System.out.println("id:"+id);
         PointMercharsVo pointMercharsVo = pointMercharsClient.queryPointMerchaseDetailOfId(id);
+
         System.out.println("pointMercharsVo:"+pointMercharsVo);
         String[] split = pointMercharsVo.getPics().split(",");
-        List<String> list = Arrays.asList(split);
+        StringBuilder concatenatedString = new StringBuilder();
+        for (String element : split) {
+            concatenatedString.append(element).append(",");
+        }
+        // 去除末尾的逗号
+        if (concatenatedString.length() > 0) {
+            concatenatedString.setLength(concatenatedString.length() - 1);
+        }
+        String result = concatenatedString.toString();
         model.addAttribute("id",id);
         model.addAttribute("item",pointMercharsVo);
-        model.addAttribute("pictures",list);
-        System.out.println(list);
+        model.addAttribute("pictures",result);
         return PREFIX + "TGoods_edit.html";
     }
 
@@ -566,10 +708,21 @@
     public String payOfDetails(@PathVariable(value = "id") Integer id,Model model) {
         System.out.println(id);
         model.addAttribute("id",id);
+        PointsMerchandise byId = pointMercharsClient.getById(id);
+        model.addAttribute("type",byId.getType());
         return PREFIX + "TGoods_pay.html";
     }
-
-
+    /**
+     *  购买详情
+     * @param id 商品id
+     * @return
+     */
+    @RequestMapping("/tPay_detail1/{id}")
+    public String payOfDetailsOne(@PathVariable(value = "id") Integer id,Model model) {
+        System.out.println(id);
+        model.addAttribute("id",id);
+        return PREFIX + "TGoods_payOne.html";
+    }
     /**
      * 获取 购买记录列表
      */
@@ -582,9 +735,18 @@
         payedVo.setPhone(phone);
         payedVo.setStatus(status);
         List<Map<String,Object>> points = pointMercharsClient.queryUserPayedGoodsList(payedVo);
-        System.out.println(points);
+            System.out.println(points);
         if (points.size() > 0 ){
+
             for (Map<String, Object> point : points) {
+                Object id1 = point.get("id");
+                String idAsString = String.valueOf(id1);
+
+                // 移除原始的 "id" 键
+                point.remove("id");
+
+                // 将字符串类型的 "id" 放回 Map 对象中
+                point.put("id", idAsString);
                 Integer userId = (Integer) point.get("userId");
                 TAppUser tAppUser = appUserClient.queryById(userId);
                 if (ToolUtil.isNotEmpty(tAppUser)){

--
Gitblit v1.7.1