wuxw
2024-07-18 1a8c34b90bdad9dd7f18fff2cf2a6c7b60151b6d
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.java110.job.smo.impl;
 
 
import com.alibaba.fastjson.JSONObject;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.core.log.LoggerFactory;
import com.java110.dto.MallDataDto;
import com.java110.dto.integral.DeductionIntegralDto;
import com.java110.dto.integral.GiftIntegralDto;
import com.java110.dto.mall.MallConfigDto;
import com.java110.dto.user.UserDto;
import com.java110.intf.job.IMallInnerServiceSMO;
import com.java110.job.adapt.hcIot.IotConstant;
import com.java110.job.adapt.hcIotNew.http.ISendIot;
import com.java110.job.mall.ISendMall;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 定时任务属性内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class MallInnerServiceSMOImpl extends BaseServiceSMO implements IMallInnerServiceSMO {
    private static final Logger logger = LoggerFactory.getLogger(MallInnerServiceSMOImpl.class);
 
    private static final String MALL_DOMAIN = "MALL";
 
 
    @Autowired
    private ISendMall sendMallImpl;
 
 
    @Override
    public ResultVo postMall(@RequestBody JSONObject paramIn) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
 
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        return resultVo;
    }
 
    @Override
    public ResultVo postMallData(@RequestBody MallDataDto mallDataDto) {
 
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
 
 
        JSONObject paramIn = mallDataDto.getData();
        paramIn.put("mallApiCode", mallDataDto.getMallApiCode());
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        return resultVo;
    }
 
    @Override
    public String generatorMallCode(@RequestBody UserDto userDto) {
 
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            throw new IllegalArgumentException("未部署商城系统");
        }
 
        JSONObject paramIn = new JSONObject();
        paramIn.put("userId", userDto.getUserId());
        paramIn.put("tel", userDto.getTel());
        paramIn.put("passwd", userDto.getPassword());
        paramIn.put("userName", userDto.getName());
        paramIn.put("address", userDto.getAddress());
 
        ResultVo resultVo = sendMallImpl.post("/mall/api/token.generatorCode", paramIn);
 
        if (resultVo.getCode() != ResultVo.CODE_OK) {
            throw new IllegalArgumentException(resultVo.getMsg());
        }
 
        return resultVo.getData().toString();
    }
 
    @Override
    public ResultVo sendUserInfo(@RequestBody UserDto userDto) {
 
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
 
        JSONObject paramIn = new JSONObject();
        paramIn.put("userId", userDto.getUserId());
        paramIn.put("tel", userDto.getTel());
        paramIn.put("passwd", userDto.getPassword());
        paramIn.put("userName", userDto.getName());
        paramIn.put("address", userDto.getAddress());
 
        ResultVo resultVo = sendMallImpl.post("/mall/api/token.generatorCode", paramIn);
 
        return resultVo;
    }
 
    @Override
    public double computeIntegralMoney(@RequestBody int quantity) {
 
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return 0;
        }
 
 
        JSONObject paramIn = new JSONObject();
        paramIn.put("quantity", quantity);
        paramIn.put("mallApiCode", "computeIntegralMoneyBmoImpl");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
        if (resultVo.getCode() != ResultVo.CODE_OK) {
            throw new IllegalArgumentException(resultVo.getMsg());
        }
        return Double.parseDouble(resultVo.getData().toString());
    }
 
    @Override
    public ResultVo sendUserIntegral(@RequestBody GiftIntegralDto giftIntegralDto) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
 
 
        JSONObject paramIn = new JSONObject();
        paramIn.put("link", giftIntegralDto.getLink());
        paramIn.put("integral", giftIntegralDto.getIntegral());
        paramIn.put("orderId", giftIntegralDto.getOrderId());
 
        paramIn.put("remark", giftIntegralDto.getRemark());
 
        paramIn.put("mallApiCode", "sendIntegralToUserBmoImpl");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
 
        return resultVo;
    }
 
    @Override
    public ResultVo userIntegralToCommunity(@RequestBody DeductionIntegralDto deductionIntegralDto) {
 
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return new ResultVo(ResultVo.CODE_OK, ResultVo.MSG_OK);
        }
 
        JSONObject paramIn = new JSONObject();
        paramIn.put("link", deductionIntegralDto.getLink());
        paramIn.put("integral", deductionIntegralDto.getIntegral());
        paramIn.put("communityId", deductionIntegralDto.getCommunityId());
 
        paramIn.put("remark", deductionIntegralDto.getRemark());
 
        paramIn.put("mallApiCode", "userIntegralToCommunity");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
 
        return resultVo;
    }
 
    @Override
    public MallConfigDto getMallConfig(MallConfigDto mallConfigDto) {
        String mallSwitch = MappingCache.getValue(MALL_DOMAIN, "MALL_SWITCH");
 
        if (!"ON".equals(mallSwitch)) {
            return mallConfigDto;
        }
 
 
        JSONObject paramIn = BeanConvertUtil.beanCovertJson(mallConfigDto);
 
        paramIn.put("mallApiCode", "getMallConfig");
        ResultVo resultVo = sendMallImpl.post("/mall/api/common.openCommonApi", paramIn);
 
        if(resultVo.getCode() != 0){
            throw new IllegalArgumentException(resultVo.getMsg());
        }
        mallConfigDto = BeanConvertUtil.covertBean(resultVo.getData(),MallConfigDto.class);
        return mallConfigDto;
    }
 
}