shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.ishop.mobile.api;
 
import com.iplatform.base.Constants;
import com.ishop.mobile.BaseApi;
import com.ishop.mobile.util.VoUtils;
import com.ishop.model.po.EbMerchant;
import com.ishop.model.po.EbMerchantInfo;
import com.ishop.model.vo.MerchantDetailVo;
import com.ishop.model.vo.MerchantIndexVo;
import com.ishop.model.vo.ProductCategoryVo;
import com.walker.web.ResponseValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
@RequestMapping("/front/merchant")
public class MerchantApi extends BaseApi {
 
    /**
     * 店铺详细信息
     * @return
     * @date 2023-07-05
     */
    @RequestMapping(value = "/detail/{id}", method = RequestMethod.GET)
    public ResponseValue getDetail(@PathVariable Integer id){
        if(id == null || id.intValue() <= 0){
            return ResponseValue.error(Constants.ERROR_ARGUMENT);
        }
        EbMerchant merchant = this.getMerchantCache().get(id);
        if(merchant == null){
            return ResponseValue.error("商户不存在");
        }
        if(merchant.getIsSwitch().intValue() == 0){
            return ResponseValue.error("商户未营业");
        }
        MerchantDetailVo detailVo = VoUtils.acquireMerchantDetailVo(merchant);
        EbMerchantInfo merchantInfo = this.getMerchantService().queryMerchantInfo(id);
        VoUtils.combineMerchantInfo(detailVo, merchantInfo);
//        detailVo.setFollowerNum(userMerchantCollectService.getCountByMerId(merchant.getId()));
//        detailVo.setIsCollect(userMerchantCollectService.isCollect(userId, merchant.getId()));
        detailVo.setFollowerNum(0);
        detailVo.setIsCollect(false);
        return ResponseValue.success(detailVo);
    }
 
    /**
     * 店铺首页信息
     * @param id
     * @return
     * @date 2023-07-04
     */
    @RequestMapping(value = "/index/info/{id}", method = RequestMethod.GET)
    public ResponseValue getIndexInfo(@PathVariable Integer id){
        if(id == null){
            throw new IllegalArgumentException("id is required!");
        }
        EbMerchant merchant = this.getMerchantCache().get(id);
        if(merchant == null){
            return ResponseValue.error("商户不存在");
        }
        if (merchant.getIsSwitch().intValue() == 0) {
            return ResponseValue.error("商户未营业");
        }
        MerchantIndexVo vo = VoUtils.acquireMerchantIndexVo(merchant, this.getCdnUrl());
        EbMerchantInfo merchantInfo = this.getMerchantService().queryMerchantInfo(id);
        vo.setServiceType(merchantInfo.getServiceType());
        vo.setServiceLink(merchantInfo.getServiceLink());
        vo.setServicePhone(merchantInfo.getServicePhone());
//        if (userId > 0) {
//            response.setIsCollect(userMerchantCollectService.isCollect(userId, merchant.getId()));
//            // 商品浏览量统计(每日/个体)
//            String dateStr = DateUtil.date().toString(DateConstants.DATE_FORMAT_DATE);
//            redisUtil.incrAndCreate(StrUtil.format(RedisConstants.MERCHANT_VISITORS_KEY, dateStr, merchant.getId()));
//        }
        return ResponseValue.success(vo);
    }
 
    /**
     * 获取商户客服信息
     * @param id
     * @return
     * @date 2023-07-04
     */
    @RequestMapping(value = "/customer/service/info/{id}", method = RequestMethod.GET)
    public ResponseValue getCustomerServiceInfo(@PathVariable("id") Integer id){
        if(id == null){
            throw new IllegalArgumentException("id is required!");
        }
        EbMerchant merchant = this.getMerchantCache().get(id);
        if(merchant == null){
            return ResponseValue.error("商户不存在");
        }
        EbMerchantInfo info = this.getMerchantService().queryMerchantInfo(id);
        return ResponseValue.success(VoUtils.acquireMerchantServiceInfoVo(info));
    }
 
    /**
     * 商户商品分类缓存树
     * @param id 商户ID
     * @return
     * @date 2023-07-05
     */
    @RequestMapping(value = "/product/category/cache/tree/{id}", method = RequestMethod.GET)
    public ResponseValue getCacheTree(@PathVariable("id") Integer id){
        List<ProductCategoryVo> listTree = this.getMerProductCategoryCache().getTree(String.valueOf(id));
        return ResponseValue.success(listTree);
    }
 
//    @ApiOperation(value = "获取全部商户类型列表")
    @RequestMapping(value = "/all/type/list", method = RequestMethod.GET)
    public ResponseValue allTypeList(){
        return ResponseValue.success(this.getMerchantTypeCache().getList());
    }
 
//    @ApiOperation(value = "获取全部商户分类列表")
    @RequestMapping(value = "/all/category/list", method = RequestMethod.GET)
    public ResponseValue allCategoryList(){
        return ResponseValue.success(this.getMerchantCategoryCache().getList());
    }
}