liujie
2023-09-25 d41358fce9a436d81b9341d06fc1d8f3ddff92ff
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/TGoodsController.java
@@ -9,10 +9,12 @@
import com.dsh.course.feignClient.account.model.CityManager;
import com.dsh.course.feignClient.account.model.QueryByNamePhone;
import com.dsh.course.feignClient.account.model.TAppUser;
import com.dsh.course.feignClient.account.model.TCityManager;
import com.dsh.course.feignClient.activity.CouponClient;
import com.dsh.course.feignClient.activity.PointMercharsClient;
import com.dsh.course.feignClient.activity.model.*;
import com.dsh.guns.config.UserExt;
import com.dsh.guns.core.base.tips.ErrorTip;
import com.dsh.guns.core.base.tips.SuccessTip;
import com.dsh.guns.core.common.constant.factory.PageFactory;
import com.dsh.guns.core.util.ToolUtil;
@@ -215,23 +217,6 @@
        return storeList;
    }
//    /**
//     * 获取 优惠券管理
//     */
//    @RequestMapping(value = "/list")
//    @ResponseBody
//    public Object listOfDatas(String name, Integer type, Integer distributionMethod , Integer userPopulation, Integer status, Integer state) {
//        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
//        CouponListOfSearch ofSearch = new CouponListOfSearch();
//        ofSearch.setPage(page);
//        ofSearch.setName(name);
//        ofSearch.setType(type);
//        ofSearch.setDistributionMethod(distributionMethod);
//        ofSearch.setUserPopulation(userPopulation);
//        ofSearch.setStatus(status);
//        ofSearch.setState(state);
//        return client.getCouponListOfSearch(ofSearch);
//    }
    @RequestMapping(value = "/listRecord")
    @ResponseBody
    public Object listRecord(Integer id,String name, Integer type, String phone) {
@@ -352,4 +337,108 @@
    /**
     * 跳转到修改车辆管理
     */
    @RequestMapping("/tGoods_update/{id}")
    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(",");
        model.addAttribute("item",pointMercharsVo);
        model.addAttribute("pictures",split);
        return PREFIX + "TGoods_edit.html";
    }
    /**
     *  上下架处理操作
     * @param id 商品id
     * @param type 1=上架操作 2=下架操作
     * @return
     */
    @RequestMapping("/grounding")
    @ResponseBody
    public Object updateGrounding(Integer id,Integer type) {
        System.out.println(id);
        System.out.println(type);
        Map<String,Integer> map = new HashMap<>();
        map.put("id",id);
        map.put("type",type);
        boolean b = pointMercharsClient.updateGoodsGroudingStatus(map);
        System.out.println(b);
        return new SuccessTip<>();
    }
    /**
     *  购买详情
     * @param id 商品id
     * @return
     */
    @RequestMapping("/tPay_detail/{id}")
    public String payOfDetails(@PathVariable(value = "id") Integer id,Model model) {
        System.out.println(id);
        model.addAttribute("id",id);
        return PREFIX + "TGoods_pay.html";
    }
    /**
     * 获取 购买记录列表
     */
    @ResponseBody
    @RequestMapping(value = "/payList/{id}")
    public Object payList(@PathVariable(value = "id") Integer id, String name, String phone, Integer status) {
        PointMercharsPayedVo  payedVo = new PointMercharsPayedVo();
        payedVo.setId(id);
        payedVo.setName(name);
        payedVo.setPhone(phone);
        payedVo.setStatus(status);
        List<Map<String,Object>> points = pointMercharsClient.queryUserPayedGoodsList(payedVo);
        System.out.println(points);
        if (points.size() > 0 ){
            for (Map<String, Object> point : points) {
                Integer userId = (Integer) point.get("userId");
                TAppUser tAppUser = appUserClient.queryById(userId);
                if (ToolUtil.isNotEmpty(tAppUser)){
                    point.put("name",tAppUser.getName());
                    point.put("phone",tAppUser.getPhone());
                }
            }
            if (ToolUtil.isNotEmpty(name)){
                points = points.stream()
                        .filter(data -> {
                            String obtName = (String) data.get("name");
                            return obtName != null && obtName.contains(name);
                        })
                        .collect(Collectors.toList());
            }
            if (ToolUtil.isNotEmpty(phone)){
                points = points.stream()
                        .filter(data -> {
                            String obtPhone = (String) data.get("phone");
                            return obtPhone != null && obtPhone.contains(phone);
                        })
                        .collect(Collectors.toList());
            }
        }
        return points;
    }
    /**
     *  核销操作
     * @param id 商品id
     * @return
     */
    @RequestMapping("/write_off")
    @ResponseBody
    public Object GoodsWriteOff(Integer id){
        System.out.println(id);
        // TODO: 2023/8/15 核销操作
        return new SuccessTip<>();
    }
}