puzhibing
2023-12-08 32106f511657695e79d53e98a350ce70a36f6da1
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;
@@ -73,6 +76,8 @@
    @Autowired
    private CourseClient courseClient;
    @Autowired
    private CoursePackageClient coursePackageClient;
    @Resource
    private PointMercharsClient pointMercharsClient;
@@ -89,6 +94,7 @@
    }
    @RequestMapping("/audit")
    public String audit(Model model) {
        return PREFIX1 + "TGoodsAudit.html";
    }
@@ -137,10 +143,10 @@
            Integer coursePackageId = pointMercharsVo.getCoursePackageId();
            List<String> name = courseClient.queryPackageById(coursePackageId);
            Integer coursePackageId1 = pointMercharsVo.getCoursePackageId();
            String classHours = courseClient.getHours(coursePackageId1);
            List<CoursePackagePaymentConfig> hoursByPackageId = courseClient.getHoursByPackageId(coursePackageId1);
            model.addAttribute("typeName",name.get(0));
            model.addAttribute("pageName",name.get(1));
            model.addAttribute("classHours",classHours);
            model.addAttribute("classHours",hoursByPackageId);
            String productImages = pointMercharsVo.getProductImages();
            ArrayList<String> strings = new ArrayList<>();
            for (String s : productImages.split(",")) {
@@ -158,7 +164,7 @@
                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);
            }
@@ -410,6 +416,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<>();
@@ -444,6 +451,26 @@
                       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
    ) 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.setType(typeAll);
        pointsMerchandise.setName(name);
@@ -481,9 +508,11 @@
        pointsMerchandise.setState(1);
        pointsMerchandise.setInsertTime(new Date());
        pointsMerchandise.setCoursePackageConfigId(coursePackageConfigId);
        if(UserExt.getUser().getObjectType()!=1){
            pointsMerchandise.setStatus(2);
        }
        // 代替storeId
        pointsMerchandise.setShelves(1);
        Integer id = pointMercharsClient.add(pointsMerchandise);
        if(typeAll!=2){
            if(useScope==2){
                ArrayList<Map<String,String>> objects = new ArrayList<>();
@@ -495,11 +524,27 @@
                    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){
                if(UserExt.getUser().getObjectType()==3){
                    storeIds=UserExt.getUser().getObjectId().toString();
                }
                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;
                // 添加多个城市 门店
                try{
@@ -508,7 +553,15 @@
                }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<>();
@@ -571,13 +624,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";
    }
@@ -611,6 +672,8 @@
    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";
    }
    /**