PickBiz.java
25.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
package com.cjs.site.biz.user.pick;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import com.cjs.site.dao.user.pick.*;
import com.cjs.site.util.lang.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cjs.site.biz.ServiceException;
import com.cjs.site.biz.pub.ZhaoonlineBiz;
import com.cjs.site.biz.user.fund.FundBiz;
import com.cjs.site.dao.pub.OtcExchangeDateDao;
import com.cjs.site.dao.user.account.ClientInfoDao;
import com.cjs.site.dao.user.account.UserAddressDao;
import com.cjs.site.model.pub.ConstInfo;
import com.cjs.site.model.pub.ResultInfo;
import com.cjs.site.model.user.account.ClientInfo;
import com.cjs.site.model.user.account.UserAddressInfo;
import com.cjs.site.model.user.account.UserInfo;
import com.cjs.site.model.user.pick.InventoryInfo;
import com.cjs.site.model.user.pick.OutpropApplyInfo;
import com.cjs.site.model.user.pick.OutpropApplyPickInfo;
import com.cjs.site.model.user.pick.PickPackageInfo;
import com.cjs.site.model.user.pick.WarehouseInfo;
import com.cjs.site.util.lang.DateEnum;
import com.cjs.site.util.lang.DateUtil;
import com.cjs.site.util.redis.JedisTemplate;
import com.cjs.site.util.t2.T2Result;
import com.cjs.site.util.t2.T2Util;
import com.cjs.site.util.web.ActionUtil;
/**
* 提货
*
* @author tongyufu
*
*/
@Service
public class PickBiz {
Logger log = LogManager.getLogger();
@Autowired
private JedisTemplate jedisTemplate;
@Autowired
private OutpropApplyPickDao pickDao;
@Autowired
private OutpropApplyDao outpropApplyDao;
@Autowired
private UserAddressDao userAddressDao;
@Autowired
private ClientInfoDao clientInfoDao;
@Autowired
private FundBiz fundBiz;
@Autowired
private ZhaoonlineBiz zhaoonlineBiz;
@Autowired
private PositionBiz positionBiz;
@Autowired
private OtcExchangeDateDao otcExchangeDateDao;
@Autowired
private PickPackageDao pickPackageDao;
@Autowired
private WarehouseDao warehouseDao;
@Autowired
private WarehouseBiz warehouseBiz;
@Autowired
private InventoryDao inventoryDao;
@Autowired
private PickPackDao pickPackDao;
/**
* 封装费用汇总
*/
@SuppressWarnings("unchecked")
public Double pickPackFeeAmount() {
HttpSession session = ActionUtil.getRequest().getSession();
List<OutpropApplyInfo> applyList = (List<OutpropApplyInfo>) session
.getAttribute("applyList");
double amount = 0;
if (applyList == null) {
throw new ServiceException("提货列表不能为空");
}
for (OutpropApplyInfo apply : applyList) {
amount += apply.getPackFee() * apply.getOccurAmount();
}
return amount;
}
/**
* 自提
*/
@SuppressWarnings("unchecked")
public ResultInfo selfPick(OutpropApplyPickInfo pickInfo) {
//提货方式(0:本人自提;1:委托自提;2:物流;3:转赵涌在线;4:网点自提;5:网点委托)
String pickType = StringUtils.isBlank(pickInfo.getDelegateName()) ? "0" : "1";
String pickDate = pickInfo.getPickDate();
String warehousePickDate = pickInfo.getPickDate();
OutpropApplyInfo applyInfo = new OutpropApplyInfo();
ClientInfo clientInfo = clientInfoDao.queryByClientId(ActionUtil.getUser().getUserId());
ResultInfo resultInfo = null;
String warehouseCode = pickInfo.getWarehouseCode();
HttpSession session = ActionUtil.getRequest().getSession();
if ("1".equals(pickType)) {
if (StringUtils.isBlank(pickInfo.getDelegateId())) {
return new ResultInfo(0, "委托人证件号码不能为空");
}
if (StringUtils.isBlank(pickInfo.getDelegateName())) {
return new ResultInfo(0, "委托人姓名不能为空");
}
applyInfo.setPickingName(pickInfo.getDelegateName());
applyInfo.setIdNo(pickInfo.getDelegateId());
} else {
applyInfo.setPickingName(clientInfo.getClientName());
}
/* resultInfo = this.checkPickTime(9, 16);
if (resultInfo.getCode() == 0) {
return resultInfo;
}*/
if (StringUtils.isNotBlank(warehouseCode)) {
WarehouseInfo warehouse = warehouseDao.queryByCode(warehouseCode);
//Integer startHour = warehouseBiz.getHour(warehouse.getBusinessStartTime());
//Integer endHour = warehouseBiz.getHour(warehouse.getBusinessEndTime());
String pickAddress = warehouse.getProvince() + warehouse.getCity() + warehouse.getArea()
+ warehouse.getAddress();
warehouse = warehouseBiz.parseWarehouseTime(warehouse);
warehousePickDate += " " + warehouse.getBusinessStartTime();
warehousePickDate += "-" + warehouse.getBusinessEndTime();
//resultInfo = this.checkPickTime(startHour, endHour);
applyInfo.setPickingAddress(pickAddress);
pickType = StringUtils.isBlank(pickInfo.getDelegateName()) ? "4" : "5";
}
if (StringUtils.isBlank(pickDate)) {
return new ResultInfo(0, "提货日期不能为空");
}
pickDate = this.createPickDate(pickDate);
pickInfo.setPickDate(pickDate);
pickInfo.setPickType(pickType);
pickInfo.setInsurance(0);
//提货详细信息
applyInfo.setPickType("01");
applyInfo.setPhoneCode(clientInfo.getMobileTel());
resultInfo = this.pick(pickInfo, applyInfo);
if (resultInfo.getCode() != 0) {
if (StringUtils.isBlank(warehouseCode)) {
warehousePickDate += " 9:00-16:00";
} else {
List<OutpropApplyInfo> applyList = (List<OutpropApplyInfo>) session
.getAttribute("applyList");
this.updateInventory(applyList, warehouseCode);
}
pickInfo.setPickDate(warehousePickDate);
if ("0".equals(pickInfo.getPickType()) || "4".equals(pickInfo.getPickType())) {
pickInfo.setPickType("本人自提");
} else {
pickInfo.setPickType("委托自提");
}
}
return resultInfo;
}
/**
* 顺丰到付
*/
public ResultInfo expressPick(OutpropApplyPickInfo pickInfo, Integer addressId) {
// ResultInfo resultInfo = this.checkPickTime(9, 16);
/* if (resultInfo.getCode() == 0) {
return resultInfo;
}*/
if (pickInfo.getInsuranceType() == null) {
return new ResultInfo(0, "请选择投保方式");
}
if (pickInfo.getInsuranceType() == 1) {
if (pickInfo.getInsurance() == null || pickInfo.getInsurance() < 1000) {
return new ResultInfo(0, "投保金额不能低于1000元");
}
}
HttpSession session = ActionUtil.getRequest().getSession();
UserAddressInfo addressInfo = userAddressDao.queryById(addressId);
OutpropApplyInfo applyInfo = new OutpropApplyInfo();
String pickDate = this.createPickDate("");
String pack = (String) session.getAttribute("pack"); //0:普通自提;1:封装自提
if (addressInfo == null) {
return new ResultInfo(0, "收货地址不存在");
}
//提货详细信息
applyInfo.setPickType("02");
applyInfo.setPhoneCode(addressInfo.getMobileNo());
applyInfo.setExpressAddress(addressInfo.getAddress());
applyInfo.setPickingName(addressInfo.getUserName());
pickInfo.setPickType("2");
pickInfo.setPickDate(pickDate);
//普通自提时检查是否需要合并取货单
if ("0".equals(pack)) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("pickingName", addressInfo.getUserName());
params.put("expressAddress", addressInfo.getAddress());
params.put("phoneCode", addressInfo.getMobileNo());
params.put("initDate", DateUtil.getNow(DateEnum.UNSIGNED_DATE));
List<OutpropApplyInfo> beforeApplys = outpropApplyDao.search(params);
if (!beforeApplys.isEmpty()) {
pickInfo.setPickNo(beforeApplys.get(0).getOpStation());
pickInfo.setMerge(true);
}
}
return this.pick(pickInfo, applyInfo);
}
/**转赵涌在线拍卖*/
public ResultInfo zhaoonlinePick(OutpropApplyPickInfo pickInfo) {
//ResultInfo resultInfo = this.checkPickTime(9, 16);
/* if (resultInfo.getCode() == 0) {
return resultInfo;
}*/
try {
zhaoonlineBiz.checkZhaoonlineId(pickInfo.getZhaoonlineId());
} catch (ServiceException e) {
return new ResultInfo(0, e.getMessage());
}
//提货详细信息
ClientInfo clientInfo = clientInfoDao.queryByClientId(ActionUtil.getUser().getUserId());
OutpropApplyInfo applyInfo = new OutpropApplyInfo();
applyInfo.setPickType("01");
applyInfo.setPhoneCode(clientInfo.getMobileTel());
applyInfo.setPickingName(clientInfo.getClientName());
applyInfo.setExpressAddress("转赵涌在线:" + pickInfo.getZhaoonlineId());
pickInfo.setZhaoonlineId(pickInfo.getZhaoonlineId());
pickInfo.setPickType("3");
pickInfo.setInsurance(0);
pickInfo.setPickDate(this.createPickDate(""));
return this.pick(pickInfo, applyInfo);
}
/**
* 提货
* @param pickInfo
* @return code(0:全部失败;1:成功;2:部分失败)
*/
@SuppressWarnings("unchecked")
private ResultInfo pick(OutpropApplyPickInfo pickInfo, OutpropApplyInfo applyInfo) {
UserInfo user = ActionUtil.getUser();
HttpSession session = ActionUtil.getRequest().getSession();
List<OutpropApplyInfo> applyList = (List<OutpropApplyInfo>) session
.getAttribute("applyList");
Map<String, T2Result> resultMap = new HashMap<String, T2Result>();
Integer pickAmount = 0;
ResultInfo resultInfo = this.valid(applyList, pickInfo, user);
String pickNo = pickInfo.getPickNo();
int successAmount = 0;
String pack = (String) session.getAttribute("pack"); //0:普通自提;1:封装自提
if (resultInfo.getCode() == 0) {
return resultInfo;
}
if (!pickInfo.isMerge()) {
pickNo = this.createPickNo();
}
applyInfo.setOpStation(pickNo);
for (OutpropApplyInfo apply : applyList) {
apply.setOpStation(pickNo);
applyInfo.setOtcCode(apply.getOtcCode());
applyInfo.setOtcName(apply.getOtcName());
applyInfo.setOccurAmount(apply.getOccurAmount());
applyInfo.setPickingDate(pickInfo.getPickDate());
T2Result t2Result = pickServiceSelf(user, applyInfo);
apply.setResultCode(t2Result.getCode());
resultMap.put(apply.getOtcCode(), t2Result);
pickAmount += apply.getOccurAmount();
applyInfo.setOpStation(pickNo);
pickPackDao.insertPick(this.compent(applyInfo));
if (t2Result.getCode() == 0) {
successAmount++;
//修改提货封装费用
if ("1".equals(pack)) {
outpropApplyDao.updateApply(apply);
}
}
}
session.setAttribute("applyList", applyList);
if (successAmount > 0) {
pickInfo.setClientId(user.getClient_id());
pickInfo.setPickNo(pickNo);
pickInfo.setPickAmount(pickAmount);
pickInfo.setCreateDate(DateUtil.getNow(DateEnum.UNSIGNED_DATE));
pickInfo.setCreateTime(DateUtil.getNow(DateEnum.UNSIGNED_TIME));
pickInfo.setPickDate(DateUtil.getNow(DateEnum.UNSIGNED_DATE));
if (pickInfo.getInsurance() == null) {
pickInfo.setInsurance(0);
}
if (!pickInfo.isMerge()) {
pickDao.save(pickInfo);
}
//提货接口默认记录当前用户身份证号码,所以修改为委托人身份证号码
if (StringUtils.isNotBlank(pickInfo.getDelegateId())) {
outpropApplyDao.updateIdNo(applyInfo);
}
}
resultInfo = this.pickResult(resultMap, pickNo);
if (resultInfo.getCode() == 0) {
return resultInfo;
}
String userId = ActionUtil.getUser().getUserId();
Map<String, Object> balance = pickPackDao.queryUserFundAccount(userId);//fundBiz.balance(userId);
Double enableBalance = 0.00;
if(balance!=null && balance.get("enable_balance") != null){
enableBalance = Double.valueOf(balance.get("enable_balance").toString());
}
//普通物流提货,收取6元物流包装费
if ("0".equals(pack) && "2".equals(pickInfo.getPickType())) {
if (pickInfo.isMerge()) {
pickDao.mergeOrder(pickInfo);
} else {
if(enableBalance >= 6){
//收取6元物流包装费
T2Result result = this.subtractSysFund(pickInfo.getPickNo(),
ConstInfo.Fund.USER_PICK, user.getClient_id(), -6.0,
ConstInfo.Fund.USER_PICK_REMARK);
log.info("收取提货包装费[" + pickInfo.getPickNo() + "]:" + result);
}
}
}
//封装提货,收取费用
if ("1".equals(pack)) {
if(enableBalance >= pickInfo.getAmountFee()){
T2Result result = this.subtractSysFund(pickInfo.getPickNo(),
ConstInfo.Fund.USER_PICK, user.getClient_id(), -pickInfo.getAmountFee(),
ConstInfo.Fund.USER_PICK_REMARK);
log.info("收取提货包装费[" + pickInfo.getPickNo() + "]:" + result);
}
}
return resultInfo;
}
private Map<String,Object> compent(OutpropApplyInfo apply){
Map<String,Object> dbPickInfo = new HashMap<String, Object>();
dbPickInfo.put("initDate",DateUtil.getNow(DateEnum.UNSIGNED_DATE));
dbPickInfo.put("ocurrDate",DateUtil.getNow(DateEnum.UNSIGNED_DATE));
dbPickInfo.put("opStation",apply.getOpStation());
dbPickInfo.put("otcCode",apply.getOtcCode());
dbPickInfo.put("otcName",apply.getOtcName());
dbPickInfo.put("occurAmount",apply.getOccurAmount());
dbPickInfo.put("businessFlag","35902");
dbPickInfo.put("status","0");
dbPickInfo.put("picType",apply.getPickType());
dbPickInfo.put("postionStr", apply.getOpStation()+apply.getOtcCode()+System.currentTimeMillis());
dbPickInfo.put("pickName",apply.getPickingName());
dbPickInfo.put("pickDate",apply.getPickingDate()==null?DateUtil.getNow(DateEnum.UNSIGNED_DATE):apply.getPickingDate());
dbPickInfo.put("fee",0);
dbPickInfo.put("phone",apply.getPhoneCode()==null?"":apply.getPhoneCode());
dbPickInfo.put("idNo",apply.getIdNo()==null?"":apply.getIdNo());
if(StringUtils.isEmpty(apply.getPickingAddress())){
apply.setPickingAddress("上海市浦东新区盛荣路88弄盛大天地源创谷7号楼下沉式广场");
}
dbPickInfo.put("pikingAddress",apply.getPickingAddress() == null ?"无":apply.getPickingAddress());
dbPickInfo.put("address",apply.getExpressAddress()==null?"无":apply.getExpressAddress());
dbPickInfo.put("fundAccount",apply.getFundAccount());
dbPickInfo.put("serialNo",apply.getSerialNo());
return dbPickInfo;
}
public T2Result subtractSysFund(String businessId, String businessType, String userId,
Double money, String remark) {
//扣减用户余额
this.pickPackDao.ducueUserFundAmount(money,userId);
return new T2Result();
}
public T2Result pickServiceSelf(UserInfo user, OutpropApplyInfo applyInfo){
//扣减库存
this.pickPackDao.ducueUserInventory(applyInfo.getOccurAmount(),applyInfo.getOtcCode(),user.getClient_id());
T2Result result = new T2Result();
result.setCode(0);
return result;
}
/**提货数量验证*/
private ResultInfo valid(List<OutpropApplyInfo> applyList, OutpropApplyPickInfo pickInfo,
UserInfo user) {
if (applyList == null || applyList.isEmpty()) {
return new ResultInfo(0, "提货列表不能为空");
}
T2Result result = positionBiz.positionSelf(user);
List<Map<String, Object>> positions = result.getData();
List<InventoryInfo> inventories = new ArrayList<InventoryInfo>();
String message;
if (StringUtils.isNotBlank(pickInfo.getWarehouseCode())) {
inventoryDao.queryByWarehouseCode(pickInfo.getWarehouseCode());
}
//验证可提数量
for (OutpropApplyInfo apply : applyList) {
for (Map<String, Object> position : positions) {
String otcCode = position.get("otc_code").toString();
if (!StringUtils.equals(apply.getOtcCode(), otcCode)) {
continue;
}
Integer enableAmount = Double.valueOf(position.get("enable_amount").toString())
.intValue();
if (enableAmount < apply.getOccurAmount()) {
message = "提货失败:藏品[" + otcCode + "]可用数量为" + enableAmount + ",请重新输入提货数量";
return new ResultInfo(0, message);
}
}
//网点自提
for (InventoryInfo inventory : inventories) {
if (!StringUtils.equals(apply.getOtcCode(), inventory.getOtcCode())) {
continue;
}
if (inventory.getUsefulAmount() < apply.getOccurAmount()) {
message = "提货失败:藏品[" + inventory.getOtcCode() + "]可用数量为"
+ inventory.getUsefulAmount() + ",请重新输入提货数量";
return new ResultInfo(0, message);
}
}
}
//验证资金
HttpSession session = ActionUtil.getRequest().getSession();
String pack = (String) session.getAttribute("pack"); //0:普通自提;1:封装自提
double totalFee = 0;
String userId = ActionUtil.getUser().getUserId();
Map<String, Object> balance = pickPackDao.queryUserFundAccount(userId);//fundBiz.balance(userId);
Double enableBalance = 0.00;
if(balance!=null && balance.get("enable_balance") != null){
enableBalance = Double.valueOf(balance.get("enable_balance").toString());
}
//封装提货
if ("1".equals(pack)) {
Integer packageId = Integer.valueOf(session.getAttribute("packageId").toString());
PickPackageInfo pickPackageInfo = pickPackageDao.queryById(packageId);
if (pickPackageInfo != null) {
totalFee = pickPackageInfo.getPackageFee();
pickInfo.setPackageFee(pickPackageInfo.getPackageFee());
pickInfo.setPackageType(pickPackageInfo.getPackageName());
} else {
pickInfo.setPackageFee(0.0);
pickInfo.setPackageType("无需包装");
}
for (OutpropApplyInfo apply : applyList) {
totalFee += apply.getPackFee() * apply.getOccurAmount();
}
}
//物流包装费6元
if ("2".equals(pickInfo.getPickType())) {
pickInfo.setExpressPackFee(6.0);
totalFee += 6;
}
pickInfo.setAmountFee(totalFee);
/* if (enableBalance < totalFee) {
return new ResultInfo(0, "账户可用余额少于" + totalFee + "元,无法支付提货费用");
}*/
return new ResultInfo(1, "");
}
/**
* 提货接口
* @param user
* @return
*/
private T2Result pickService(UserInfo user, OutpropApplyInfo applyInfo) {
//提货 619501
Map<String, Object> params = new HashMap<String, Object>();
params.put("branch_no", "11");
params.put("otcexch_type", "O1");
params.put("op_branch_no", "11");
params.put("op_entrust_way", "7");
params.put("op_station", applyInfo.getOpStation());
params.put("password", user.getPassword());
params.put("user_token", " ");
params.put("client_id", user.getClient_id());
params.put("fund_account", user.getFund_account());
params.put("otc_account", user.getOtc_account());
params.put("otc_code", applyInfo.getOtcCode());
params.put("picking_unit", "");
params.put("occur_amount", applyInfo.getOccurAmount());
params.put("picking_type", applyInfo.getPickType()); //01:自提; 02:物流
if (StringUtils.isBlank(applyInfo.getPickingAddress())) {
params.put("picking_address", "上海漕河泾开发区田林路1016号科技绿洲三期5号楼");
} else {
params.put("picking_address", applyInfo.getPickingAddress());
}
params.put("express_fee", "");
params.put("express_address", applyInfo.getExpressAddress());
params.put("phone_code", applyInfo.getPhoneCode());
params.put("picking_date", applyInfo.getPickingDate());
params.put("picking_name", applyInfo.getPickingName());
T2Result result = T2Util.request(params, "619501");
log.info("[" + user.getClient_id() + "]提货结果:" + result);
return result;
}
/**生成订单号*/
private String createPickNo() {
String pickNo = DateUtil.getNow(DateEnum.UNSIGNED_DATE);
String sequence = jedisTemplate.incr(pickNo).toString();
sequence = StringUtils.leftPad(sequence, 4, "0");
return pickNo + sequence;
}
private ResultInfo pickResult(Map<String, T2Result> resultMap, String pickNo) {
StringBuilder msg = new StringBuilder();
ResultInfo resultInfo = new ResultInfo(1, "");
int errorCount = 0;
for (String otcCode : resultMap.keySet()) {
T2Result result = resultMap.get(otcCode);
if (result == null) {
msg.append("藏品[" + otcCode + "]提货失败");
msg.append("<br />");
errorCount++;
continue;
}
if (result.getCode() != 0) {
msg.append("藏品[" + otcCode + "]提货失败:" + result.getError().getErrorInfo());
msg.append("<br />");
errorCount++;
}
}
if (errorCount == resultMap.size()) {
resultInfo.setCode(0); //全部失败
resultInfo.setMessage(msg.toString());
} else if (errorCount > 0) {
resultInfo.setCode(2); //部分失败
resultInfo.setMessage(msg.toString());
}
//非全部失败,移除session
if (errorCount < resultMap.size()) {
//ActionUtil.getRequest().getSession().removeAttribute("applyList");
}
return resultInfo;
}
/**
* 提货日期为空时,为物流和转在线。
* 物流和转在线的提货日期统一为7天后,自提如果选择当天,则处理为后一个工作日
* @param pickDate
* @return
*/
private String createPickDate(String pickDate) {
Calendar calendar = Calendar.getInstance();
if (StringUtils.isBlank(pickDate)) {
calendar.add(Calendar.DATE, 14);
} else if (StringUtils.equals(pickDate, DateUtil.getNow(DateEnum.DATE))) {
calendar.add(Calendar.DATE, 1);
} else {
return DateUtil.parseDate(DateUtil.parseDate(pickDate, DateEnum.DATE),
DateEnum.UNSIGNED_DATE);
}
String date = DateUtil.parseDate(calendar.getTime(), DateEnum.UNSIGNED_DATE);
return otcExchangeDateDao.queryLastWorkDay(date);
}
/**检查提货时间*/
private ResultInfo checkPickTime(Integer startHour, Integer endHour) {
Map<String, Object> params = new HashMap<String, Object>();
String message = "请于交易日" + startHour + ":00 - " + endHour + ":00进行提货操作";
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour < startHour || hour >= endHour) {
return new ResultInfo(0, message);
}
params.put("function_id", "619824");
T2Result result = T2Util.request(params, "619824");
if ("0".equals(result.getData().get(0).get("business_flag"))) {
return new ResultInfo(0, message);
}
return new ResultInfo(1, "");
}
/**网点自提,减少库存*/
private void updateInventory(List<OutpropApplyInfo> applyList, String warehouseCode) {
InventoryInfo inventory = new InventoryInfo();
inventory.setWarehouseCode(warehouseCode);
for (OutpropApplyInfo apply : applyList) {
if (apply.getResultCode() == 0) {
inventory.setOtcCode(apply.getOtcCode());
inventory.setFrozenAmount(apply.getOccurAmount());
inventoryDao.updateAmount(inventory);
}
}
}
}