提交 | 用户 | age
|
a6a76f
|
1 |
package com.yc.api.controller; |
F |
2 |
|
f10e31
|
3 |
import com.alibaba.fastjson.JSON; |
a6a76f
|
4 |
import com.yc.action.BaseAction; |
9846ef
|
5 |
import com.yc.action.grid.GTGrid; |
a6a76f
|
6 |
import com.yc.action.grid.GridUtils; |
F |
7 |
import com.yc.api.bean.CartEntity; |
|
8 |
import com.yc.api.bean.MatGroupEntity; |
|
9 |
import com.yc.api.bean.*; |
|
10 |
import com.yc.api.service.QrServiceIfc; |
|
11 |
import com.yc.entity.DataSourceEntity; |
|
12 |
import com.yc.exception.ApplicationException; |
|
13 |
import com.yc.exception.CallBackMessage; |
|
14 |
import com.yc.factory.FactoryBean; |
|
15 |
import com.yc.multiData.MultiDataSource; |
|
16 |
import com.yc.multiData.SpObserver; |
f10e31
|
17 |
import com.yc.open.mutual.controller.MutualController; |
565fe8
|
18 |
import com.yc.sdk.jedis.RedisKey; |
a6a76f
|
19 |
import com.yc.sdk.shopping.action.api.ShopCcCode; |
F |
20 |
import com.yc.sdk.shopping.entity.*; |
|
21 |
import com.yc.sdk.shopping.service.*; |
|
22 |
import com.yc.sdk.shopping.service.PrepaidDeposit.PrepaidDepositIfc; |
|
23 |
import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc; |
|
24 |
import com.yc.sdk.shopping.service.register.AccountIfc; |
|
25 |
import com.yc.sdk.shopping.service.share.ShareIfc; |
|
26 |
import com.yc.sdk.shopping.util.HtmlUtil; |
|
27 |
import com.yc.sdk.shopping.util.SettingKey; |
|
28 |
import com.yc.service.BaseService; |
|
29 |
import com.yc.service.grid.GridServiceIfc; |
|
30 |
import com.yc.utils.SessionKey; |
7f8ca8
|
31 |
import org.apache.commons.lang.text.StrBuilder; |
a6a76f
|
32 |
import org.apache.commons.lang3.StringUtils; |
F |
33 |
import org.slf4j.Logger; |
|
34 |
import org.slf4j.LoggerFactory; |
035b76
|
35 |
import org.springframework.beans.BeanUtils; |
a6a76f
|
36 |
import org.springframework.beans.factory.annotation.Autowired; |
F |
37 |
import org.springframework.dao.EmptyResultDataAccessException; |
565fe8
|
38 |
import org.springframework.data.redis.core.RedisTemplate; |
a9a8e7
|
39 |
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
a6a76f
|
40 |
import org.springframework.transaction.annotation.Transactional; |
F |
41 |
import org.springframework.web.bind.annotation.*; |
a9a8e7
|
42 |
import org.springframework.web.context.request.async.WebAsyncTask; |
a6a76f
|
43 |
|
F |
44 |
import javax.servlet.http.HttpServletRequest; |
|
45 |
import javax.servlet.http.HttpServletResponse; |
|
46 |
import javax.servlet.http.HttpSession; |
|
47 |
import java.util.*; |
a9a8e7
|
48 |
import java.util.concurrent.Callable; |
F |
49 |
import java.util.concurrent.TimeUnit; |
a6a76f
|
50 |
import java.util.regex.Matcher; |
F |
51 |
import java.util.regex.Pattern; |
|
52 |
import java.util.stream.Collectors; |
|
53 |
|
|
54 |
|
|
55 |
/** |
|
56 |
* 扫码 |
|
57 |
*/ |
|
58 |
@RestController |
|
59 |
public class QrCodeController extends BaseAction { |
|
60 |
protected final Logger log = LoggerFactory.getLogger(this.getClass()); |
|
61 |
@Autowired |
|
62 |
CartIfc cartIfc; |
|
63 |
@Autowired |
|
64 |
QrServiceIfc qrServiceIfc; |
|
65 |
@Autowired |
|
66 |
ShoppingImageDataIfc imgData; |
|
67 |
@Autowired |
|
68 |
SettingIfc settingIfc; |
|
69 |
|
|
70 |
// 价格 |
|
71 |
@Autowired |
|
72 |
MatPriceIfc matPriceIfc; |
|
73 |
|
|
74 |
// 货币 |
|
75 |
@Autowired |
|
76 |
CurrencyIfc currencyIfc; |
|
77 |
|
|
78 |
// 商品资料 |
|
79 |
@Autowired |
|
80 |
MatCodeIfc matCodeIfc; |
|
81 |
|
|
82 |
// 商品附加图片信息 |
|
83 |
@Autowired |
|
84 |
MatCodeImageIfc matCodeImageIfc; |
|
85 |
|
|
86 |
// 商品选项 |
|
87 |
@Autowired |
|
88 |
MatOptionIfc matOptionIfc; |
|
89 |
|
|
90 |
|
|
91 |
// 消费积份 |
|
92 |
@Autowired |
|
93 |
MatPointsIfc matPointsIfc; |
|
94 |
|
|
95 |
// 商品促销活动关联表 |
|
96 |
@Autowired |
|
97 |
MatDiscountIfc matDiscountIfc; |
|
98 |
|
|
99 |
// 选项 |
|
100 |
@Autowired |
|
101 |
MatComponentIfc matComponentIfc; |
|
102 |
|
|
103 |
// 显示分享信息 |
|
104 |
@Autowired |
|
105 |
ShareIfc shareIfc; |
|
106 |
|
|
107 |
// 选项属性 |
|
108 |
@Autowired |
|
109 |
MatAttrIfc matAttrIfc; |
|
110 |
//优惠劵 |
|
111 |
@Autowired |
|
112 |
CouponIfc couponIfc; |
|
113 |
|
|
114 |
//预付订金分组 |
|
115 |
@Autowired |
|
116 |
PrepaidDepositIfc prepaidDepositIfc; |
|
117 |
|
|
118 |
@Autowired |
|
119 |
AccountIfc accountIfc; |
|
120 |
@Autowired |
|
121 |
private GridServiceIfc gridService; |
a9a8e7
|
122 |
@Autowired |
F |
123 |
ThreadPoolTaskExecutor threadPoolExecutor; |
87daf8
|
124 |
@Autowired |
F |
125 |
ShoppingImageDataIfc shoppingImageDataIfc; |
a6a76f
|
126 |
|
F |
127 |
/** |
|
128 |
* 获取清单 |
|
129 |
* |
|
130 |
* @param request |
|
131 |
* @param response |
|
132 |
*/ |
|
133 |
@RequestMapping(value = "/qr/cartList.do", method = RequestMethod.GET) |
|
134 |
@CrossOrigin |
|
135 |
public @ResponseBody |
|
136 |
Object getCartList(String docCode, HttpServletRequest request, HttpServletResponse response) { |
|
137 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
138 |
try { |
ce46b2
|
139 |
String dbid=request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""; |
F |
140 |
SpObserver.setDBtoInstance("_" +dbid ); |
|
141 |
String hostUrl = SettingKey.getHostUrlForImage(request); |
a6a76f
|
142 |
final List<com.yc.api.bean.CartEntity> cartList = qrServiceIfc.getCartList(request.getSession().getAttribute(SessionKey.USERCODE) + "", docCode); |
ce46b2
|
143 |
// cartList.stream().map(x -> { |
F |
144 |
// x.setPhotoPath(imgData.getImageUrl(x.getPhotoPath(), 120, |
|
145 |
// 120, false, |
|
146 |
// false, request)); |
|
147 |
// return x; |
|
148 |
// }).collect(Collectors.toList()); |
|
149 |
cartList.stream().forEach(x -> { |
|
150 |
x.setPhotoPath(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
151 |
x.setPhotoPathUrl(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
152 |
}); |
035b76
|
153 |
//合并相同商品,输出一个 |
F |
154 |
final List<com.yc.api.bean.CartEntity> newCartList = new ArrayList<>(); |
|
155 |
String matCode=""; |
|
156 |
Iterator<CartEntity> iterator = cartList.iterator(); |
|
157 |
while (iterator.hasNext()) { |
|
158 |
CartEntity cartEntity = iterator.next(); |
|
159 |
com.yc.api.bean.CartEntity cart=new com.yc.api.bean.CartEntity(); |
|
160 |
BeanUtils.copyProperties(cartEntity,cart); |
|
161 |
double totalAmount=StringUtils.isNotBlank(cart.getAmount())?Double.parseDouble(cart.getAmount()):0;//合并总价 |
|
162 |
double totalQuantity=cart.getQuantity();//合并数量 |
|
163 |
iterator.remove(); |
|
164 |
if(!matCode.equalsIgnoreCase(cart.getMatCode())) { |
|
165 |
matCode=cart.getMatCode(); |
|
166 |
Iterator<CartEntity> iterator2 = cartList.iterator(); |
|
167 |
while (iterator2.hasNext()) { |
|
168 |
CartEntity cartEntity2 = iterator2.next(); |
|
169 |
if (cart.getMatCode().equalsIgnoreCase(cartEntity2.getMatCode())) { |
|
170 |
totalAmount += Double.parseDouble(cartEntity2.getAmount()); |
|
171 |
totalQuantity += cartEntity2.getQuantity(); |
|
172 |
} |
|
173 |
} |
|
174 |
cart.setAmount(totalAmount + ""); |
|
175 |
cart.setQuantity(totalQuantity); |
|
176 |
newCartList.add(cart); |
|
177 |
} |
|
178 |
} |
a6a76f
|
179 |
//List<Gfrom> refFormIdList = getRefFormIdList(request, refFormid); |
F |
180 |
Map map = new HashMap(); |
035b76
|
181 |
map.put("carts", newCartList); |
a6a76f
|
182 |
//map.put("refFormids", refFormIdList); |
F |
183 |
|
|
184 |
callBackMessage.setInfo(map); |
|
185 |
callBackMessage.sendSuccessMessage("成功"); |
|
186 |
return callBackMessage.toJSONObject(); |
|
187 |
|
|
188 |
} catch (Exception ex) { |
|
189 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
190 |
return callBackMessage.toJSONObject(); |
|
191 |
} finally { |
|
192 |
SpObserver.setDBtoInstance(); |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* 删除 |
|
198 |
* |
|
199 |
* @param request |
|
200 |
* @param response |
|
201 |
*/ |
|
202 |
@Transactional |
|
203 |
@RequestMapping(value = "/qr/delCart.do", method = RequestMethod.GET) |
|
204 |
@CrossOrigin |
|
205 |
public @ResponseBody |
4bd49a
|
206 |
WebAsyncTask delCart(String idList, HttpServletRequest request, HttpServletResponse response) { |
F |
207 |
String userCode = request.getSession().getAttribute(SessionKey.HRCODE) + ""; |
|
208 |
String userName = request.getSession().getAttribute(SessionKey.HRNAME) + ""; |
87daf8
|
209 |
Callable<Object> callable = new CartCallable(null, null, idList, userCode, userName, request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "", qrServiceIfc, 3); |
4bd49a
|
210 |
//定义超时45秒 |
F |
211 |
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(45), threadPoolExecutor, callable); |
|
212 |
asyncTask.onCompletion( |
|
213 |
() -> log.info("执行成功") |
|
214 |
); |
|
215 |
asyncTask.onError( |
|
216 |
(Callable<Object>) () -> { |
|
217 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
218 |
log.info("执行出错"); |
|
219 |
callBackMessage.sendErrorMessage("操作出错"); |
|
220 |
return callBackMessage.toJSONObject(); |
|
221 |
} |
|
222 |
); |
|
223 |
asyncTask.onTimeout( |
|
224 |
(Callable<Object>) () -> { |
|
225 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
226 |
log.info("执行超时"); |
|
227 |
callBackMessage.sendErrorMessage("服务器繁忙,正在排队处理,请不要重复提交,稍后请在购物车查看结果", -1003); |
|
228 |
return callBackMessage.toJSONObject(); |
|
229 |
} |
|
230 |
); |
|
231 |
return asyncTask; |
a6a76f
|
232 |
} |
F |
233 |
|
|
234 |
/** |
|
235 |
* 立即下单 |
|
236 |
* |
|
237 |
* @param request |
|
238 |
* @param response |
|
239 |
*/ |
|
240 |
@Transactional |
|
241 |
@RequestMapping(value = "/qr/postCarts.do", method = RequestMethod.POST) |
|
242 |
@CrossOrigin |
|
243 |
public @ResponseBody |
4bd49a
|
244 |
WebAsyncTask postCarts(@RequestBody PostCartEntity postCartEntity, HttpServletRequest request, HttpServletResponse response) { |
F |
245 |
String userCode = request.getSession().getAttribute(SessionKey.HRCODE) + ""; |
|
246 |
String userName = request.getSession().getAttribute(SessionKey.HRNAME) + ""; |
|
247 |
log.info("---------------------start:" + userCode + "-----------------"); |
87daf8
|
248 |
Callable<Object> callable = new T120201Callable(postCartEntity, userCode, userName, request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "", qrServiceIfc, 1); |
4bd49a
|
249 |
//定义超时45秒 |
F |
250 |
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(45), threadPoolExecutor, callable); |
|
251 |
asyncTask.onCompletion( |
|
252 |
() -> log.info("执行成功") |
|
253 |
); |
|
254 |
asyncTask.onError( |
|
255 |
(Callable<Object>) () -> { |
|
256 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
257 |
log.info("执行出错"); |
|
258 |
callBackMessage.sendErrorMessage("执行出错,请重新下单"); |
|
259 |
return callBackMessage.toJSONObject(); |
a6a76f
|
260 |
} |
4bd49a
|
261 |
); |
F |
262 |
asyncTask.onTimeout( |
|
263 |
(Callable<Object>) () -> { |
|
264 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
265 |
log.info("执行超时"); |
|
266 |
callBackMessage.sendErrorMessage("服务器繁忙,正在排队处理,请不要重复提交,稍后请在【销售管理】-【销售订单】-【查询订单进度表】中查看结果", -1003); |
|
267 |
return callBackMessage.toJSONObject(); |
|
268 |
} |
|
269 |
); |
|
270 |
return asyncTask; |
a6a76f
|
271 |
} |
F |
272 |
|
|
273 |
/** |
|
274 |
* 在购物车通过多选物料生成单据 |
|
275 |
* |
|
276 |
* @param postCartEntity 用;分隔的多个cartid |
|
277 |
* @param request |
|
278 |
* @param response |
|
279 |
*/ |
|
280 |
@RequestMapping(value = "/qr/createPost.do", method = RequestMethod.POST) |
|
281 |
@CrossOrigin |
|
282 |
public @ResponseBody |
a9a8e7
|
283 |
WebAsyncTask cartPost(@RequestBody PostCartEntity postCartEntity, HttpServletRequest request, HttpServletResponse response) { |
4bd49a
|
284 |
String userCode = request.getSession().getAttribute(SessionKey.HRCODE) + ""; |
F |
285 |
String userName = request.getSession().getAttribute(SessionKey.HRNAME) + ""; |
|
286 |
log.info("---------------------start:" + userCode + "-----------------"); |
87daf8
|
287 |
Callable<Object> callable = new T120201Callable(postCartEntity, userCode, userName, request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "", qrServiceIfc, 0); |
a9a8e7
|
288 |
//定义超时45秒 |
F |
289 |
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(45), threadPoolExecutor, callable); |
|
290 |
asyncTask.onCompletion( |
|
291 |
() -> log.info("执行成功") |
|
292 |
); |
|
293 |
asyncTask.onError( |
|
294 |
(Callable<Object>) () -> { |
|
295 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
296 |
log.info("执行出错"); |
|
297 |
callBackMessage.sendErrorMessage("执行出错,请重新下单"); |
|
298 |
return callBackMessage.toJSONObject(); |
|
299 |
} |
|
300 |
); |
|
301 |
asyncTask.onTimeout( |
|
302 |
(Callable<Object>) () -> { |
|
303 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
304 |
log.info("执行超时"); |
|
305 |
callBackMessage.sendErrorMessage("服务器繁忙,正在排队处理,请不要重复提交,稍后请在【销售管理】-【销售订单】-【查询订单进度表】中查看结果", -1003); |
|
306 |
return callBackMessage.toJSONObject(); |
|
307 |
} |
|
308 |
); |
|
309 |
return asyncTask; |
|
310 |
} |
87daf8
|
311 |
|
a9a8e7
|
312 |
private class T120201Callable implements Callable<Object> { |
F |
313 |
PostCartEntity postCartEntity; |
4bd49a
|
314 |
String userCode; |
a9a8e7
|
315 |
String dbid; |
F |
316 |
QrServiceIfc qrServiceIfc; |
87daf8
|
317 |
int actionType = 0;//0 表示从购物车下单,1 表示立即下单 |
4bd49a
|
318 |
String userName; |
a6a76f
|
319 |
|
87daf8
|
320 |
public T120201Callable(PostCartEntity postCartEntity, String userCode, String userName, String dbid, QrServiceIfc qrServiceIfc, int actionType) { |
a9a8e7
|
321 |
this.postCartEntity = postCartEntity; |
4bd49a
|
322 |
this.userCode = userCode; |
a9a8e7
|
323 |
this.dbid = dbid; |
F |
324 |
this.qrServiceIfc = qrServiceIfc; |
87daf8
|
325 |
this.actionType = actionType; |
F |
326 |
this.userName = userName; |
a9a8e7
|
327 |
} |
87daf8
|
328 |
|
F |
329 |
private String joinCartSql() { |
|
330 |
final List<CartEntity> carts = postCartEntity.getCarts(); |
|
331 |
StrBuilder sb = new StrBuilder(); |
|
332 |
if (carts != null && carts.size() > 0) { |
|
333 |
//声明变量 |
|
334 |
sb.append(" declare @CartId varchar(800) \n"); |
|
335 |
if (postCartEntity.getIsSaveAll() == 1) { |
|
336 |
//先清空购物车 |
|
337 |
sb.append(" delete from t710205 where UserCode =" + GridUtils.prossSqlParm(postCartEntity.getUserCode())); |
|
338 |
} |
|
339 |
for (CartEntity cartEntity : carts) { |
|
340 |
sb.append(" insert into t710205 (UserCode,UserName,CltCode,CltName,MatCode,MatName,Special,PhotoPath, \n") |
|
341 |
.append(" Quantity,Price,Amount,WeightUom,DateAdded,VoucherDocCode,\n") |
ea72e1
|
342 |
.append(" refDocCode,refFormId,refFormType,refRowId,isSelected,MatGroupStatus,SalesPrice,Discount,ManualPrice,skuId1,skuName1,skuId2,skuName2,skuId3,skuName3,skuId4,skuName4,skuId5,skuName5,skuId6,skuName6,skuId7,skuName7,skuId8,skuName8,skuId9,skuName9,skuId10,skuName10) \n") |
F |
343 |
.append(" values(" + GridUtils.prossSqlParm(postCartEntity.getUserCode()) + "," + GridUtils.prossSqlParm(userName) + "," + GridUtils.prossSqlParm(postCartEntity.getCltCode()) + "," + GridUtils.prossSqlParm(postCartEntity.getCltName()) + "," + GridUtils.prossSqlParm(cartEntity.getMatCode()) + "," + GridUtils.prossSqlParm(cartEntity.getMatName()) + "," + GridUtils.prossSqlParm(cartEntity.getSpecial()) + " ," + GridUtils.prossSqlParm(cartEntity.getPhotoPath()) + "," + cartEntity.getQuantity() + "," + cartEntity.getPrice() + ",round(isnull("+cartEntity.getQuantity()+",0) * isnull("+cartEntity.getManualPrice()+",0),2),null,getdate(),null," + GridUtils.prossSqlParm(postCartEntity.getRefDocCode()) + "," + postCartEntity.getRefFormId() + "," + postCartEntity.getRefFormType() + "," + GridUtils.prossSqlParm(postCartEntity.getRefRowId()) + ",1,1," + cartEntity.getSalesPrice() + "," + cartEntity.getDiscount() +"," + cartEntity.getManualPrice()+"," + cartEntity.getSkuId1()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName1())+"," + cartEntity.getSkuId2()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName2())+"," + cartEntity.getSkuId3()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName3())+"," + cartEntity.getSkuId4()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName4())+"," + cartEntity.getSkuId5()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName5())+"," + cartEntity.getSkuId6()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName6())+"," + cartEntity.getSkuId7()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName7())+"," + cartEntity.getSkuId8()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName8())+"," + cartEntity.getSkuId9()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName9())+"," + cartEntity.getSkuId10()+"," +GridUtils.prossSqlParm(cartEntity.getSkuName10()) + ")\n") |
87daf8
|
344 |
.append(" SELECT @CartId =isnull(@CartId,'')+cast(@@IDENTITY as varchar) +','; \n"); |
F |
345 |
} |
|
346 |
sb.append(" select @CartId=left(@cartId,len(@cartId)-1) \n"); |
|
347 |
} |
|
348 |
return sb.toString(); |
7f8ca8
|
349 |
} |
87daf8
|
350 |
|
a9a8e7
|
351 |
@Override |
F |
352 |
public Object call() throws Exception { |
|
353 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
354 |
long startTime = System.currentTimeMillis(); |
|
355 |
try { |
|
356 |
SpObserver.setDBtoInstance("_" + dbid); |
87daf8
|
357 |
String cartids = null; |
F |
358 |
String cartSql = null; |
7f8ca8
|
359 |
postCartEntity.setUserCode(userCode); |
0d7208
|
360 |
Map map = null; |
F |
361 |
if (dbid.equals("530")) { |
|
362 |
//卤江南专用 |
|
363 |
map = qrServiceIfc.save120201(postCartEntity, userCode); |
87daf8
|
364 |
} else { |
0d7208
|
365 |
if (actionType == 1) { |
F |
366 |
if (postCartEntity == null || postCartEntity.getCarts() == null || postCartEntity.getCarts().size() == 0) { |
|
367 |
throw new ApplicationException("没有商品,不能下单"); |
|
368 |
} |
|
369 |
if (postCartEntity.getFormId() == null) { |
|
370 |
throw new ApplicationException("生成单据所对应目标功能号不能为空"); |
|
371 |
} |
|
372 |
cartSql = joinCartSql(); |
|
373 |
} else { |
|
374 |
//在购物车下单,直接取carid |
|
375 |
cartids = postCartEntity.getCartids(); |
|
376 |
} |
|
377 |
map = qrServiceIfc.savePost(postCartEntity, cartids, userCode, cartSql); |
|
378 |
if (map != null) { |
|
379 |
postCartEntity.setCartids(map.get("cartIds") + ""); |
|
380 |
final Integer result = qrServiceIfc.delCart(postCartEntity); |
|
381 |
map.remove("cartIds"); |
|
382 |
map.put("delable", result == -1 ? 1 : 0); |
|
383 |
} |
a9a8e7
|
384 |
} |
87daf8
|
385 |
if (map == null || StringUtils.isBlank(GridUtils.prossRowSetDataType_String(map, "docCode"))) { |
4bd49a
|
386 |
throw new ApplicationException(postCartEntity.getFormId() + "生成单据出错:单号为空"); |
F |
387 |
} |
|
388 |
log.info("cltCode:" + userCode + "-客户:" + userCode + "下单花费:" + (System.currentTimeMillis() - startTime)); |
a9a8e7
|
389 |
callBackMessage.setInfo(map); |
F |
390 |
callBackMessage.sendSuccessMessageByDefault(); |
|
391 |
return callBackMessage.toJSONObject(); |
|
392 |
} catch (Exception ex) { |
4bd49a
|
393 |
log.info("cltCode:" + userCode + "-客户下单出错:" + userCode + "花费:" + (System.currentTimeMillis() - startTime)); |
a9a8e7
|
394 |
callBackMessage.sendErrorMessage(ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage()); |
F |
395 |
return callBackMessage.toJSONObject(); |
|
396 |
} finally { |
|
397 |
SpObserver.setDBtoInstance(); |
4bd49a
|
398 |
log.info("---------------------end:" + userCode + "-----------------"); |
a9a8e7
|
399 |
} |
a6a76f
|
400 |
} |
F |
401 |
} |
87daf8
|
402 |
|
a6a76f
|
403 |
/** |
F |
404 |
* 新增 |
|
405 |
* |
|
406 |
* @param request |
|
407 |
* @param response |
|
408 |
*/ |
|
409 |
|
|
410 |
@RequestMapping(value = "/qr/addCart.do", method = RequestMethod.POST) |
|
411 |
@CrossOrigin |
|
412 |
public @ResponseBody |
4bd49a
|
413 |
WebAsyncTask addCart(@RequestBody PostCartEntity postCartEntity, HttpServletRequest request, HttpServletResponse response) { |
F |
414 |
|
|
415 |
String userCode = request.getSession().getAttribute(SessionKey.HRCODE) + ""; |
|
416 |
String userName = request.getSession().getAttribute(SessionKey.HRNAME) + ""; |
|
417 |
postCartEntity.setUserCode(userCode); |
87daf8
|
418 |
Callable<Object> callable = new CartCallable(postCartEntity, null, null, userCode, userName, request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "", qrServiceIfc, 1); |
4bd49a
|
419 |
//定义超时45秒 |
F |
420 |
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(45), threadPoolExecutor, callable); |
|
421 |
asyncTask.onCompletion( |
|
422 |
() -> log.info("执行成功") |
|
423 |
); |
|
424 |
asyncTask.onError( |
|
425 |
(Callable<Object>) () -> { |
|
426 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
427 |
log.info("执行出错"); |
|
428 |
callBackMessage.sendErrorMessage("操作出错"); |
|
429 |
return callBackMessage.toJSONObject(); |
|
430 |
} |
|
431 |
); |
|
432 |
asyncTask.onTimeout( |
|
433 |
(Callable<Object>) () -> { |
|
434 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
435 |
log.info("执行超时"); |
|
436 |
callBackMessage.sendErrorMessage("服务器繁忙,正在排队处理,请不要重复提交,稍后请在购物车查看结果", -1003); |
|
437 |
return callBackMessage.toJSONObject(); |
|
438 |
} |
|
439 |
); |
|
440 |
return asyncTask; |
|
441 |
} |
87daf8
|
442 |
|
5f16b6
|
443 |
/** |
F |
444 |
* 保存购物车商品 |
|
445 |
* |
|
446 |
* @param request |
|
447 |
* @param response |
|
448 |
*/ |
|
449 |
|
|
450 |
@RequestMapping(value = "/qr/saveAllCart.do", method = RequestMethod.POST) |
|
451 |
@CrossOrigin |
|
452 |
public @ResponseBody |
|
453 |
WebAsyncTask saveAllCart(@RequestBody PostCartEntity postCartEntity, HttpServletRequest request, HttpServletResponse response) { |
|
454 |
|
|
455 |
String userCode = request.getSession().getAttribute(SessionKey.HRCODE) + ""; |
|
456 |
String userName = request.getSession().getAttribute(SessionKey.HRNAME) + ""; |
|
457 |
postCartEntity.setUserCode(userCode); |
|
458 |
postCartEntity.setIsSaveAll(1); |
87daf8
|
459 |
Callable<Object> callable = new CartCallable(postCartEntity, null, null, userCode, userName, request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "", qrServiceIfc, 4); |
5f16b6
|
460 |
//定义超时45秒 |
F |
461 |
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(45), threadPoolExecutor, callable); |
|
462 |
asyncTask.onCompletion( |
|
463 |
() -> log.info("执行成功") |
|
464 |
); |
|
465 |
asyncTask.onError( |
|
466 |
(Callable<Object>) () -> { |
|
467 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
468 |
log.info("执行出错"); |
|
469 |
callBackMessage.sendErrorMessage("操作出错"); |
|
470 |
return callBackMessage.toJSONObject(); |
|
471 |
} |
|
472 |
); |
|
473 |
asyncTask.onTimeout( |
|
474 |
(Callable<Object>) () -> { |
|
475 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
476 |
log.info("执行超时"); |
|
477 |
callBackMessage.sendErrorMessage("服务器繁忙,正在排队处理,请不要重复提交,稍后请在购物车查看结果", -1003); |
|
478 |
return callBackMessage.toJSONObject(); |
|
479 |
} |
|
480 |
); |
|
481 |
return asyncTask; |
|
482 |
} |
87daf8
|
483 |
|
4bd49a
|
484 |
private class CartCallable implements Callable<Object> { |
F |
485 |
PostCartEntity postCartEntity; |
|
486 |
String userCode; |
|
487 |
String userName; |
|
488 |
String dbid; |
|
489 |
QrServiceIfc qrServiceIfc; |
87daf8
|
490 |
int actionType = 0;//1,新增(保存相同商品只更新数量) 2,修改 3,删除,4 保存购物车商品(覆盖原有商品) |
4bd49a
|
491 |
CartEntity cartEntity; |
F |
492 |
String idList; |
|
493 |
|
87daf8
|
494 |
public CartCallable(PostCartEntity postCartEntity, CartEntity cartEntity, String idList, String userCode, String userName, String dbid, QrServiceIfc qrServiceIfc, int actionType) { |
4bd49a
|
495 |
this.postCartEntity = postCartEntity; |
F |
496 |
this.userCode = userCode; |
|
497 |
this.userName = userName; |
|
498 |
this.dbid = dbid; |
|
499 |
this.qrServiceIfc = qrServiceIfc; |
87daf8
|
500 |
this.actionType = actionType; |
F |
501 |
this.cartEntity = cartEntity; |
|
502 |
this.idList = idList; |
4bd49a
|
503 |
} |
F |
504 |
|
|
505 |
@Override |
|
506 |
public Object call() throws Exception { |
|
507 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
508 |
try { |
|
509 |
SpObserver.setDBtoInstance("_" + dbid); |
|
510 |
|
a6a76f
|
511 |
Map map = new HashMap(); |
87daf8
|
512 |
switch (actionType) { |
4bd49a
|
513 |
case 1: |
5f16b6
|
514 |
case 4: |
87daf8
|
515 |
if (postCartEntity == null || postCartEntity.getCarts() == null || postCartEntity.getCarts().size() == 0) { |
4bd49a
|
516 |
throw new ApplicationException("商品不能为空,新增失败"); |
F |
517 |
} |
87daf8
|
518 |
final List<Map<String, Integer>> result = qrServiceIfc.saveCart(postCartEntity, userName); |
4bd49a
|
519 |
if (result != null) { |
F |
520 |
//--增加返回购物车商品总数 |
|
521 |
Integer count = qrServiceIfc.getCartListCount(userCode, userName, postCartEntity.getRefDocCode()); |
|
522 |
map.put("data", result); |
|
523 |
map.put("count", count); |
|
524 |
} |
|
525 |
break; |
|
526 |
case 2: |
|
527 |
if (cartEntity == null) { |
|
528 |
throw new ApplicationException("商品不能为空,修改商品数量失败"); |
|
529 |
} |
87daf8
|
530 |
qrServiceIfc.updateCart(cartEntity); |
4bd49a
|
531 |
break; |
F |
532 |
case 3: |
|
533 |
if (idList == null) { |
|
534 |
throw new ApplicationException("商品不能为空,删除商品失败"); |
|
535 |
} |
|
536 |
cartIfc.delCart(idList); |
|
537 |
break; |
5f16b6
|
538 |
|
4bd49a
|
539 |
} |
a6a76f
|
540 |
callBackMessage.setInfo(map); |
4bd49a
|
541 |
callBackMessage.sendSuccessMessageByDefault(); |
a6a76f
|
542 |
return callBackMessage.toJSONObject(); |
4bd49a
|
543 |
} catch (Exception ex) { |
F |
544 |
callBackMessage.sendErrorMessage(ex.getCause() != null ? ex.getCause().getMessage() : ex.getMessage()); |
a6a76f
|
545 |
return callBackMessage.toJSONObject(); |
4bd49a
|
546 |
} finally { |
F |
547 |
SpObserver.setDBtoInstance(); |
a6a76f
|
548 |
} |
F |
549 |
} |
|
550 |
} |
87daf8
|
551 |
|
a6a76f
|
552 |
/** |
F |
553 |
* 更新 |
|
554 |
* |
|
555 |
* @param request |
|
556 |
* @param response |
|
557 |
*/ |
|
558 |
|
|
559 |
@RequestMapping(value = "/qr/updateCart.do", method = RequestMethod.POST) |
|
560 |
@CrossOrigin |
|
561 |
public @ResponseBody |
4bd49a
|
562 |
WebAsyncTask updateCart(@RequestBody CartEntity cartEntity, HttpServletRequest request, HttpServletResponse response) { |
F |
563 |
String userCode = request.getSession().getAttribute(SessionKey.HRCODE) + ""; |
|
564 |
String userName = request.getSession().getAttribute(SessionKey.HRNAME) + ""; |
87daf8
|
565 |
Callable<Object> callable = new CartCallable(null, cartEntity, null, userCode, userName, request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "", qrServiceIfc, 2); |
4bd49a
|
566 |
//定义超时45秒 |
F |
567 |
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(45), threadPoolExecutor, callable); |
|
568 |
asyncTask.onCompletion( |
|
569 |
() -> log.info("执行成功") |
|
570 |
); |
|
571 |
asyncTask.onError( |
|
572 |
(Callable<Object>) () -> { |
|
573 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
574 |
log.info("执行出错"); |
|
575 |
callBackMessage.sendErrorMessage("操作出错"); |
|
576 |
return callBackMessage.toJSONObject(); |
|
577 |
} |
|
578 |
); |
|
579 |
asyncTask.onTimeout( |
|
580 |
(Callable<Object>) () -> { |
|
581 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
582 |
log.info("执行超时"); |
|
583 |
callBackMessage.sendErrorMessage("服务器繁忙,正在排队处理,请不要重复提交,稍后请在购物车查看结果", -1003); |
|
584 |
return callBackMessage.toJSONObject(); |
|
585 |
} |
|
586 |
); |
|
587 |
return asyncTask; |
a6a76f
|
588 |
} |
F |
589 |
|
|
590 |
/** |
|
591 |
* 新增客户资料 |
|
592 |
* |
|
593 |
* @param request |
|
594 |
* @param response |
|
595 |
*/ |
|
596 |
|
|
597 |
@RequestMapping(value = "/qr/save170001.do", method = RequestMethod.POST) |
|
598 |
@CrossOrigin |
|
599 |
public @ResponseBody |
|
600 |
Object save170001(@RequestBody CustomerEntity customerEntity, HttpServletRequest request, HttpServletResponse response) { |
|
601 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
602 |
try { |
|
603 |
checkFormPerssion(request, 170001); |
|
604 |
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + ""; |
|
605 |
SpObserver.setDBtoInstance("_" + dbid); |
|
606 |
customerEntity.setAddress(customerEntity.getFullAddress()); |
|
607 |
CustomerEntity customer = null; |
|
608 |
Integer result = null; |
87daf8
|
609 |
if (StringUtils.isBlank(customerEntity.getCltName())) { |
a6a76f
|
610 |
throw new ApplicationException("客户名称不能为空"); |
F |
611 |
} |
87daf8
|
612 |
if (StringUtils.isBlank(customerEntity.getTel())) { |
a6a76f
|
613 |
throw new ApplicationException("客户电话不能为空"); |
F |
614 |
} |
|
615 |
if (customerEntity.getCltCode() == null || StringUtils.isBlank(customerEntity.getCltCode())) { |
|
616 |
//新增 |
|
617 |
customer = accountIfc.saveNewCustomer(customerEntity, request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
|
618 |
} else { |
|
619 |
//修改 |
|
620 |
result = qrServiceIfc.update170001(customerEntity); |
|
621 |
} |
|
622 |
List<Map<String, Object>> meta = new ArrayList<>(); |
|
623 |
String sql = this.procssSQLPersion(request, meta); |
|
624 |
final Map map = qrServiceIfc.get170001(customerEntity.getCltCode(), sql); |
87daf8
|
625 |
String docCode = map.get("docCode") + ""; |
5812ff
|
626 |
//--生成二维码 |
a6a76f
|
627 |
QrCodeForAppEntity qrCodeForAppEntity = new QrCodeForAppEntity(); |
F |
628 |
qrCodeForAppEntity.setAction(QrCodeForAppEntity.ViewDocument); //设置行为 Action |
|
629 |
qrCodeForAppEntity.setAuthorCode((String) request.getSession().getAttribute(SessionKey.HRCODE)); |
|
630 |
qrCodeForAppEntity.setAuthorName((String) request.getSession().getAttribute(SessionKey.HRNAME)); |
|
631 |
qrCodeForAppEntity.setRefFormId(170001); |
|
632 |
qrCodeForAppEntity.setRefDocCode(docCode); |
|
633 |
qrCodeForAppEntity.setRefFormType(16); |
87daf8
|
634 |
qrCodeForAppEntity = qrServiceIfc.createQrCode(qrCodeForAppEntity); |
F |
635 |
if (qrCodeForAppEntity == null || StringUtils.isBlank(qrCodeForAppEntity.getQrCode())) { |
|
636 |
throw new ApplicationException("请检查" + qrCodeForAppEntity.getRefFormId() + "在9801是否勾选上【生成单据二维码】参数设置"); |
|
637 |
} else { |
|
638 |
map.put("qrCode", qrCodeForAppEntity.getQrCode()); |
|
639 |
} |
a6a76f
|
640 |
|
87daf8
|
641 |
//---与购物车中还没有关联的物料进行关联处理 |
F |
642 |
final Integer updateresult = qrServiceIfc.updateRefBy170001(map.get("doccode") + "", map.get("formId") + "", map.get("formtype") + "", request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
a6a76f
|
643 |
if (customer != null) { |
F |
644 |
callBackMessage.sendSuccessMessage("新建成功"); |
|
645 |
} else { |
|
646 |
//修改 |
|
647 |
if (result == 0) { |
|
648 |
throw new ApplicationException("更新客户资料出错"); |
|
649 |
} else { |
|
650 |
callBackMessage.sendSuccessMessage("更新成功"); |
|
651 |
} |
|
652 |
} |
|
653 |
callBackMessage.setInfo(map); |
|
654 |
return callBackMessage.toJSONObject(); |
|
655 |
} catch (Exception ex) { |
|
656 |
ex.printStackTrace(); |
|
657 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
658 |
return callBackMessage.toJSONObject(); |
|
659 |
} finally { |
|
660 |
SpObserver.setDBtoInstance(); |
|
661 |
} |
|
662 |
} |
|
663 |
|
|
664 |
/** |
|
665 |
* 检查指定功能号是否有权限 |
|
666 |
* |
|
667 |
* @param request |
|
668 |
* @param formid |
|
669 |
*/ |
|
670 |
public void checkFormPerssion(HttpServletRequest request, int formid) { |
|
671 |
//---检查权限 |
|
672 |
if (Integer.parseInt(request.getSession().getAttribute(SessionKey.SUPPER_USER) + "") == 0) { |
|
673 |
final Map attribute = (Map) request.getSession().getAttribute(SessionKey.PERSSION); |
87a321
|
674 |
if (!attribute.containsKey(formid+"")) {// TODO key为String类型,containsKey传的参数类型也要强制转换成String类型 ,不然会出现本来是存在,又找不到的情况,特别注意 |
a6a76f
|
675 |
//不存在于权限集合表示不需要输出 |
F |
676 |
throw new ApplicationException("没有新增客户资料的权限"); |
|
677 |
} |
|
678 |
} |
|
679 |
} |
|
680 |
|
|
681 |
/** |
|
682 |
* 搜索客户资料 |
|
683 |
* |
|
684 |
* @param request |
|
685 |
* @param response |
|
686 |
*/ |
|
687 |
|
|
688 |
@RequestMapping(value = "/qr/list170001.do", method = RequestMethod.POST) |
|
689 |
@CrossOrigin |
|
690 |
public @ResponseBody |
|
691 |
Object list170001(@RequestBody ProducParmBean producParmBean, HttpServletRequest request, HttpServletResponse response) { |
|
692 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
693 |
try { |
|
694 |
this.checkFormPerssion(request, 170001); |
|
695 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
696 |
//--处理权限,读取9802设置 |
|
697 |
List<Map<String, Object>> meta = new ArrayList<>(); |
|
698 |
String sql = this.procssSQLPersion(request, meta); |
9846ef
|
699 |
GTGrid gtGrid =(GTGrid) FactoryBean.getBean("GTGrid"); |
F |
700 |
final String dataGroupInfo = gtGrid.getDataGroupInfo(170001, request.getSession().getAttribute(SessionKey.USERCODE) + "", 0, request.getSession()); |
|
701 |
final List list = qrServiceIfc.list170001(producParmBean, sql,dataGroupInfo); |
a6a76f
|
702 |
|
F |
703 |
//if (list !=null&&list.size()>0) { |
|
704 |
callBackMessage.sendSuccessMessage("成功"); |
|
705 |
callBackMessage.setInfo(list); |
|
706 |
return callBackMessage.toJSONObject(); |
|
707 |
// } |
|
708 |
} catch (Exception ex) { |
|
709 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
710 |
return callBackMessage.toJSONObject(); |
|
711 |
} finally { |
|
712 |
SpObserver.setDBtoInstance(); |
|
713 |
} |
|
714 |
} |
87daf8
|
715 |
|
a6a76f
|
716 |
/** |
F |
717 |
* 显示客户资料明细 |
|
718 |
* |
|
719 |
* @param request |
|
720 |
* @param response |
|
721 |
*/ |
|
722 |
@RequestMapping(value = "/qr/get170001.do", method = RequestMethod.GET) |
|
723 |
@CrossOrigin |
|
724 |
public @ResponseBody |
|
725 |
Object get170001(String cltCode, HttpServletRequest request, HttpServletResponse response) { |
|
726 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
727 |
try { |
|
728 |
this.checkFormPerssion(request, 170001); |
|
729 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
730 |
Map map = new HashMap(); |
|
731 |
//--处理权限,读取9802设置 |
|
732 |
List<Map<String, Object>> meta = new ArrayList<>(); |
|
733 |
String sql = this.procssSQLPersion(request, meta); |
|
734 |
if (StringUtils.isNotBlank(cltCode)) { |
|
735 |
map.put("customer", qrServiceIfc.get170001(cltCode, sql)); |
|
736 |
} |
|
737 |
callBackMessage.sendSuccessMessage("成功"); |
|
738 |
map.put("9802", meta); |
|
739 |
final BaseService baseService = (BaseService) FactoryBean.getBean("BaseService"); |
|
740 |
map.put("cltType", baseService.getSimpleJdbcTemplate().queryForList("select a.CltType as fieldId,a.CltType as fieldName from t110201 a order by a.CltType asc")); |
|
741 |
callBackMessage.setInfo(map); |
|
742 |
return callBackMessage.toJSONObject(); |
|
743 |
|
|
744 |
} catch (Exception ex) { |
|
745 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
746 |
return callBackMessage.toJSONObject(); |
|
747 |
} finally { |
|
748 |
SpObserver.setDBtoInstance(); |
|
749 |
} |
|
750 |
} |
87daf8
|
751 |
|
F |
752 |
/** |
a6a76f
|
753 |
* 根据电话查询客户资料 |
F |
754 |
* |
|
755 |
* @param request |
|
756 |
* @param response |
|
757 |
*/ |
|
758 |
@RequestMapping(value = "/qr/get170001ByTel.do", method = RequestMethod.GET) |
|
759 |
@CrossOrigin |
|
760 |
public @ResponseBody |
|
761 |
Object get170001ByTel(String tel, HttpServletRequest request, HttpServletResponse response) { |
|
762 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
763 |
try { |
|
764 |
this.checkFormPerssion(request, 170001); |
|
765 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
766 |
Map map = new HashMap(); |
|
767 |
//--处理权限,读取9802设置 |
|
768 |
List<Map<String, Object>> meta = new ArrayList<>(); |
|
769 |
String sql = this.procssSQLPersion(request, meta); |
|
770 |
|
|
771 |
if (StringUtils.isBlank(tel)) { |
|
772 |
throw new ApplicationException("电话不能为空"); |
|
773 |
} |
87daf8
|
774 |
T110203 t110203 = qrServiceIfc.get170001ByTel(tel, sql); |
a6a76f
|
775 |
callBackMessage.sendSuccessMessage("成功"); |
F |
776 |
callBackMessage.setInfo(t110203); |
|
777 |
return callBackMessage.toJSONObject(); |
|
778 |
|
87daf8
|
779 |
} catch (EmptyResultDataAccessException e) { |
a6a76f
|
780 |
callBackMessage.sendSuccessMessage("成功"); |
F |
781 |
callBackMessage.setInfo(new T110203()); |
|
782 |
return callBackMessage.toJSONObject(); |
|
783 |
} catch (Exception ex) { |
|
784 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
785 |
return callBackMessage.toJSONObject(); |
|
786 |
} finally { |
|
787 |
SpObserver.setDBtoInstance(); |
|
788 |
} |
|
789 |
} |
|
790 |
|
|
791 |
private String procssSQLPersion(HttpServletRequest request, List<Map<String, Object>> meta) { |
|
792 |
final List<Map<String, Object>> list = gridService.getSimpleJdbcTemplate().queryForList("set nocount on ; select " + gridService.getGET_GFIELD().toLowerCase() + " from gfield where formid=170001 and headflag=0 order by statisid asc"); |
|
793 |
String sql = ""; |
|
794 |
List<String> valueExp = new ArrayList<>();//字段(id,权限,css,tips) |
|
795 |
String fieldNames = ";cltcode;cltname;tel;tel2;fulladdress;clttype;linkman;";//需要显示的字段 |
|
796 |
for (Map<String, Object> map : list) { |
|
797 |
String fieldId = GridUtils.prossRowSetDataType_String(map, "fieldid"); |
|
798 |
if (fieldNames.contains(";" + fieldId.toLowerCase() + ";")) { |
|
799 |
Map<String, Object> met = new HashMap<>(); |
|
800 |
met.put("fieldId", fieldId.toLowerCase()); |
|
801 |
|
|
802 |
//--权限表达式 |
|
803 |
if (!"".equalsIgnoreCase(GridUtils.prossRowSetDataType_String(map, "ShowFieldValueExpression"))) { |
|
804 |
String expr = " case when (" + map.get("ShowFieldValueExpression") + ") =1 then 1 when (" + map.get("ShowFieldValueExpression") + ") =2 then 2 else 0 end as [" + fieldId.toLowerCase() + "_expr]"; |
|
805 |
String value = " case (" + map.get("ShowFieldValueExpression") + ") when 0 then '******' else " + fieldId.toLowerCase() + " end as [" + fieldId.toLowerCase() + "]"; |
|
806 |
valueExp.add(value); |
|
807 |
valueExp.add(expr); |
|
808 |
} else { |
|
809 |
valueExp.add("[" + fieldId.toLowerCase() + "]"); |
|
810 |
} |
|
811 |
//只读 |
|
812 |
met.put("readOnly", GridUtils.prossRowSetDataType_Integer(map, "ReadOnly")); |
|
813 |
//初始值 |
|
814 |
met.put("initValue", GridUtils.prossRowSetDataType_String(map, "initValue")); |
|
815 |
meta.add(met); |
|
816 |
} |
|
817 |
} |
|
818 |
|
|
819 |
sql = String.join(",", valueExp); |
|
820 |
//替换会话参数 |
|
821 |
Pattern p = Pattern.compile("@.*?\\w+");// 匹配以@开头的单词 |
|
822 |
java.util.regex.Matcher propsMatcher = p.matcher(sql); |
|
823 |
while (propsMatcher.find()) { |
|
824 |
sql = sql.replaceAll(propsMatcher.group(), request.getSession().getAttribute(propsMatcher.group().toLowerCase()) + ""); |
|
825 |
} |
|
826 |
return sql; |
|
827 |
} |
|
828 |
|
|
829 |
/** |
|
830 |
* 保存扫码显示方式 |
|
831 |
* |
|
832 |
* @param request |
|
833 |
* @param response |
|
834 |
*/ |
|
835 |
|
|
836 |
@RequestMapping(value = "/qr/qrScanType.do", method = RequestMethod.GET) |
|
837 |
@CrossOrigin |
|
838 |
public @ResponseBody |
87daf8
|
839 |
Object saveQrSanType(int type, int isRelatingMaterialWhenNewCustomer, HttpServletRequest request, HttpServletResponse response) { |
a6a76f
|
840 |
CallBackMessage callBackMessage = new CallBackMessage(); |
F |
841 |
try { |
|
842 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
843 |
|
|
844 |
final Integer result = qrServiceIfc.saveQrScanType(request.getSession().getAttribute(SessionKey.USERCODE) + "", |
|
845 |
request.getSession().getAttribute(SessionKey.USER_NAME) + "", |
87daf8
|
846 |
type, isRelatingMaterialWhenNewCustomer); |
a6a76f
|
847 |
if (result > 0) { |
F |
848 |
callBackMessage.sendSuccessMessage("提交成功"); |
|
849 |
return callBackMessage.toJSONObject(); |
|
850 |
} else { |
|
851 |
callBackMessage.sendErrorMessage("提交出错"); |
|
852 |
return callBackMessage.toJSONObject(); |
|
853 |
} |
|
854 |
} catch (Exception ex) { |
|
855 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
856 |
return callBackMessage.toJSONObject(); |
|
857 |
} finally { |
|
858 |
SpObserver.setDBtoInstance(); |
|
859 |
} |
|
860 |
} |
|
861 |
|
|
862 |
/** |
|
863 |
* 扫码取数 |
|
864 |
* |
|
865 |
* @param refPostCartEntity 引用的原始单据功能号实体 |
|
866 |
* @param response |
|
867 |
*/ |
|
868 |
@RequestMapping(value = "/qr/qrScan.do", method = RequestMethod.POST) |
|
869 |
@CrossOrigin |
|
870 |
public @ResponseBody |
|
871 |
Object qrScan(@RequestBody PostCartEntity refPostCartEntity, HttpServletRequest request, HttpServletResponse response) { |
|
872 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
873 |
try { |
f10e31
|
874 |
String dbid=request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""; |
F |
875 |
SpObserver.setDBtoInstance("_" + dbid); |
87daf8
|
876 |
T112002 t112002 = new T112002(); |
F |
877 |
if (refPostCartEntity.getQrCode().startsWith("2003")) { |
565fe8
|
878 |
//API对接认证二维码 |
F |
879 |
RedisTemplate redisTemplate = (RedisTemplate) FactoryBean.getBean("redisTemplate"); |
|
880 |
final Object object = redisTemplate.opsForValue().get(RedisKey.MUTUAL_QRCODE + ":" + refPostCartEntity.getQrCode()); |
87daf8
|
881 |
if (object != null) { |
565fe8
|
882 |
t112002.setAction(QrCodeForAppEntity.AUTH); |
f10e31
|
883 |
//增加当前用户的companyName,logo。输出到前端 |
F |
884 |
String companyName = request.getSession().getAttribute(SessionKey.COMPANY_NAME) + ""; |
|
885 |
String domain = request.getSession().getAttribute(SessionKey.DOMAIN) + ""; |
|
886 |
MutualController mutualController=(MutualController)FactoryBean.getBean("mutualController"); |
|
887 |
String logo =mutualController.getLogo(dbid); |
|
888 |
Map ownMap =JSON.parseObject(String.valueOf(object),HashMap.class); |
|
889 |
Map qrCodeDate=(Map)ownMap.get("qrCodeData"); |
|
890 |
qrCodeDate.put("ownCompanyName",companyName); |
|
891 |
qrCodeDate.put("ownLogo",domain+logo); |
|
892 |
t112002.setQueryString(GridUtils.toJson(ownMap)); |
565fe8
|
893 |
Map map = new HashMap(); |
87daf8
|
894 |
map.put("qrCodeInfo", t112002); |
565fe8
|
895 |
callBackMessage.setInfo(map); |
87daf8
|
896 |
} else { |
f10e31
|
897 |
throw new ApplicationException("二维码已过期"); |
565fe8
|
898 |
} |
87daf8
|
899 |
} else { |
F |
900 |
t112002 = qrServiceIfc.getT112002(refPostCartEntity.getQrCode()); |
565fe8
|
901 |
callBackMessage.setInfo(getProductInfo(t112002, refPostCartEntity, request, response)); |
F |
902 |
} |
a6a76f
|
903 |
|
F |
904 |
callBackMessage.sendSuccessMessage("成功"); |
|
905 |
return callBackMessage.toJSONObject(); |
|
906 |
} catch (EmptyResultDataAccessException e) { |
|
907 |
callBackMessage.sendErrorMessage(refPostCartEntity.getQrCode() + "码不存在"); |
|
908 |
return callBackMessage.toJSONObject(); |
|
909 |
} catch (Exception ex) { |
|
910 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
911 |
return callBackMessage.toJSONObject(); |
|
912 |
} finally { |
|
913 |
SpObserver.setDBtoInstance(); |
|
914 |
} |
|
915 |
} |
|
916 |
|
|
917 |
/** |
|
918 |
* 通过原始单据取得引用物料列表 |
|
919 |
* |
|
920 |
* @param refPostCartEntity 引用的原始单据功能号实体 |
|
921 |
* @param response |
|
922 |
*/ |
|
923 |
@RequestMapping(value = "/qr/getRefMatCodes.do", method = RequestMethod.POST) |
|
924 |
@CrossOrigin |
|
925 |
public @ResponseBody |
|
926 |
Object getRefMatCodes(@RequestBody PostCartEntity refPostCartEntity, HttpServletRequest request, HttpServletResponse response) { |
|
927 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
928 |
try { |
|
929 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
930 |
|
|
931 |
|
|
932 |
callBackMessage.setInfo(getRefMatCodeList(refPostCartEntity, request)); |
|
933 |
|
|
934 |
callBackMessage.sendSuccessMessage("成功"); |
|
935 |
return callBackMessage.toJSONObject(); |
|
936 |
} catch (EmptyResultDataAccessException e) { |
|
937 |
callBackMessage.sendErrorMessage(refPostCartEntity.getQrCode() + "码不存在"); |
|
938 |
return callBackMessage.toJSONObject(); |
|
939 |
} catch (Exception ex) { |
|
940 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
941 |
return callBackMessage.toJSONObject(); |
|
942 |
} finally { |
|
943 |
SpObserver.setDBtoInstance(); |
|
944 |
} |
|
945 |
} |
|
946 |
|
|
947 |
private Map getRefMatCodeList(PostCartEntity refPostCartEntity, HttpServletRequest request) { |
|
948 |
Integer formid = refPostCartEntity.getFormId(); |
|
949 |
if (formid != null && formid != 0) { |
|
950 |
//需要通过formid查找9802设置的QrCodeSqlScript,执行sql返回相关联的物料,返回给前端 |
|
951 |
final QrCodeRefEntity refProduct = qrServiceIfc.getRefProduct(formid); |
|
952 |
if (refProduct != null) { |
|
953 |
if (StringUtils.isNotBlank(refProduct.getQrCodeSqlScript())) { |
|
954 |
Map qrMap = new HashMap(); |
|
955 |
if (StringUtils.isBlank(refProduct.getQrCodeRefRowId())) { |
|
956 |
throw new ApplicationException("请在9802中为【" + refProduct.getFieldid() + "】字段设置参数【APP扫码|引用外表RowId字段名】"); |
|
957 |
} |
|
958 |
qrMap.put("refRowid", refProduct.getQrCodeRefRowId()); |
|
959 |
if (StringUtils.isBlank(refProduct.getQrCodeRefDigit())) { |
|
960 |
throw new ApplicationException("请在9802中为【" + refProduct.getFieldid() + "】字段设置参数【APP扫码|引用外表数量字段名】"); |
|
961 |
} |
|
962 |
qrMap.put("refDigit", refProduct.getQrCodeRefDigit()); |
|
963 |
String sql = refProduct.getQrCodeSqlScript(); |
|
964 |
//&..&替换 |
|
965 |
Pattern p = Pattern.compile("&.*?&"); |
|
966 |
Matcher m = p.matcher(sql); |
|
967 |
while (m.find()) { |
|
968 |
String field = m.group().replaceAll("&", ""); |
|
969 |
if (field.equalsIgnoreCase("matcode")) { |
|
970 |
|
|
971 |
sql = sql.replaceAll(m.group(), refPostCartEntity.getMatCode()); |
|
972 |
} else if (field.equalsIgnoreCase("refformid")) { |
|
973 |
sql = sql.replaceAll(m.group(), refPostCartEntity.getRefFormId() + ""); |
|
974 |
} else if (field.equalsIgnoreCase("refdoccode")) { |
|
975 |
sql = sql.replaceAll(m.group(), refPostCartEntity.getRefDocCode() + ""); |
|
976 |
} else if (field.equalsIgnoreCase("refformtype")) { |
|
977 |
sql = sql.replaceAll(m.group(), refPostCartEntity.getRefFormType() + ""); |
|
978 |
} |
|
979 |
} |
|
980 |
//会话替换 |
|
981 |
sql = filterSession(sql, request); |
87daf8
|
982 |
List<Map<String, Object>> qrCodeSqlScriptMatCode = null; |
a6a76f
|
983 |
try { |
F |
984 |
qrCodeSqlScriptMatCode = qrServiceIfc.getQrCodeSqlScriptMatCode(sql); |
87daf8
|
985 |
if (qrCodeSqlScriptMatCode != null && qrCodeSqlScriptMatCode.size() == 0) { |
F |
986 |
throw new ApplicationException("当前引用" + refPostCartEntity.getRefDocCode() + "单据不存在" + refPostCartEntity.getMatCode() + "物料,请重新确认"); |
a6a76f
|
987 |
} |
87daf8
|
988 |
} catch (EmptyResultDataAccessException e) { |
F |
989 |
throw new ApplicationException("当前引用" + refPostCartEntity.getRefDocCode() + "单据不存在" + refPostCartEntity.getMatCode() + "物料,请重新确认"); |
a6a76f
|
990 |
} |
F |
991 |
|
|
992 |
qrMap.put("refProduct", qrCodeSqlScriptMatCode); |
|
993 |
return qrMap; |
|
994 |
} |
|
995 |
return null; |
|
996 |
} |
|
997 |
} |
|
998 |
return null; |
|
999 |
} |
|
1000 |
|
|
1001 |
/** |
|
1002 |
* 显示单据二维码 |
|
1003 |
* |
|
1004 |
* @param qrCode 二维码 |
|
1005 |
* @param response |
|
1006 |
*/ |
|
1007 |
@RequestMapping(value = "/qr/showQrCode.do", method = RequestMethod.GET) |
|
1008 |
@CrossOrigin |
|
1009 |
public @ResponseBody |
|
1010 |
Object showQrCode(String qrCode, HttpServletRequest request, HttpServletResponse response) { |
|
1011 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1012 |
try { |
|
1013 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
1014 |
T112002 t112002 = qrServiceIfc.getT112002(qrCode); |
|
1015 |
callBackMessage.setInfo(imgData.getImageUrl(t112002.getQrCodeUnid(), null, |
|
1016 |
null, true, |
|
1017 |
false, request)); |
|
1018 |
callBackMessage.sendSuccessMessage("成功"); |
|
1019 |
return callBackMessage.toJSONObject(); |
|
1020 |
} catch (EmptyResultDataAccessException e) { |
|
1021 |
callBackMessage.sendErrorMessage(qrCode + "码不存在"); |
|
1022 |
return callBackMessage.toJSONObject(); |
|
1023 |
} catch (Exception ex) { |
|
1024 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1025 |
return callBackMessage.toJSONObject(); |
|
1026 |
} finally { |
|
1027 |
SpObserver.setDBtoInstance(); |
|
1028 |
} |
|
1029 |
} |
|
1030 |
|
|
1031 |
private Map getProductInfo(T112002 t112002, PostCartEntity refPostCartEntity, HttpServletRequest request, HttpServletResponse response) { |
|
1032 |
Map<String, Object> map = new HashMap<>(); |
|
1033 |
map.put("qrCodeInfo", t112002); |
|
1034 |
if (QrCodeForAppEntity.ViewMaterial.equalsIgnoreCase(t112002.getAction())) { |
|
1035 |
//扫物料 |
|
1036 |
Integer formid = refPostCartEntity.getFormId(); |
|
1037 |
final Map matCodeMap = this.getMatCode(t112002.getMatCode(), request, response); |
|
1038 |
map.put("product", matCodeMap); |
|
1039 |
if (formid != null && formid != 0) { |
|
1040 |
refPostCartEntity.setMatCode(matCodeMap.get("MatCode") + ""); |
|
1041 |
map.put("refData", this.getRefMatCodeList(refPostCartEntity, request)); |
|
1042 |
} |
|
1043 |
|
|
1044 |
} else if (QrCodeForAppEntity.ViewDocument.equalsIgnoreCase(t112002.getAction())) { |
|
1045 |
//扫单据 |
|
1046 |
// refFormIdList = getRefFormIdList(request, t112002.getRefFormId()); |
|
1047 |
//map.put("reFormids", refFormIdList); |
|
1048 |
} |
|
1049 |
return map; |
|
1050 |
} |
|
1051 |
|
|
1052 |
private String filterSession(String filter, HttpServletRequest request) { |
|
1053 |
if ("".equals(filter)) return filter; |
|
1054 |
Pattern p = Pattern.compile("@.*?\\w+"); |
|
1055 |
Matcher m = p.matcher(filter); |
|
1056 |
while (m.find()) {//存在 |
|
1057 |
filter = filter.replaceAll(m.group(), request.getSession().getAttribute(m.group()) + ""); |
|
1058 |
} |
|
1059 |
return filter; |
|
1060 |
} |
|
1061 |
|
|
1062 |
/** |
|
1063 |
* 查看商品明细 |
|
1064 |
* |
|
1065 |
* @param request |
|
1066 |
* @param response |
|
1067 |
*/ |
|
1068 |
@RequestMapping(value = "/qr/product.do", method = RequestMethod.GET) |
|
1069 |
@CrossOrigin |
|
1070 |
public @ResponseBody |
|
1071 |
Object product(String matCode, HttpServletRequest request, HttpServletResponse response) { |
|
1072 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1073 |
try { |
|
1074 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
1075 |
callBackMessage.setInfo(this.getMatCode(matCode, request, response)); |
|
1076 |
callBackMessage.sendSuccessMessage("成功"); |
|
1077 |
return callBackMessage.toJSONObject(); |
|
1078 |
} catch (EmptyResultDataAccessException e) { |
|
1079 |
callBackMessage.sendErrorMessage(matCode + "不存在"); |
|
1080 |
return callBackMessage.toJSONObject(); |
|
1081 |
} catch (Exception ex) { |
|
1082 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1083 |
return callBackMessage.toJSONObject(); |
|
1084 |
} finally { |
|
1085 |
SpObserver.setDBtoInstance(); |
|
1086 |
} |
|
1087 |
} |
87daf8
|
1088 |
|
a6a76f
|
1089 |
/** |
F |
1090 |
* 更新购物车里没有关联的物料到指定引用单据 |
|
1091 |
* |
|
1092 |
* @param request |
|
1093 |
* @param response |
|
1094 |
*/ |
|
1095 |
@RequestMapping(value = "/qr/updateRef.do", method = RequestMethod.POST) |
|
1096 |
@CrossOrigin |
|
1097 |
public @ResponseBody |
|
1098 |
Object product(@RequestBody PostCartEntity postCartEntity, HttpServletRequest request, HttpServletResponse response) { |
|
1099 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1100 |
try { |
|
1101 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
87daf8
|
1102 |
Integer result = qrServiceIfc.updateRef(postCartEntity); |
F |
1103 |
if (result > 0) { |
|
1104 |
callBackMessage.sendSuccessMessageByDefault(); |
|
1105 |
return callBackMessage.toJSONObject(); |
|
1106 |
} else { |
|
1107 |
throw new ApplicationException("更新出错,请重试"); |
|
1108 |
} |
|
1109 |
} catch (Exception ex) { |
a6a76f
|
1110 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
F |
1111 |
return callBackMessage.toJSONObject(); |
|
1112 |
} finally { |
|
1113 |
SpObserver.setDBtoInstance(); |
|
1114 |
} |
|
1115 |
} |
87daf8
|
1116 |
|
a6a76f
|
1117 |
/** |
F |
1118 |
* 商品分类显示 |
|
1119 |
* |
|
1120 |
* @param request |
|
1121 |
* @param response |
|
1122 |
*/ |
|
1123 |
@RequestMapping(value = "/qr/matGroups.do", method = RequestMethod.GET) |
|
1124 |
@CrossOrigin |
|
1125 |
public @ResponseBody |
|
1126 |
Object matGroups(HttpServletRequest request, HttpServletResponse response) { |
|
1127 |
CallBackMessage callBackMessage = new CallBackMessage(); |
3dbec0
|
1128 |
String dbid=request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""; |
a6a76f
|
1129 |
try { |
3dbec0
|
1130 |
SpObserver.setDBtoInstance("_" +dbid ); |
F |
1131 |
GTGrid gtGrid =(GTGrid)FactoryBean.getBean("GTGrid"); |
|
1132 |
final HttpSession session = request.getSession(); |
|
1133 |
final String dataGroupInfo = gtGrid.getDataGroupInfo(110501, session.getAttribute(SessionKey.USERCODE) + "", 0, session); |
|
1134 |
final List<MatGroupEntity> groups = qrServiceIfc.getMatGroups(dataGroupInfo); |
a6a76f
|
1135 |
List<Map> groupList = new ArrayList(); |
F |
1136 |
String matgourpId = null; |
3dbec0
|
1137 |
String hostUrl = SettingKey.getHostUrlForImage(request); |
F |
1138 |
List<MatGroupEntity> mainGroup=groups.stream().filter(x->( |
|
1139 |
x.getParentRowid()==null||x.getParentRowid().equals("")) |
|
1140 |
).collect(Collectors.toList()); |
|
1141 |
if(mainGroup!=null&&mainGroup.size()>0) { |
|
1142 |
for (MatGroupEntity matGroupEntity : mainGroup) { |
|
1143 |
Map matGroup = new HashMap(); |
|
1144 |
//1级分类 |
|
1145 |
matGroup.put("MatGroupName", matGroupEntity.getMatGroupName()); |
|
1146 |
matGroup.put("MatGroup", matGroupEntity.getMatGroup()); |
|
1147 |
if (matgourpId == null) { |
|
1148 |
matgourpId = matGroupEntity.getMatGroup(); |
|
1149 |
} |
|
1150 |
//2级分类 |
|
1151 |
List<MatGroupEntity> subMatGroupList = groups.stream().filter(x -> ( |
|
1152 |
x.getParentRowid().equals(matGroupEntity.getRowid()) |
|
1153 |
)).collect(Collectors.toList());//qrServiceIfc.getMatGroupsByParentRowId(matGroupEntity.getRowid()); |
|
1154 |
List<Map> subList = new ArrayList<>(); |
|
1155 |
if(subMatGroupList!=null&&subMatGroupList.size()>0) { |
|
1156 |
subMatGroupList.stream().forEach(x -> { |
|
1157 |
Map subMap = new HashMap(); |
|
1158 |
subMap.put("SubMatGroupName", x.getMatGroupName()); |
|
1159 |
subMap.put("SubMatGroup", x.getMatGroup()); |
|
1160 |
subList.add(subMap); |
|
1161 |
}); |
|
1162 |
} |
|
1163 |
matGroup.put("subList", subList); |
|
1164 |
groupList.add(matGroup); |
a6a76f
|
1165 |
} |
3dbec0
|
1166 |
final List<MatCodeEntity> matCodeEntityList = qrServiceIfc.getMatCodesByMatGroup(matgourpId, 50, 1); |
F |
1167 |
// matCodeEntityList.stream().map(x -> { |
|
1168 |
// x.setPhotoPath(imgData.getImageUrl(x.getPhotoPath(), 120, |
|
1169 |
// 120, false, |
|
1170 |
// false, request)); |
|
1171 |
// return x; |
|
1172 |
// }).collect(Collectors.toList()); |
|
1173 |
matCodeEntityList.stream().forEach(x -> { |
|
1174 |
x.setPhotoPath(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
1175 |
x.setPhotoPathUrl(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
1176 |
}); |
|
1177 |
Map nodes = new HashMap(); |
|
1178 |
nodes.put("nodes", groupList); |
|
1179 |
nodes.put("data", matCodeEntityList); |
|
1180 |
nodes.put("appSalesOrderStyle", request.getSession().getAttribute(SessionKey.APP_SALESORDER_STYLE)); |
|
1181 |
callBackMessage.setInfo(nodes); |
a6a76f
|
1182 |
} |
F |
1183 |
callBackMessage.sendSuccessMessage("成功"); |
|
1184 |
return callBackMessage.toJSONObject(); |
|
1185 |
} catch (Exception ex) { |
|
1186 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1187 |
return callBackMessage.toJSONObject(); |
|
1188 |
} finally { |
|
1189 |
SpObserver.setDBtoInstance(); |
|
1190 |
} |
|
1191 |
} |
|
1192 |
|
|
1193 |
/** |
|
1194 |
* 商品列表显示 |
|
1195 |
* |
|
1196 |
* @param request |
|
1197 |
* @param response |
|
1198 |
*/ |
|
1199 |
@RequestMapping(value = "/qr/productList.do", method = RequestMethod.POST) |
|
1200 |
@CrossOrigin |
|
1201 |
public @ResponseBody |
|
1202 |
Object productList(@RequestBody ProducParmBean producParmBean, HttpServletRequest request, HttpServletResponse response) { |
|
1203 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1204 |
try { |
ce46b2
|
1205 |
String dbid=request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""; |
F |
1206 |
String hostUrl = SettingKey.getHostUrlForImage(request); |
|
1207 |
SpObserver.setDBtoInstance("_" +dbid ); |
a6a76f
|
1208 |
final List<MatCodeEntity> matCodeEntityList = qrServiceIfc.getMatCodesByMatGroup(producParmBean.getValue(), producParmBean.getLimit(), producParmBean.getPage()); |
F |
1209 |
|
ce46b2
|
1210 |
// matCodeEntityList.stream().map(x -> { |
F |
1211 |
// x.setPhotoPath(imgData.getImageUrl(x.getPhotoPath(), 120, |
|
1212 |
// 120, false, |
|
1213 |
// false, request)); |
|
1214 |
// return x; |
|
1215 |
// }).collect(Collectors.toList()); |
|
1216 |
matCodeEntityList.stream().forEach(x -> { |
|
1217 |
x.setPhotoPath(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
1218 |
x.setPhotoPathUrl(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
1219 |
}); |
a6a76f
|
1220 |
callBackMessage.setInfo(matCodeEntityList); |
F |
1221 |
callBackMessage.sendSuccessMessage("成功"); |
|
1222 |
return callBackMessage.toJSONObject(); |
|
1223 |
} catch (Exception ex) { |
|
1224 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1225 |
return callBackMessage.toJSONObject(); |
|
1226 |
} finally { |
|
1227 |
SpObserver.setDBtoInstance(); |
|
1228 |
} |
|
1229 |
} |
|
1230 |
|
|
1231 |
/** |
|
1232 |
* 商品搜索 |
|
1233 |
* |
|
1234 |
* @param request |
|
1235 |
* @param response |
|
1236 |
*/ |
|
1237 |
@RequestMapping(value = "/qr/searchProduct.do", method = RequestMethod.POST) |
|
1238 |
@CrossOrigin |
|
1239 |
public @ResponseBody |
|
1240 |
Object searchProduct(@RequestBody ProducParmBean producParmBean, HttpServletRequest request, HttpServletResponse response) { |
|
1241 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1242 |
try { |
ce46b2
|
1243 |
String dbid=request.getSession().getAttribute(SessionKey.DATA_BASE_ID)+""; |
F |
1244 |
SpObserver.setDBtoInstance("_" + dbid); |
|
1245 |
String hostUrl = SettingKey.getHostUrlForImage(request); |
a6a76f
|
1246 |
final List<MatCodeEntity> matCodeEntityList = qrServiceIfc.getMatCodesByMatGroupBySearch(producParmBean.getValue(), producParmBean.getLimit(), producParmBean.getPage()); |
ce46b2
|
1247 |
// matCodeEntityList.stream().map(x -> { |
F |
1248 |
// x.setPhotoPath(imgData.getImageUrl(x.getPhotoPath(), 120, |
|
1249 |
// 120, false, |
|
1250 |
// false, request)); |
|
1251 |
// return x; |
|
1252 |
// }).collect(Collectors.toList()); |
|
1253 |
matCodeEntityList.stream().forEach(x -> { |
|
1254 |
x.setPhotoPath(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
1255 |
x.setPhotoPathUrl(SettingKey.getUrl(hostUrl, x.getPhotoPathUrl(), dbid+"",null)); |
|
1256 |
}); |
a6a76f
|
1257 |
callBackMessage.setInfo(matCodeEntityList); |
F |
1258 |
callBackMessage.sendSuccessMessage("成功"); |
|
1259 |
return callBackMessage.toJSONObject(); |
|
1260 |
} catch (Exception ex) { |
|
1261 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1262 |
return callBackMessage.toJSONObject(); |
|
1263 |
} finally { |
|
1264 |
SpObserver.setDBtoInstance(); |
|
1265 |
} |
|
1266 |
} |
|
1267 |
|
|
1268 |
/** |
|
1269 |
* 保存2002类型的二维码单据信息 |
|
1270 |
* |
|
1271 |
* @param targetFormId 生成目标功能号 |
|
1272 |
* @param targetFormName 生成目标功能名称 |
|
1273 |
*/ |
|
1274 |
@RequestMapping(value = "/qr/save112005.do", method = RequestMethod.GET) |
|
1275 |
@CrossOrigin |
|
1276 |
public @ResponseBody |
|
1277 |
Object save112005(String qrCode, String targetFormId, String targetFormName, HttpServletRequest request, HttpServletResponse response) { |
|
1278 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1279 |
try { |
|
1280 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
1281 |
T112002 t112002 = qrServiceIfc.getT112002(qrCode); |
|
1282 |
if (t112002 != null && StringUtils.isNotBlank(t112002.getQueryString())) { |
|
1283 |
Map map = GridUtils.fromJson(t112002.getQueryString()); |
|
1284 |
if (map != null) { |
|
1285 |
T112005 t112005 = new T112005(); |
|
1286 |
t112005.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
|
1287 |
t112005.setRefFormId(GridUtils.prossRowSetDataType_Int(map, "FormId")); |
|
1288 |
t112005.setRefFormType(GridUtils.prossRowSetDataType_Int(map, "FormType")); |
|
1289 |
t112005.setRefDocCode(GridUtils.prossRowSetDataType_String(map, "DocCode")); |
|
1290 |
t112005.setTargetFormId(targetFormId); |
|
1291 |
t112005.setTargetFormName(targetFormName); |
|
1292 |
t112005.setQrCode(qrCode); |
|
1293 |
t112005.setQrCodeUnid(t112002.getQrCodeUnid()); |
|
1294 |
t112005.setQueryString(t112002.getQueryString()); |
|
1295 |
Integer result = qrServiceIfc.save112005(t112005); |
|
1296 |
Map rst = new HashMap(2); |
|
1297 |
rst.put("qrCodeInfo", t112002); |
|
1298 |
rst.put("count", result); |
|
1299 |
callBackMessage.setInfo(rst); |
|
1300 |
callBackMessage.sendSuccessMessage("成功"); |
|
1301 |
} |
|
1302 |
} else { |
|
1303 |
callBackMessage.sendErrorMessage(qrCode + "码查找不到相关数据"); |
|
1304 |
} |
|
1305 |
return callBackMessage.toJSONObject(); |
|
1306 |
} catch (Exception ex) { |
|
1307 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1308 |
return callBackMessage.toJSONObject(); |
|
1309 |
} finally { |
|
1310 |
SpObserver.setDBtoInstance(); |
|
1311 |
} |
|
1312 |
} |
|
1313 |
|
|
1314 |
/** |
|
1315 |
* 删除2002类型的二维码单据信息 |
|
1316 |
* |
|
1317 |
* @param request |
|
1318 |
* @param response |
|
1319 |
*/ |
|
1320 |
@RequestMapping(value = "/qr/del112005.do", method = RequestMethod.GET) |
|
1321 |
@CrossOrigin |
|
1322 |
public @ResponseBody |
|
1323 |
Object del112005(String docCode, HttpServletRequest request, HttpServletResponse response) { |
|
1324 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1325 |
try { |
|
1326 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
1327 |
T112005 t112005 = new T112005(); |
|
1328 |
t112005.setUserCode(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
|
1329 |
|
|
1330 |
t112005.setRefDocCode(docCode); |
|
1331 |
|
|
1332 |
Integer result = qrServiceIfc.del112005(t112005); |
|
1333 |
if (result > 0) { |
|
1334 |
callBackMessage.sendSuccessMessage("成功"); |
|
1335 |
} else { |
|
1336 |
callBackMessage.sendErrorMessage("删除出错"); |
|
1337 |
} |
|
1338 |
return callBackMessage.toJSONObject(); |
|
1339 |
} catch (Exception ex) { |
|
1340 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1341 |
return callBackMessage.toJSONObject(); |
|
1342 |
} finally { |
|
1343 |
SpObserver.setDBtoInstance(); |
|
1344 |
} |
|
1345 |
} |
|
1346 |
|
|
1347 |
/** |
|
1348 |
* 2002类型的二维码单据信息列表 |
|
1349 |
* |
|
1350 |
* @param request |
|
1351 |
* @param response |
|
1352 |
*/ |
|
1353 |
@RequestMapping(value = "/qr/list112005.do", method = RequestMethod.GET) |
|
1354 |
@CrossOrigin |
|
1355 |
public @ResponseBody |
|
1356 |
Object list112005(HttpServletRequest request, HttpServletResponse response) { |
|
1357 |
CallBackMessage callBackMessage = new CallBackMessage(); |
|
1358 |
try { |
|
1359 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
|
1360 |
|
|
1361 |
|
|
1362 |
List<T112005> list112005 = qrServiceIfc.list112005(request.getSession().getAttribute(SessionKey.USERCODE) + ""); |
|
1363 |
if (list112005 != null && list112005.size() > 0) { |
|
1364 |
callBackMessage.sendSuccessMessage("成功"); |
|
1365 |
callBackMessage.setInfo(list112005); |
|
1366 |
} |
|
1367 |
return callBackMessage.toJSONObject(); |
|
1368 |
} catch (Exception ex) { |
|
1369 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1370 |
return callBackMessage.toJSONObject(); |
|
1371 |
} finally { |
|
1372 |
SpObserver.setDBtoInstance(); |
|
1373 |
} |
|
1374 |
} |
|
1375 |
|
|
1376 |
/** |
|
1377 |
* 取得关联功能号 |
|
1378 |
* |
|
1379 |
* @param request |
|
1380 |
* @param response |
|
1381 |
*/ |
|
1382 |
@RequestMapping(value = "/qr/getRefFormIds.do", method = RequestMethod.GET) |
|
1383 |
@CrossOrigin |
|
1384 |
public @ResponseBody |
e1b640
|
1385 |
Object getRefFormIds(Integer refFormid,Integer targetFormid, HttpServletRequest request, HttpServletResponse response) { |
a6a76f
|
1386 |
CallBackMessage callBackMessage = new CallBackMessage(); |
F |
1387 |
try { |
|
1388 |
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID)); |
e1b640
|
1389 |
final List<Gfrom> refFormIdList = this.getRefFormIdList(request, refFormid,targetFormid); |
a6a76f
|
1390 |
if (refFormIdList == null || refFormIdList.size() == 0) { |
e1b640
|
1391 |
if (refFormid != null) { |
0f330b
|
1392 |
//针对扫码方式,refFormid是有值 |
F |
1393 |
throw new ApplicationException("请设置要生成的目标单据功能号,在9802中为扫码字段设置【APP扫码|引用外表功能号【多值用分号隔开】】参数"); |
87daf8
|
1394 |
} else { |
0f330b
|
1395 |
//针对下单方式,refFormid是没有值,也就是没有关联 |
F |
1396 |
throw new ApplicationException("在下单方式下请确保要生成的目标单据功能号,在9802中为扫码字段设置【APP扫码|引用外表功能号【多值用分号隔开】】参数要为空"); |
|
1397 |
} |
a6a76f
|
1398 |
} else { |
F |
1399 |
callBackMessage.sendSuccessMessage("成功"); |
|
1400 |
callBackMessage.setInfo(refFormIdList); |
|
1401 |
return callBackMessage.toJSONObject(); |
|
1402 |
} |
|
1403 |
} catch (Exception ex) { |
|
1404 |
callBackMessage.sendErrorMessage(this.getErrorMsg(ex)); |
|
1405 |
return callBackMessage.toJSONObject(); |
|
1406 |
} finally { |
|
1407 |
SpObserver.setDBtoInstance(); |
|
1408 |
} |
|
1409 |
} |
|
1410 |
|
e1b640
|
1411 |
public List<Gfrom> getRefFormIdList(HttpServletRequest request, Integer refFormid,Integer targetFormid) { |
a6a76f
|
1412 |
//---二维码关联的功能号 |
F |
1413 |
List<Gfrom> refFormIdList = qrServiceIfc.getRefFormIdList(refFormid); |
87daf8
|
1414 |
if (refFormIdList == null || refFormIdList.size() == 0) { |
F |
1415 |
throw new ApplicationException("未找到可生成的目标功能号"); |
|
1416 |
} |
e1b640
|
1417 |
return procFormLimitV2(request, refFormIdList,targetFormid); |
a9a8e7
|
1418 |
} |
F |
1419 |
|
|
1420 |
public List<Gfrom> procFormLimit(HttpServletRequest request, List<Gfrom> refFormIdList) { |
a6a76f
|
1421 |
if (Integer.parseInt(request.getSession().getAttribute(SessionKey.SUPPER_USER) + "") == 0) { |
F |
1422 |
//---取出当前用户的功能号权限集合 |
|
1423 |
final Map attribute = (Map) request.getSession().getAttribute(SessionKey.PERSSION); |
|
1424 |
Iterator<Gfrom> iterator = refFormIdList.iterator(); |
|
1425 |
while (iterator.hasNext()) { |
|
1426 |
Gfrom gfrom = iterator.next(); |
87daf8
|
1427 |
if (!attribute.containsKey(gfrom.getFormid() + "")) { |
a6a76f
|
1428 |
//不存在于权限集合表示不需要输出 |
F |
1429 |
iterator.remove(); |
|
1430 |
} |
|
1431 |
} |
|
1432 |
} |
|
1433 |
return refFormIdList; |
|
1434 |
} |
|
1435 |
|
e1b640
|
1436 |
/** |
F |
1437 |
* 增加对下单,采购订单下单的分别处理 |
|
1438 |
* @param request |
|
1439 |
* @param refFormIdList |
|
1440 |
* @param targetFormid |
|
1441 |
* @return |
|
1442 |
*/ |
|
1443 |
public List<Gfrom> procFormLimitV2(HttpServletRequest request, List<Gfrom> refFormIdList,Integer targetFormid) { |
|
1444 |
//---取出当前用户的功能号权限集合 |
|
1445 |
final Map attribute = (Map) request.getSession().getAttribute(SessionKey.PERSSION); |
|
1446 |
Iterator<Gfrom> iterator = refFormIdList.iterator(); |
799c0b
|
1447 |
boolean isAdmin=false;//是否管理员 |
F |
1448 |
String supperUser= (String) request.getSession().getAttribute(SessionKey.SUPPER_USER); |
|
1449 |
if(StringUtils.isNotBlank(supperUser)){ |
|
1450 |
if(Integer.parseInt(supperUser)==1){ |
|
1451 |
isAdmin=true; |
|
1452 |
} |
|
1453 |
} |
e1b640
|
1454 |
while (iterator.hasNext()) { |
F |
1455 |
Gfrom gfrom = iterator.next(); |
|
1456 |
if(targetFormid==null) { |
|
1457 |
//表示调用不是采购下单的另一个下单功能,则就算有生成130301权限也需要排除 |
799c0b
|
1458 |
if (130301==gfrom.getFormid().intValue()||(!isAdmin&&!attribute.containsKey(gfrom.getFormid() + "")) |
e1b640
|
1459 |
) { |
F |
1460 |
//不存在于权限集合表示不需要输出 |
|
1461 |
iterator.remove(); |
|
1462 |
} |
|
1463 |
}else{ |
|
1464 |
//执行是采购订单下单,则除了自己(采购订单),其他的都要排除 |
|
1465 |
if(gfrom.getFormid()==null||gfrom.getFormid().intValue()!=targetFormid.intValue()){ |
|
1466 |
iterator.remove(); |
|
1467 |
} |
|
1468 |
} |
|
1469 |
} |
|
1470 |
return refFormIdList; |
|
1471 |
} |
a6a76f
|
1472 |
public Map getMatCode(String matCode, HttpServletRequest request, HttpServletResponse response) { |
F |
1473 |
HttpSession session = request.getSession(); |
|
1474 |
String userCode = (session.getAttribute(SessionKey.USERCODE) == null ? "" |
|
1475 |
: (String) session.getAttribute(SessionKey.USERCODE)); |
84e09e
|
1476 |
String openId = (session.getAttribute(SessionKey.WEIXIN_OPENID) == null ? "" : (String) session.getAttribute(SessionKey.WEIXIN_OPENID)); |
a6a76f
|
1477 |
//String wx = (session.getAttribute(SessionKey.WEIXIN_FROM) == null ? "" : (String) session.getAttribute(SessionKey.WEIXIN_FROM)); |
F |
1478 |
|
|
1479 |
boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request); |
|
1480 |
|
|
1481 |
//depositDocCode 和 depositRowId 表示取 维护抢购订金分组 710170 里的明细 |
|
1482 |
String depositDocCode = request.getParameter("DepositDocCode"); |
|
1483 |
String depositRowId = request.getParameter("DepositRowId"); |
|
1484 |
|
|
1485 |
|
|
1486 |
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
1487 |
//SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
1488 |
SettingEntity settingEntity = null; |
|
1489 |
|
|
1490 |
|
|
1491 |
try { |
|
1492 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap(request); |
|
1493 |
SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());// 切换数据源 |
22907b
|
1494 |
settingEntity = settingIfc.getSettingEntity(request); |
a6a76f
|
1495 |
|
F |
1496 |
// 取网店 shopcccode |
|
1497 |
ShopCcCodeEntity shopCcCodeEntity = ShopCcCode.getShopCcCode(settingEntity, request); |
|
1498 |
|
|
1499 |
|
|
1500 |
String hostUrl = SettingKey.getHostUrl(request); |
|
1501 |
// 将微信corpid组装成url |
|
1502 |
String wxQueryString = SettingKey.getQueryStringByWx(request); |
|
1503 |
|
|
1504 |
// 商品编号信息 |
|
1505 |
MatCodeEntity matCodeEntity = qrServiceIfc.getMatCodeForAPP(matCode, shopCcCodeEntity.getShopCcCode()); |
|
1506 |
if (matCodeEntity == null) { |
|
1507 |
throw new ApplicationException("商品编号【" + matCode + "】不存在"); |
|
1508 |
|
|
1509 |
} |
|
1510 |
// 商品附加图片信息 |
|
1511 |
List<MatCodeImageEntity> matImageList = matCodeImageIfc.getMatCodeImage(matCode); |
|
1512 |
|
|
1513 |
// 商品评价条数 |
|
1514 |
Integer matReviewCount = 0; |
87daf8
|
1515 |
matReviewCount = matCodeEntity.getRatingCount(); |
a6a76f
|
1516 |
|
F |
1517 |
// 消费积份 |
|
1518 |
Integer points = matPointsIfc.getMatPoints(matCode, null); |
|
1519 |
|
|
1520 |
// 商品促销活动关联表 |
|
1521 |
List<MatDiscountEntity> matDisList = matDiscountIfc.getMatDiscount(matCode, null); |
|
1522 |
|
|
1523 |
// 取处理过的商品描述 |
|
1524 |
String matDmatDescription = imgData.getDescriptionByNewImgLink(matCodeEntity.getDescription(), request); |
|
1525 |
|
|
1526 |
// 购物车 |
|
1527 |
// cartList = cartIfc.getCarts(userCode, sessionId,openId,cltCode); |
|
1528 |
|
|
1529 |
// 关注商品资料 |
|
1530 |
// matCodeList = |
|
1531 |
// matCodeIfc.getMatCodesByWishList(userCode,sessionId,openId,cltCode,shopCcCode); |
|
1532 |
// List<MatCodeEntity> matCodeCompareList = |
|
1533 |
// matCodeIfc.getMatCodesByCompare(userCode,sessionId,openId,cltCode,shopCcCode); |
|
1534 |
|
|
1535 |
// 显示分享信息 |
|
1536 |
// ShareEntity shareEntity=shareIfc.getShareEntity(); |
|
1537 |
|
|
1538 |
// 是否有选项要显示 |
|
1539 |
boolean hasMatAttr = true;// matAttrIfc.hasMatAttr(matCode); |
|
1540 |
|
|
1541 |
Map jsonObject = new HashMap(); |
|
1542 |
|
|
1543 |
String url = "", externalURL = ""; |
0d7208
|
1544 |
String imageHostUrl = shoppingImageDataIfc.getImageHostUrl(hostUrl); |
a6a76f
|
1545 |
if (matCodeEntity.getExternalURL() != null && !"".equals(matCodeEntity.getExternalURL())) { |
F |
1546 |
externalURL = matCodeEntity.getExternalURL(); |
87daf8
|
1547 |
if (!externalURL.startsWith("http")) externalURL = imageHostUrl + externalURL; |
a6a76f
|
1548 |
String separator = "?"; |
F |
1549 |
int pos = externalURL.indexOf("?"); |
|
1550 |
if (pos > 0) separator = "&"; |
|
1551 |
externalURL = externalURL + (wxQueryString == null || "".equals(wxQueryString) ? "" : separator + wxQueryString); |
|
1552 |
} else { |
87daf8
|
1553 |
url = imageHostUrl + SettingKey.getMatCodeUrl("", matCodeEntity.getMatCode(), isMoblieBrowser) |
a6a76f
|
1554 |
+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "&" + wxQueryString); |
F |
1555 |
} |
|
1556 |
|
|
1557 |
jsonObject.put("ExternalUrl", externalURL); |
|
1558 |
//jsonObject.addProperty("url", url); |
|
1559 |
jsonObject.put("MatCodeUrl", url); |
|
1560 |
//主图片 |
|
1561 |
jsonObject.put("PhotoPath", |
87daf8
|
1562 |
SettingKey.getUrl(imageHostUrl, matCodeEntity.getPhotoPathUrl(), dataSourceEntity.getDbId() + "", null) |
a6a76f
|
1563 |
//+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "?" + wxQueryString) |
F |
1564 |
); |
|
1565 |
jsonObject.put("PhotoUnid", matCodeEntity.getPhotoPath()); |
|
1566 |
// 主图片与多图片合并 |
|
1567 |
List<String> subImageListArray = new ArrayList<>(); |
|
1568 |
if (matCodeEntity.getPhotoPath() != null && !matCodeEntity.getPhotoPath().equals("")) { |
87daf8
|
1569 |
subImageListArray.add(SettingKey.getUrl(imageHostUrl, matCodeEntity.getPhotoPathUrl(), dataSourceEntity.getDbId() + "", null)); |
F |
1570 |
// subImageListArray.add(imgData.getImageUrl(matCodeEntity.getPhotoPath(), settingEntity.getImageProductWidth(), |
|
1571 |
// settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(), |
|
1572 |
// settingEntity.isFromCached(), request) |
|
1573 |
// //+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "?" + wxQueryString) |
|
1574 |
// ); |
a6a76f
|
1575 |
} |
F |
1576 |
//主图片与多图片合并 |
87daf8
|
1577 |
// for (int k = 0; matImageList != null && k < matImageList.size(); k++) { |
F |
1578 |
// MatCodeImageEntity matImage = matImageList.get(k); |
|
1579 |
// subImageListArray.add(imgData.getImageUrl(matImage.getImage(), settingEntity.getImagePopupWidth(), |
|
1580 |
// settingEntity.getImagePopupHeight(), settingEntity.isShowPopupOrgImage(), |
|
1581 |
// settingEntity.isFromCached(), request) |
|
1582 |
// //+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "?" + wxQueryString) |
|
1583 |
// ); |
|
1584 |
// } |
|
1585 |
|
|
1586 |
if (matCodeEntity.getImagesUrl() != null && !matCodeEntity.getImagesUrl().equals("")) { |
|
1587 |
String images[] = matCodeEntity.getImagesUrl().split(";"); |
|
1588 |
for (int j = 0; j < images.length; j++) { |
|
1589 |
subImageListArray.add(SettingKey.getUrl(imageHostUrl, images[j], dataSourceEntity.getDbId() + "", null)); |
|
1590 |
} |
a6a76f
|
1591 |
} |
F |
1592 |
|
|
1593 |
jsonObject.put("images", subImageListArray); |
|
1594 |
String cltCode = (String) session.getAttribute(SettingKey.CLTCODE); |
|
1595 |
|
|
1596 |
//是否显示评价 |
|
1597 |
jsonObject.put("isShowReviewStatus", settingEntity.getReviewStatus()); |
|
1598 |
// 商品评价 |
|
1599 |
if (settingEntity.getReviewStatus()) { |
|
1600 |
|
|
1601 |
} |
|
1602 |
|
|
1603 |
if (settingEntity.isShowBrand()) { |
|
1604 |
jsonObject.put("Brand", matCodeEntity.getBrand()); |
|
1605 |
} |
|
1606 |
|
|
1607 |
jsonObject.put("MatName", matCodeEntity.getMatName()); |
|
1608 |
jsonObject.put("MatCode", matCodeEntity.getMatCode()); |
7abd51
|
1609 |
jsonObject.put("startupSkuParameters", matCodeEntity.isStartupSkuParameters()); |
799c0b
|
1610 |
jsonObject.put("ShopMatCode", matCodeEntity.getShopMatCode()); |
a6a76f
|
1611 |
jsonObject.put("isShowMatCode", settingEntity.isShowMatCode()); |
F |
1612 |
jsonObject.put("isShowMatName", settingEntity.isShowMatName()); |
|
1613 |
jsonObject.put("isShowSpecial", settingEntity.isShowSpecial()); |
|
1614 |
jsonObject.put("isShowPrice", settingEntity.isShowPrice()); |
|
1615 |
jsonObject.put("isShowPoints", settingEntity.isShowPoints()); |
|
1616 |
jsonObject.put("isShowBrand", settingEntity.isShowBrand()); |
|
1617 |
jsonObject.put("StockDisplay", settingEntity.getStockDisplay()); |
|
1618 |
|
|
1619 |
jsonObject.put("isStartupMatName2", settingEntity.isStartupMatName2()); |
|
1620 |
jsonObject.put("isStartupMatName3", settingEntity.isStartupMatName3()); |
|
1621 |
jsonObject.put("isStartupMatName4", settingEntity.isStartupMatName4()); |
|
1622 |
|
|
1623 |
if (settingEntity.isShowSpecial()) { |
|
1624 |
jsonObject.put("Special", matCodeEntity.getSpecial()); |
|
1625 |
} |
|
1626 |
|
|
1627 |
if (settingEntity.isStartupMatName2()) { |
|
1628 |
jsonObject.put("MatName2Label", settingEntity.getMatName2Label()); |
|
1629 |
jsonObject.put("MatName2", matCodeEntity.getMatName2()); |
|
1630 |
} |
|
1631 |
|
|
1632 |
if (settingEntity.isStartupMatName3()) { |
|
1633 |
jsonObject.put("MatName3Label", settingEntity.getMatName3Label()); |
|
1634 |
jsonObject.put("MatName3", matCodeEntity.getMatName3()); |
|
1635 |
} |
|
1636 |
|
|
1637 |
if (settingEntity.isStartupMatName4()) { |
|
1638 |
jsonObject.put("MatName4Label", settingEntity.getMatName4Label()); |
|
1639 |
jsonObject.put("MatName4", matCodeEntity.getMatName4()); |
|
1640 |
} |
|
1641 |
|
|
1642 |
if (settingEntity.isShowPoints()) { |
|
1643 |
jsonObject.put("Points", matCodeEntity.getPoints()); // 奖励积分 |
|
1644 |
jsonObject.put("SalesPoints", points + ""); // 消费积分 |
|
1645 |
} |
|
1646 |
|
|
1647 |
if (matCodeEntity.getStockStatusName() != null && !"".equals(matCodeEntity.getStockStatusName())) { |
|
1648 |
jsonObject.put("StockStatusName", matCodeEntity.getStockStatusName()); |
|
1649 |
} |
|
1650 |
|
|
1651 |
if (settingEntity.isShowPrice()) { |
|
1652 |
|
|
1653 |
MatPriceEntity matPriceEntity = matPriceIfc.getMatPrice(matCodeEntity.getMatCode(), cltCode, null); |
|
1654 |
Double price = matPriceEntity.getPrice(); |
|
1655 |
jsonObject.put("Price", price); // 实际价格,此价格可能低于“标价” |
|
1656 |
jsonObject.put("SalesPrice", matCodeEntity.getSalesPrice()); // 标价 |
6e88ad
|
1657 |
jsonObject.put("purchasePrice", matCodeEntity.getPurchasePrice()); // 采购单价 |
a6a76f
|
1658 |
|
22907b
|
1659 |
CurrencyEntity currencyEntity = new CurrencyEntity(request); |
87daf8
|
1660 |
jsonObject.put("Currency", currencyEntity == null ? "" : currencyEntity.getCurrency()); |
F |
1661 |
jsonObject.put("CurrencySign", currencyEntity == null ? "" : currencyEntity.getCurrencySign()); |
a6a76f
|
1662 |
} |
F |
1663 |
jsonObject.put("Quantity", matCodeEntity.getQuantity()); |
|
1664 |
|
|
1665 |
List<Map> matDisListJsonArray = new ArrayList<>(); |
|
1666 |
// 商品促销活动关联表 |
|
1667 |
for (int i = 0; matDisList != null && i < matDisList.size(); i++) { |
|
1668 |
Map subJsonObject = new HashMap(); |
|
1669 |
subJsonObject.put("digit", matDisList.get(i).getDigit()); |
|
1670 |
subJsonObject.put("price", matDisList.get(i).getPrice()); |
|
1671 |
matDisListJsonArray.add(subJsonObject); |
|
1672 |
} |
|
1673 |
|
|
1674 |
jsonObject.put("matdiscount", matDisListJsonArray); |
|
1675 |
|
|
1676 |
// 获取商品选项(如:数量,日期。。。) |
|
1677 |
// matComponentIfc.getMatComponent(matCodeEntity, matCode, |
|
1678 |
// currencyEntityProd.getMemo(),isMoblieBrowser,false) ; |
|
1679 |
|
|
1680 |
// 评星级分 |
|
1681 |
if (settingEntity.isShowRatingOnHomePage()) { |
|
1682 |
jsonObject.put("RatingAvg", matCodeEntity.getRatingAvg() + ""); |
|
1683 |
} |
|
1684 |
|
|
1685 |
// 评价条数 |
|
1686 |
if (settingEntity.getReviewStatus()) { |
|
1687 |
jsonObject.put("ReviewCount", (matReviewCount == null ? 0 : matReviewCount) + ""); |
|
1688 |
} |
|
1689 |
|
|
1690 |
// 商品描述 |
|
1691 |
jsonObject.put("Description", matDmatDescription); |
|
1692 |
//是否显示属性 |
|
1693 |
jsonObject.put("isShowMatAttr", hasMatAttr); |
|
1694 |
//最小起订数量 |
|
1695 |
jsonObject.put("Mininum", matCodeEntity.getMininum()); |
|
1696 |
|
|
1697 |
//商品属性 |
|
1698 |
List<Map> matAttrGroupJsonArray = new ArrayList<>(); |
|
1699 |
if (hasMatAttr) { |
|
1700 |
List<MatAttrGroupEntity> matAttrGroupList = matAttrIfc.getMatAttrGroupByMatCode(matCode); |
|
1701 |
for (int j = 0; matAttrGroupList != null && j < matAttrGroupList.size(); j++) { |
|
1702 |
MatAttrGroupEntity matAttrGroupEntity = matAttrGroupList.get(j); |
|
1703 |
Map matAttrGroupJsonObject = new HashMap(); |
|
1704 |
matAttrGroupJsonObject.put("AttrGroupName", matAttrGroupEntity.getAttrGroupName()); |
|
1705 |
|
|
1706 |
List<Map> matAttrJsonArray = new ArrayList<>(); |
|
1707 |
List<MatAttrEntity> matAttrList = matAttrIfc.getMatAttr(matCode, matAttrGroupEntity.getAttrGroupId()); |
|
1708 |
for (int i = 0; matAttrList != null && i < matAttrList.size(); i++) { |
|
1709 |
MatAttrEntity matAttr = matAttrList.get(i); |
|
1710 |
Map matAttrJsonObject = new HashMap(); |
87daf8
|
1711 |
matAttrJsonObject.put("AttrName", matAttr == null ? "" : matAttr.getAttrName()); |
F |
1712 |
matAttrJsonObject.put("Text", matAttr == null ? "" : matAttr.getText()); |
a6a76f
|
1713 |
|
F |
1714 |
matAttrJsonArray.add(matAttrJsonObject); |
|
1715 |
} |
|
1716 |
matAttrGroupJsonObject.put("Attrs", matAttrJsonArray); |
|
1717 |
matAttrGroupJsonArray.add(matAttrGroupJsonObject); |
|
1718 |
} |
|
1719 |
|
|
1720 |
} |
|
1721 |
jsonObject.put("matattr", matAttrGroupJsonArray); |
|
1722 |
// 相关商品资料集合 调用也可实现,只是要多发一次请求: |
|
1723 |
// http://mp.onbus.cn/shopping/getMatCodeList.do?matcode=xxx&fromdata=3 |
|
1724 |
// 获取相关商品资料集合 |
b17988
|
1725 |
List<MatCodeEntity> matRelList = matCodeIfc.getMatCodesByRelMat(matCode, shopCcCodeEntity.getShopCcCode(), cltCode,openId,0); |
a6a76f
|
1726 |
List<Map> relMatJsonArray = new ArrayList<>(); |
F |
1727 |
for (int i = 0; matRelList != null && i < matRelList.size(); i++) { |
|
1728 |
MatCodeEntity relMatCodeEntity = matRelList.get(i); |
|
1729 |
Map subJsonObject = new HashMap(); |
|
1730 |
String relMatCodeUrl = ""; |
|
1731 |
if (relMatCodeEntity.getExternalURL() != null && !"".equals(relMatCodeEntity.getExternalURL())) { |
|
1732 |
relMatCodeUrl = relMatCodeEntity.getExternalURL(); |
|
1733 |
} else { |
|
1734 |
relMatCodeUrl = hostUrl |
|
1735 |
+ SettingKey.getMatCodeUrl("", relMatCodeEntity.getMatCode(), isMoblieBrowser) |
|
1736 |
+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "&" + wxQueryString); |
|
1737 |
} |
|
1738 |
subJsonObject.put("url", relMatCodeUrl); |
|
1739 |
subJsonObject.put("PhotoPath", |
87daf8
|
1740 |
SettingKey.getUrl(imageHostUrl, relMatCodeEntity.getPhotoPathUrl(), dataSourceEntity.getDbId() + "", null) |
a6a76f
|
1741 |
// + (wxQueryString == null || "".equals(wxQueryString) ? "" : "?" + wxQueryString) |
F |
1742 |
); |
|
1743 |
|
|
1744 |
subJsonObject.put("MatCode", relMatCodeEntity.getMatCode()); |
|
1745 |
subJsonObject.put("isShowMatCode", settingEntity.isShowMatCode()); |
|
1746 |
subJsonObject.put("isShowMatName", settingEntity.isShowMatName()); |
|
1747 |
subJsonObject.put("isShowSpecial", settingEntity.isShowSpecial()); |
|
1748 |
subJsonObject.put("isShowPrice", settingEntity.isShowPrice()); |
|
1749 |
subJsonObject.put("isShowPoints", settingEntity.isShowPoints()); |
|
1750 |
subJsonObject.put("isShowBrand", settingEntity.isShowBrand()); |
|
1751 |
subJsonObject.put("StockDisplay", settingEntity.getStockDisplay()); |
|
1752 |
|
|
1753 |
if (settingEntity.isShowMatName()) { |
|
1754 |
subJsonObject.put("MatName", relMatCodeEntity.getMatName()); |
|
1755 |
} |
|
1756 |
if (settingEntity.isShowDescription()) { |
|
1757 |
subJsonObject.put("Description", HtmlUtil.getShortDescription( |
|
1758 |
settingEntity.getProductDescriptionLength(), relMatCodeEntity.getDescription())); |
|
1759 |
} |
|
1760 |
if (settingEntity.isShowRatingOnHomePage()) { |
|
1761 |
subJsonObject.put("RatingAvg", matCodeEntity.getRatingAvg() + ""); |
|
1762 |
} |
|
1763 |
if (settingEntity.isShowPrice()) { |
|
1764 |
|
|
1765 |
MatPriceEntity matPriceEntity = matPriceIfc.getMatPrice(relMatCodeEntity.getMatCode(), cltCode, null); |
|
1766 |
Double price = matPriceEntity.getPrice(); |
|
1767 |
subJsonObject.put("Price", price); // 实际价格,此价格可能低于“标价” |
|
1768 |
subJsonObject.put("SalesPrice", relMatCodeEntity.getSalesPrice()); // 标价 |
6e88ad
|
1769 |
subJsonObject.put("purchasePrice", relMatCodeEntity.getPurchasePrice()); // 采购单价 |
a6a76f
|
1770 |
|
22907b
|
1771 |
CurrencyEntity currencyEntity = new CurrencyEntity(request); |
87daf8
|
1772 |
subJsonObject.put("Currency", currencyEntity == null ? "" : currencyEntity.getCurrency()); |
F |
1773 |
subJsonObject.put("CurrencySign", currencyEntity == null ? "" : currencyEntity.getCurrencySign()); |
a6a76f
|
1774 |
} |
F |
1775 |
relMatJsonArray.add(subJsonObject); |
|
1776 |
} |
|
1777 |
jsonObject.put("relmatcode", relMatJsonArray); |
|
1778 |
|
|
1779 |
//取 维护抢购订金分组 明细 |
|
1780 |
if (depositDocCode != null && !"".equals(depositDocCode) && depositRowId != null && !"".equals(depositRowId)) { |
|
1781 |
PrepaidDepositDetailEntity prepaidDepositDetailEntity = prepaidDepositIfc.getPrepaidDepositDetail(depositDocCode, depositRowId, cltCode); |
|
1782 |
jsonObject.put("DepositAmount", prepaidDepositDetailEntity != null ? prepaidDepositDetailEntity.getDepositAmount() : 0); |
|
1783 |
jsonObject.put("ItemMemo", prepaidDepositDetailEntity != null ? prepaidDepositDetailEntity.getItemMemo() : ""); |
87daf8
|
1784 |
jsonObject.put("DepositDescription", |
F |
1785 |
imgData.getImageUrl(prepaidDepositDetailEntity != null ? prepaidDepositDetailEntity.getDepositDescription() : "", settingEntity.getImageProductWidth(), |
0d7208
|
1786 |
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(), |
F |
1787 |
settingEntity.isFromCached(), request) |
a6a76f
|
1788 |
); |
87daf8
|
1789 |
jsonObject.put("isPaidDeposit", prepaidDepositDetailEntity != null && prepaidDepositDetailEntity.isPaidDeposit()); //抢购订金分组 里的 rowid ,功能号 710170 |
a6a76f
|
1790 |
} |
F |
1791 |
/* |
|
1792 |
//未使用的优惠卷 |
|
1793 |
List<CouponEntity> couponList = couponIfc.getCouponList(cltCode, openId, matCode, false, wx, shopCcCodeEntity.getShopCcCode()); |
|
1794 |
JsonArray couponListJsonArray = new JsonArray(); |
|
1795 |
for (int i = 0; couponList != null && i < couponList.size(); i++) { |
|
1796 |
CouponEntity couponEntity = couponList.get(i); |
|
1797 |
JsonObject couponEntityJsonObject = new JsonObject(); |
|
1798 |
couponEntityJsonObject.addProperty("CouponName", couponEntity.getCouponName()); //使用范围 |
|
1799 |
couponEntityJsonObject.addProperty("CouponDocCode", couponEntity.getCouponDocCode()); //优惠券单号 |
|
1800 |
couponEntityJsonObject.addProperty("CouponCode", couponEntity.getCouponCode()); //优惠券代码 |
|
1801 |
couponEntityJsonObject.addProperty("Type", couponEntity.getType()); //优惠劵类型: 1 折扣(%) , 2 固定金额 |
|
1802 |
couponEntityJsonObject.addProperty("Discount", couponEntity.getDiscount()); //优惠折扣(%) |
|
1803 |
couponEntityJsonObject.addProperty("SufficeAmount", couponEntity.getSufficeAmount()); //满多少金额可用 |
|
1804 |
couponEntityJsonObject.addProperty("Total", couponEntity.getTotal()); //优惠金额 |
|
1805 |
//couponStatus : //0 正常:可以抢 ; 1 已经抢完 ; 2 未开抢 ; 3 已经抢过了,不能重复抢 ; 4 已经提醒(微信模板消息提醒) |
|
1806 |
couponEntityJsonObject.addProperty("Status", couponEntity.getCouponStatus()); |
|
1807 |
couponEntityJsonObject.addProperty("UsesTotal", couponEntity.getUsesTotal()); //本优惠卷总张数 |
|
1808 |
couponEntityJsonObject.addProperty("UsedTimes", couponEntity.getUsedTimes()); //本优惠卷已抢的数量 |
|
1809 |
|
|
1810 |
couponEntityJsonObject.addProperty("BalanceSecond", couponEntity.getBalanceSecond()); //抢券开始时间余下的秒数,负数表示倒计时早已结束 |
|
1811 |
couponEntityJsonObject.addProperty("DateStart", couponEntity.getDateStart() == null ? "" : sdf2.format(couponEntity.getDateStart())); //抢券开始时间 |
|
1812 |
couponEntityJsonObject.addProperty("DateEnd", couponEntity.getDateEnd() == null ? "" : sdf2.format(couponEntity.getDateEnd())); //抢券结束时间 |
|
1813 |
|
|
1814 |
couponEntityJsonObject.addProperty("EffectiveDateStart", couponEntity.getEffectiveDateStart() == null ? "" : sdf.format(couponEntity.getEffectiveDateStart())); //有效使用开始期 |
|
1815 |
couponEntityJsonObject.addProperty("EffectiveDateEnd", couponEntity.getEffectiveDateEnd() == null ? "" : sdf.format(couponEntity.getEffectiveDateEnd())); //有效使用结束期 |
|
1816 |
couponEntityJsonObject.addProperty("Photo", imgData.getImageUrl(couponEntity.getPhoto(), 120, 120, settingEntity.isShowPopupOrgImage(), settingEntity.isFromCached(), request)); |
|
1817 |
couponEntityJsonObject.addProperty("BannerImage", imgData.getImageUrl(couponEntity.getBannerImage(), settingEntity.getImageBannerWidth(), settingEntity.getImageBannerHeight(), settingEntity.isShowBannerOrgImage(), settingEntity.isFromCached(), request)); |
|
1818 |
|
|
1819 |
//已抢% |
|
1820 |
int progressRate = (couponEntity.getUsesTotal() == 0 ? 0 : couponEntity.getUsedTimes() * 100 / couponEntity.getUsesTotal()); |
|
1821 |
couponEntityJsonObject.addProperty("ProgressRate", progressRate); //已抢进度% |
|
1822 |
couponListJsonArray.add(couponEntityJsonObject); |
|
1823 |
} |
|
1824 |
json.add("CouponList", couponListJsonArray); |
|
1825 |
|
|
1826 |
*/ |
799c0b
|
1827 |
|
F |
1828 |
//----------获取 sku 参数,用于“加入购物车” 或“立即购买” 时弹出选择,Added by Johns Wang,2021-01-30 |
|
1829 |
List<Map> skuMatCodeJsonArray = new ArrayList<>(); |
ce46b2
|
1830 |
SkuMatCodeEntity skuMatCodeEntity=null; |
F |
1831 |
List<Map> skuParameterJsonArray = new ArrayList<>(); |
|
1832 |
if(matCodeEntity.isStartupSkuParameters()) { |
|
1833 |
List<SkuParameterEntity> skuParameterList = matCodeIfc.getSkuParameter(matCodeEntity.getMatCode(), shopCcCodeEntity.getShopCcCode(), |
|
1834 |
null, null, null, null, null, null, null, null, null, null); |
|
1835 |
skuMatCodeEntity = matCodeIfc.getSkuMatCodeByMatCode(matCodeEntity.getMatCode(), openId); |
|
1836 |
|
|
1837 |
|
|
1838 |
// 根据skuSetId去重,并按 SkuSetSort 排序输出 |
|
1839 |
List<SkuParameterEntity> skuSetList = skuParameterList.stream().collect( |
|
1840 |
Collectors.collectingAndThen( |
|
1841 |
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SkuParameterEntity::getSkuSetId))), ArrayList::new) |
|
1842 |
); |
|
1843 |
for (int i = 0; skuSetList != null && i < skuSetList.size(); i++) { |
|
1844 |
Map skuSetEntityJsonObject = new HashMap(); |
|
1845 |
Integer skuSetId = skuSetList.get(i).getSkuSetId(); |
|
1846 |
skuSetEntityJsonObject.put("skuSetSort", skuSetList.get(i).getSkuSetSort()); |
|
1847 |
skuSetEntityJsonObject.put("skuSetId", skuSetId); |
|
1848 |
skuSetEntityJsonObject.put("skuSetName", skuSetList.get(i).getSkuSetName()); |
|
1849 |
List<SkuParameterEntity> skuList = skuParameterList.stream().filter(s -> s.getSkuSetId().intValue() == skuSetId.intValue()).collect(Collectors.toList()); |
|
1850 |
List<Map> skuListJsonArray = new ArrayList<>(); |
|
1851 |
for (int j = 0; skuList != null && j < skuList.size(); j++) { |
|
1852 |
Map skuEntityJsonObject = new HashMap(); |
|
1853 |
//skuEntityJsonObject.addProperty("skuSetId", skuList.get(j).getSkuSetId()); |
|
1854 |
skuEntityJsonObject.put("skuSort", skuList.get(j).getSkuSort()); |
|
1855 |
skuEntityJsonObject.put("skuId", skuList.get(j).getSkuId()); |
|
1856 |
skuEntityJsonObject.put("skuName", skuList.get(j).getSkuName()); |
|
1857 |
skuEntityJsonObject.put("isEnableSelection", skuList.get(j).isEnableSelection()); |
|
1858 |
skuListJsonArray.add(skuEntityJsonObject); |
|
1859 |
} |
|
1860 |
skuSetEntityJsonObject.put("skuList", skuListJsonArray); |
|
1861 |
skuParameterJsonArray.add(skuSetEntityJsonObject); |
|
1862 |
} |
799c0b
|
1863 |
} |
ce46b2
|
1864 |
jsonObject.put("SkuParameterList", skuParameterJsonArray); |
F |
1865 |
|
|
1866 |
if (skuMatCodeEntity != null) { |
|
1867 |
Map skuEntityJsonObject = new HashMap(); |
|
1868 |
skuEntityJsonObject.put("skuId1", skuMatCodeEntity.getSkuId1()); |
|
1869 |
skuEntityJsonObject.put("skuName1", skuMatCodeEntity.getSkuName1()); |
|
1870 |
skuEntityJsonObject.put("skuId2", skuMatCodeEntity.getSkuId2()); |
|
1871 |
skuEntityJsonObject.put("skuName2", skuMatCodeEntity.getSkuName2()); |
|
1872 |
skuEntityJsonObject.put("skuId3", skuMatCodeEntity.getSkuId3()); |
|
1873 |
skuEntityJsonObject.put("skuName3", skuMatCodeEntity.getSkuName3()); |
|
1874 |
skuEntityJsonObject.put("skuId4", skuMatCodeEntity.getSkuId4()); |
|
1875 |
skuEntityJsonObject.put("skuName4", skuMatCodeEntity.getSkuName4()); |
|
1876 |
skuEntityJsonObject.put("skuId5", skuMatCodeEntity.getSkuId5()); |
|
1877 |
skuEntityJsonObject.put("skuName5", skuMatCodeEntity.getSkuName5()); |
|
1878 |
skuEntityJsonObject.put("skuId6", skuMatCodeEntity.getSkuId6()); |
|
1879 |
skuEntityJsonObject.put("skuName6", skuMatCodeEntity.getSkuName6()); |
|
1880 |
skuEntityJsonObject.put("skuId7", skuMatCodeEntity.getSkuId7()); |
|
1881 |
skuEntityJsonObject.put("skuName7", skuMatCodeEntity.getSkuName7()); |
|
1882 |
skuEntityJsonObject.put("skuId8", skuMatCodeEntity.getSkuId8()); |
|
1883 |
skuEntityJsonObject.put("skuName8", skuMatCodeEntity.getSkuName8()); |
|
1884 |
skuEntityJsonObject.put("skuId9", skuMatCodeEntity.getSkuId9()); |
|
1885 |
skuEntityJsonObject.put("skuName9", skuMatCodeEntity.getSkuName9()); |
|
1886 |
skuEntityJsonObject.put("skuId10", skuMatCodeEntity.getSkuId10()); |
|
1887 |
skuEntityJsonObject.put("skuName10", skuMatCodeEntity.getSkuName10()); |
|
1888 |
skuEntityJsonObject.put("MatCode", skuMatCodeEntity.getMatCode()); |
|
1889 |
skuEntityJsonObject.put("MatName", skuMatCodeEntity.getMatName()); |
|
1890 |
skuEntityJsonObject.put("Special", skuMatCodeEntity.getSpecial()); |
|
1891 |
skuEntityJsonObject.put("PhotoPath", skuMatCodeEntity.getPhotoPath()); |
|
1892 |
skuMatCodeJsonArray.add(skuEntityJsonObject); |
|
1893 |
} |
|
1894 |
jsonObject.put("SkuMatCodeList", skuMatCodeJsonArray); |
799c0b
|
1895 |
|
F |
1896 |
|
a6a76f
|
1897 |
return jsonObject; |
F |
1898 |
|
|
1899 |
} catch (Exception e) { |
|
1900 |
e.printStackTrace(); |
|
1901 |
throw new ApplicationException(this.getErrorMsg(e)); |
|
1902 |
} finally { |
|
1903 |
SpObserver.setDBtoInstance(); |
|
1904 |
} |
|
1905 |
} |
|
1906 |
|
|
1907 |
} |