提交 | 用户 | age
|
a6a76f
|
1 |
package com.yc.sdk.shopping.action.jiazhuang; |
F |
2 |
|
|
3 |
|
9275c3
|
4 |
import java.math.BigDecimal; |
b3acab
|
5 |
import java.text.SimpleDateFormat; |
70d131
|
6 |
import java.util.Calendar; |
J |
7 |
import java.util.Date; |
b3acab
|
8 |
import java.util.List; |
8bf658
|
9 |
import java.util.stream.Collectors; |
b3acab
|
10 |
|
a6a76f
|
11 |
import javax.servlet.http.HttpServletRequest; |
F |
12 |
import javax.servlet.http.HttpServletResponse; |
|
13 |
import javax.servlet.http.HttpSession; |
|
14 |
|
|
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
16 |
import org.springframework.context.annotation.Scope; |
|
17 |
import org.springframework.dao.DataAccessException; |
70d131
|
18 |
import org.springframework.dao.DataAccessResourceFailureException; |
226142
|
19 |
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; |
a6a76f
|
20 |
import org.springframework.stereotype.Controller; |
3f0055
|
21 |
import org.springframework.web.bind.annotation.RequestBody; |
a6a76f
|
22 |
import org.springframework.web.bind.annotation.RequestMapping; |
F |
23 |
|
9275c3
|
24 |
import com.github.binarywang.wxpay.exception.WxPayException; |
b3acab
|
25 |
import com.google.gson.JsonArray; |
a6a76f
|
26 |
import com.google.gson.JsonObject; |
F |
27 |
import com.yc.action.BaseAction; |
226142
|
28 |
import com.yc.action.grid.QrCodeRunable; |
a6a76f
|
29 |
import com.yc.entity.DataSourceEntity; |
70d131
|
30 |
import com.yc.factory.FactoryBean; |
a6a76f
|
31 |
import com.yc.multiData.MultiDataSource; |
F |
32 |
import com.yc.multiData.SpObserver; |
ad9fb8
|
33 |
import com.yc.sdk.WebSocketMessage.action.WebSocketMessageServer; |
J |
34 |
import com.yc.sdk.WebSocketMessage.entity.MessageInfo; |
|
35 |
import com.yc.sdk.WebSocketMessage.entity.MessageType; |
6990b5
|
36 |
import com.yc.sdk.WebSocketMessage.entity.UserFromType; |
9275c3
|
37 |
import com.yc.sdk.miniapp.entity.MaSettingEntity; |
J |
38 |
import com.yc.sdk.miniapp.service.MaSettingIfc; |
|
39 |
import com.yc.sdk.shopping.action.Wxtransactions; |
b6cfc5
|
40 |
import com.yc.sdk.shopping.action.jiazhuang.task.PanicBuyingTaskIfc; |
70d131
|
41 |
import com.yc.sdk.shopping.entity.AddressEntity; |
2b1479
|
42 |
import com.yc.sdk.shopping.entity.AllowBuyingResult; |
74f517
|
43 |
import com.yc.sdk.shopping.entity.CheckServiceBalanceWhenRefundResult; |
a6a76f
|
44 |
import com.yc.sdk.shopping.entity.ConfirmEntity; |
F |
45 |
import com.yc.sdk.shopping.entity.CurrencyEntity; |
70d131
|
46 |
import com.yc.sdk.shopping.entity.CustomerEntity; |
a6a76f
|
47 |
import com.yc.sdk.shopping.entity.DocCodeStateEntity; |
70d131
|
48 |
import com.yc.sdk.shopping.entity.FreeEntity; |
J |
49 |
import com.yc.sdk.shopping.entity.PanicBuyingEntity; |
02cac6
|
50 |
import com.yc.sdk.shopping.entity.PanicBuyingOrderEntity; |
bd8e71
|
51 |
import com.yc.sdk.shopping.entity.PanicBuyingSellerEntity; |
226142
|
52 |
import com.yc.sdk.shopping.entity.QrCodeForAppEntity; |
74f517
|
53 |
import com.yc.sdk.shopping.entity.ReturnOrderResult; |
J |
54 |
import com.yc.sdk.shopping.entity.ReturnOrderResult.ReturnOrderDetailResult; |
3f0055
|
55 |
import com.yc.sdk.shopping.entity.SaveOrderParamters; |
b3acab
|
56 |
import com.yc.sdk.shopping.entity.SettingEntity; |
a6a76f
|
57 |
import com.yc.sdk.shopping.service.CurrencyIfc; |
70d131
|
58 |
import com.yc.sdk.shopping.service.FreeIfc; |
226142
|
59 |
import com.yc.sdk.shopping.service.MatCodeIfc; |
b3acab
|
60 |
import com.yc.sdk.shopping.service.SettingIfc; |
70d131
|
61 |
import com.yc.sdk.shopping.service.address.AddressIfc; |
226142
|
62 |
import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc; |
70d131
|
63 |
import com.yc.sdk.shopping.service.panicBuying.PanicBuyingIfc; |
a6a76f
|
64 |
import com.yc.sdk.shopping.service.panicBuying.PanicBuyingOrderIfc; |
70d131
|
65 |
import com.yc.sdk.shopping.service.register.AccountIfc; |
9275c3
|
66 |
import com.yc.sdk.shopping.service.wxpay.WxPayIfc; |
a6a76f
|
67 |
import com.yc.sdk.shopping.util.SettingKey; |
331b08
|
68 |
import com.yc.sdk.shopping.util.StringReplaceUtil; |
a6a76f
|
69 |
import com.yc.utils.SessionKey; |
F |
70 |
|
|
71 |
@Controller |
|
72 |
@Scope("prototype") |
d0c96b
|
73 |
@RequestMapping("/shopping/panicBuyingOrder.do") |
a6a76f
|
74 |
public class PanicBuyingOrder extends BaseAction { |
F |
75 |
@Autowired |
|
76 |
PanicBuyingOrderIfc panicBuyingOrderIfc; |
|
77 |
@Autowired |
|
78 |
CurrencyIfc currencyIfc; |
b3acab
|
79 |
@Autowired |
F |
80 |
SettingIfc settingIfc ; |
70d131
|
81 |
@Autowired |
J |
82 |
AccountIfc accountIfc; |
|
83 |
@Autowired |
|
84 |
PanicBuyingIfc panicBuyingIfc; |
|
85 |
@Autowired |
|
86 |
FreeIfc freeIfc; |
9275c3
|
87 |
@Autowired |
J |
88 |
WxPayIfc wxPayIfc; |
|
89 |
@Autowired |
|
90 |
MaSettingIfc maSettingIfc; |
226142
|
91 |
@Autowired |
J |
92 |
MatCodeIfc matCodeIfc; |
|
93 |
@Autowired |
|
94 |
ShoppingImageDataIfc imgData; |
b6cfc5
|
95 |
@Autowired |
J |
96 |
PanicBuyingTaskIfc panicBuyingTaskIfc ; |
a6a76f
|
97 |
|
F |
98 |
@RequestMapping(params = "m=saveOrder") |
3f0055
|
99 |
public void saveOrder(@RequestBody SaveOrderParamters saveOrderParamters , HttpServletRequest request, HttpServletResponse response) { |
a6a76f
|
100 |
//HttpSession session = request.getSession(); |
F |
101 |
JsonObject json = new JsonObject(); |
|
102 |
JsonObject errJson = new JsonObject(); |
|
103 |
|
|
104 |
String docCode = null; |
|
105 |
ConfirmEntity confirmEntity = null ; |
|
106 |
String corpId = null ; |
|
107 |
try { |
|
108 |
confirmEntity = new ConfirmEntity(request) ; |
|
109 |
corpId = request.getParameter(SessionKey.WEIXIN_CORPID) ; |
|
110 |
if (corpId == null || "".equals(corpId)) { |
|
111 |
corpId = request.getParameter(SessionKey.WEIXIN_APPID) ; |
|
112 |
} |
|
113 |
|
|
114 |
if (confirmEntity.getCltCode() == null || "".equals(confirmEntity.getCltCode())) { |
|
115 |
errJson.addProperty("warning", "客户不存在,请核实!"); |
|
116 |
json.add("error", errJson); |
|
117 |
this.printJson(response, json.toString()); |
|
118 |
return; |
|
119 |
} |
|
120 |
|
3f0055
|
121 |
// if (confirmEntity.getSelectedCartIds() == null || "".equals(confirmEntity.getSelectedCartIds())) { |
J |
122 |
// errJson.addProperty("warning", "没有可供生成订单的商品,请从购物车重新勾选商品!"); |
|
123 |
// json.add("error", errJson); |
|
124 |
// this.printJson(response, json.toString()); |
|
125 |
// return; |
|
126 |
// } |
a6a76f
|
127 |
} catch (Exception e) { |
F |
128 |
e.printStackTrace(); |
|
129 |
errJson.addProperty("warning", (e.getCause()!=null? e.getCause().getMessage():e.getMessage())); |
|
130 |
json.add("error", errJson); |
|
131 |
this.printJson(response, json.toString()); |
|
132 |
return; |
|
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
try { |
|
137 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
138 |
SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId()); |
a6a6b5
|
139 |
|
J |
140 |
FreeEntity freeEntity = freeIfc.getFreeEntity(saveOrderParamters.getFreeId()) ; |
|
141 |
if (freeEntity!=null && freeEntity.isRequiredAddress() && saveOrderParamters.getPaymentAddress()== null) { |
|
142 |
errJson.addProperty("warning", "请选择收货地址!"); |
|
143 |
json.add("error", errJson); |
|
144 |
this.printJson(response, json.toString()); |
|
145 |
return; |
|
146 |
} |
|
147 |
|
|
148 |
|
a6a76f
|
149 |
//微信支付金额,此金额是在 p710806v3 存付过程里计算出来的 |
F |
150 |
double weiXinPayAmount = 0; |
|
151 |
CurrencyEntity currencyEntity = currencyIfc.getUserCurrency(confirmEntity.getUserCode()); |
|
152 |
confirmEntity.setCurrency(currencyEntity.getCurrency()); |
|
153 |
|
3f0055
|
154 |
if (saveOrderParamters.getPaymentAddress()!=null) confirmEntity.setPaymentAddress(saveOrderParamters.getPaymentAddress()); |
J |
155 |
if (saveOrderParamters.getFreeId()!=null) confirmEntity.setFreeId(saveOrderParamters.getFreeId()); |
|
156 |
if (saveOrderParamters.getPanicBuyingDocCode()!=null) confirmEntity.setPanicBuyingDocCode(saveOrderParamters.getPanicBuyingDocCode()); |
|
157 |
if (saveOrderParamters.getQuantity()!=null) confirmEntity.setQuantity(saveOrderParamters.getQuantity()); |
|
158 |
if (saveOrderParamters.getComment()!=null) confirmEntity.setComment(saveOrderParamters.getComment()); |
|
159 |
if (saveOrderParamters.getBalancePayAmount()!=null) confirmEntity.setBalancePayAmount(saveOrderParamters.getBalancePayAmount()); |
|
160 |
|
2b1479
|
161 |
//检查是否超过限购数量 |
J |
162 |
AllowBuyingResult allowBuyingResult = panicBuyingOrderIfc.isAllowBuying( confirmEntity.getPanicBuyingDocCode(),confirmEntity.getOpenId(),confirmEntity.getQuantity()); |
|
163 |
if (allowBuyingResult!=null&&!allowBuyingResult.isAllowBuying()&& !"".equals(allowBuyingResult.getMessage())) { |
|
164 |
errJson.addProperty("warning", allowBuyingResult.getMessage()); |
|
165 |
json.add("error", errJson); |
|
166 |
this.printJson(response, json.toString()); |
|
167 |
return; |
|
168 |
} |
|
169 |
|
|
170 |
//提交订单 |
a6a76f
|
171 |
DocCodeStateEntity docCodeStateEntity = panicBuyingOrderIfc.saveOrder(confirmEntity); |
226142
|
172 |
|
a6a76f
|
173 |
if (docCodeStateEntity != null) { |
b6cfc5
|
174 |
//到期未支付的,是定时取消订单 |
J |
175 |
panicBuyingTaskIfc.addCancelOrderTaskForPayingExpired( dataSourceEntity,docCodeStateEntity.getDocCode()) ; |
|
176 |
|
226142
|
177 |
//--增加处理单据确认后生成二维码,线程处理 |
J |
178 |
ThreadPoolTaskScheduler threadPoolTaskScheduler = (ThreadPoolTaskScheduler) FactoryBean.getBean("threadPoolTaskScheduler"); |
|
179 |
threadPoolTaskScheduler.execute(new QrCodeRunable(docCodeStateEntity.getFormId(), docCodeStateEntity.getFormType(),docCodeStateEntity.getDocCode() |
|
180 |
, confirmEntity.getCltCode(),confirmEntity.getCltName(), dataSourceEntity.getDbId()+"")); |
|
181 |
|
a6a76f
|
182 |
docCode = docCodeStateEntity.getDocCode(); |
F |
183 |
json.addProperty("DocStatus", docCodeStateEntity.getDocStatus()); |
|
184 |
json.addProperty("isAllowPayable", docCodeStateEntity.getIsAllowPayable()); |
|
185 |
weiXinPayAmount = docCodeStateEntity.getWeiXinPayAmount(); |
|
186 |
} |
|
187 |
json.addProperty(SettingKey.DOCCODE, docCode); |
3f0055
|
188 |
json.addProperty("formid", "710806"); |
a6a76f
|
189 |
json.addProperty("weiXinPayAmount", weiXinPayAmount); //如果有月结客户,则不需要支付 |
F |
190 |
json.addProperty("status", "success"); |
|
191 |
//json.addProperty("redirect", redirect); |
|
192 |
this.printJson(response, json.toString()); |
|
193 |
return; |
|
194 |
|
|
195 |
} catch (DataAccessException e) { |
|
196 |
e.printStackTrace(); |
|
197 |
errJson.addProperty("warning", (e.getCause()!=null?e.getCause().getMessage():e.getMessage())); |
|
198 |
json.add("error", errJson); |
|
199 |
this.printJson(response, json.toString()); |
|
200 |
return; |
|
201 |
} catch (Exception e) { |
|
202 |
e.printStackTrace(); |
|
203 |
errJson.addProperty("warning", (e.getCause()!=null?e.getCause().getMessage():e.getMessage())); |
|
204 |
json.add("error", errJson); |
|
205 |
this.printJson(response, json.toString()); |
|
206 |
return; |
|
207 |
} finally { |
|
208 |
SpObserver.setDBtoInstance(); |
|
209 |
} |
|
210 |
} |
70d131
|
211 |
|
J |
212 |
/** |
|
213 |
* 获取活动订单确认时的信息 json 数据格式(小程序需要用到) |
|
214 |
* @param request |
|
215 |
* @param response |
|
216 |
*/ |
|
217 |
@RequestMapping(params = "m=getPanicBuyingConfirmInfo") |
|
218 |
public void getPanicBuyingConfirmInfo(HttpServletRequest request, HttpServletResponse response) { |
|
219 |
HttpSession session = request.getSession(); |
|
220 |
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID); |
|
221 |
//String userCode = (session.getAttribute(SessionKey.USERCODE) == null ? "" : (String)session.getAttribute(SessionKey.USERCODE)); |
|
222 |
String openId = (session.getAttribute(SessionKey.WEIXIN_OPENID) == null ? "" : (String) session.getAttribute(SessionKey.WEIXIN_OPENID) ) ; |
|
223 |
//String sessionId = session.getId(); |
|
224 |
String cltCode = (session.getAttribute(SettingKey.CLTCODE) == null?"": (String)session.getAttribute(SettingKey.CLTCODE)) ; |
|
225 |
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
|
226 |
String hostUrl = SettingKey.getHostUrl(request); |
|
227 |
|
|
228 |
JsonObject json = new JsonObject(); |
|
229 |
JsonObject errJson = new JsonObject(); |
|
230 |
|
|
231 |
|
|
232 |
SettingEntity settingEntity = null; |
|
233 |
List<FreeEntity> freeList = null; |
|
234 |
AddressEntity addressEntity = null ; |
|
235 |
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request); |
|
236 |
|
|
237 |
try { |
|
238 |
ConfirmEntity confirmEntity = new ConfirmEntity(request) ; |
|
239 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
240 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
241 |
AddressIfc myAddressIfc = (AddressIfc) FactoryBean.getBean("AddressImpl"); |
|
242 |
try { |
|
243 |
//交货地址 |
|
244 |
addressEntity = myAddressIfc.getAddressByAddressId(confirmEntity.getPaymentAddress(), cltCode); |
|
245 |
}catch (Exception e) { |
|
246 |
if (e instanceof DataAccessResourceFailureException) { //The connection is closed , 该连接已关闭 |
|
247 |
try { |
|
248 |
System.out.println(this.getClass()+" 准备第二次获取地址"); |
|
249 |
//交货地址,有 The connection is closed 错误时,再执行一次 |
|
250 |
addressEntity = myAddressIfc.getAddressByAddressId(confirmEntity.getPaymentAddress(), cltCode); |
|
251 |
|
|
252 |
} catch (Exception e2) { |
|
253 |
System.out.println(this.getClass()+" 第二次获取地址时出错:" + ( e2.getCause()!=null? e2.getCause().getMessage():e2.getMessage())); |
|
254 |
throw e2; |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
settingEntity = settingIfc.getSettingEntity() ; |
|
262 |
//取网店 shopcccode |
|
263 |
//ShopCcCodeEntity shopCcCodeEntity = ShopCcCode.getShopCcCode(settingEntity,request); |
|
264 |
|
|
265 |
//检查该客户是否存在 |
|
266 |
if (openId != null && !"".equals(openId)) { |
|
267 |
CustomerEntity customerEntity = accountIfc.getLoginInfoByMiniAppOpenId(openId); |
|
268 |
if (customerEntity==null || customerEntity.getCltCode()==null||customerEntity.getCltCode().equals("")) { |
|
269 |
cltCode = null; |
|
270 |
session.removeAttribute(SettingKey.CLTCODE); |
|
271 |
} |
|
272 |
} |
|
273 |
|
|
274 |
//检查该客户是否存在 |
|
275 |
if (cltCode != null && !"".equals(cltCode)) { |
|
276 |
|
|
277 |
CustomerEntity customerEntity = accountIfc.getLoginInfoByCltCode(cltCode,cltCode,cltCode); |
|
278 |
if (customerEntity==null || customerEntity.getCltCode()==null||customerEntity.getCltCode().equals("")) { |
|
279 |
cltCode = null; |
|
280 |
session.removeAttribute(SettingKey.CLTCODE); |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
if (cltCode == null || "".equals(cltCode) ) { |
|
285 |
json.addProperty(SettingKey.CLTCODE, ""); |
|
286 |
errJson.addProperty("warning", "客户不存在,请重新登录"); |
|
287 |
json.add("error", errJson); |
|
288 |
this.printJson(response, json.toString()); |
|
289 |
return; |
|
290 |
}else { |
|
291 |
session.removeAttribute(SettingKey.REDIRECT); |
|
292 |
} |
|
293 |
|
|
294 |
//Gson gson=new Gson(); |
|
295 |
//DecimalFormat df = new DecimalFormat("0.00"); |
|
296 |
|
|
297 |
Calendar calendar=Calendar.getInstance(); |
|
298 |
calendar.setTime(new Date()); |
|
299 |
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)+ settingEntity.getPreSendDays().intValue());//让日期加3 |
|
300 |
//SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
|
301 |
//SimpleDateFormat sdf2=new SimpleDateFormat("hh:mm"); |
|
302 |
|
|
303 |
//收货地址 |
|
304 |
JsonObject addressEntityJsonObject = new JsonObject(); |
|
305 |
Integer paymentAddressSeq = null; |
|
306 |
if (confirmEntity.getPaymentAddress() != null) { |
|
307 |
paymentAddressSeq = confirmEntity.getPaymentAddress(); |
|
308 |
}else { |
|
309 |
paymentAddressSeq = addressEntity!=null?addressEntity.getSeq():0 ; |
|
310 |
} |
|
311 |
addressEntityJsonObject.addProperty("paymentaddress",paymentAddressSeq); //交货地址 |
|
312 |
|
|
313 |
if (addressEntity != null) { |
|
314 |
addressEntityJsonObject.addProperty("LinkName", addressEntity.getLinkMan()!= null&& ! "".equals(addressEntity.getLinkMan())?addressEntity.getLinkMan(): addressEntity.getCltName()); |
|
315 |
addressEntityJsonObject.addProperty("Telephone",addressEntity.getTelephone()!= null&& ! "".equals(addressEntity.getTelephone())?addressEntity.getTelephone() : "" ); |
473089
|
316 |
addressEntityJsonObject.addProperty("TelephoneMask",StringReplaceUtil.getTelephoneMask(addressEntity.getTelephone()!= null&& ! "".equals(addressEntity.getTelephone())?addressEntity.getTelephone() : "" )); |
70d131
|
317 |
addressEntityJsonObject.addProperty("Address",(addressEntity.getAddress()==null||"".equals(addressEntity.getAddress() )?addressEntity.getPropertyAddress(): addressEntity.getAddress())); |
J |
318 |
addressEntityJsonObject.addProperty("AddressName",addressEntity.getAddressName()); |
|
319 |
addressEntityJsonObject.addProperty("isSelected", true); //是否选中 |
|
320 |
addressEntityJsonObject.addProperty("Street",addressEntity.getStreet()); |
|
321 |
addressEntityJsonObject.addProperty("Longitude",addressEntity.getLongitude()); |
|
322 |
addressEntityJsonObject.addProperty("Latitude",addressEntity.getLatitude()); |
|
323 |
addressEntityJsonObject.addProperty("TransDistance", addressEntity.getTransDistance()); //距离 |
|
324 |
} |
|
325 |
json.add("Address", addressEntityJsonObject); |
|
326 |
|
|
327 |
JsonArray orderListJsonArray = new JsonArray(); |
ad9fb8
|
328 |
PanicBuyingEntity orderEntity = panicBuyingIfc.getPanicBuyingHeader(docCode,openId) ; |
70d131
|
329 |
if (orderEntity != null) { |
152948
|
330 |
orderListJsonArray.add(PanicBuying.getPanicBuyingJsonObject( orderEntity, hostUrl, dataSourceEntity.getDbId()+"",openId)); |
70d131
|
331 |
} |
J |
332 |
json.add("Data", orderListJsonArray); |
|
333 |
|
|
334 |
//获取配送列表 |
|
335 |
JsonArray freeListJsonArray = new JsonArray(); |
|
336 |
freeList = freeIfc.getFreeEntityList(settingEntity.getDeliveryMethod(),paymentAddressSeq,cltCode, 0) ; |
|
337 |
for (int i = 0; freeList!=null&& i < freeList.size(); i++) { |
|
338 |
FreeEntity freeEntity = freeList.get(i); |
|
339 |
JsonObject freeEntityJsonObject = new JsonObject(); |
|
340 |
freeEntityJsonObject.addProperty("FreeId", freeEntity.getFreeId()); |
|
341 |
freeEntityJsonObject.addProperty("FreeName", freeEntity.getFreeName()); |
|
342 |
freeEntityJsonObject.addProperty("FreeTotal", freeEntity.getFreeTotal()); //订单总金额超过多少免费 |
|
343 |
freeEntityJsonObject.addProperty("TransCosts", freeEntity.getTransCosts()); //运费 |
|
344 |
freeEntityJsonObject.addProperty("TransDistance", freeEntity.getTransDistance()); //距离(米) |
|
345 |
freeEntityJsonObject.addProperty("isRequiredAddress", freeEntity.isRequiredAddress()); //下单时检查收货地址 |
|
346 |
|
|
347 |
freeListJsonArray.add(freeEntityJsonObject); |
|
348 |
} |
|
349 |
json.add("FreeList", freeListJsonArray); |
|
350 |
|
|
351 |
this.printJson(response, json.toString()); |
|
352 |
return; |
|
353 |
|
|
354 |
} catch (DataAccessException e) { |
|
355 |
e.printStackTrace(); |
|
356 |
errJson.addProperty("warning", ( e.getCause()!=null? e.getCause().getMessage():e.getMessage())); |
|
357 |
json.add("error", errJson); |
|
358 |
this.printJson(response, json.toString()); |
|
359 |
return; |
|
360 |
} catch (Exception e) { |
|
361 |
e.printStackTrace(); |
|
362 |
errJson.addProperty("warning", ( e.getCause()!=null? e.getCause().getMessage():e.getMessage())); |
|
363 |
json.add("error", errJson); |
|
364 |
this.printJson(response, json.toString()); |
|
365 |
return; |
|
366 |
} finally { |
|
367 |
SpObserver.setDBtoInstance(); |
|
368 |
} |
|
369 |
} |
a6a76f
|
370 |
|
226142
|
371 |
|
J |
372 |
|
|
373 |
|
|
374 |
|
a6a76f
|
375 |
/** |
F |
376 |
* |
|
377 |
* 核销活动订单api |
|
378 |
*/ |
226142
|
379 |
@RequestMapping(params = "m=doHeXiao") |
J |
380 |
public void doHeXiao(HttpServletRequest request, HttpServletResponse response) { |
a6a76f
|
381 |
HttpSession session = request.getSession(); |
F |
382 |
String openId = (session.getAttribute(SessionKey.WEIXIN_OPENID) == null ? "" |
|
383 |
: (String) session.getAttribute(SessionKey.WEIXIN_OPENID) ) ; |
|
384 |
String cltCode = (session.getAttribute(SettingKey.CLTCODE) == null?"": (String)session.getAttribute(SettingKey.CLTCODE)) ; |
|
385 |
String cltName = (session.getAttribute(SettingKey.CLTNAME) == null?"": (String)session.getAttribute(SettingKey.CLTNAME)) ; |
|
386 |
|
|
387 |
JsonObject json = new JsonObject(); |
|
388 |
JsonObject errJson = new JsonObject(); |
226142
|
389 |
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
J |
390 |
//String qrCode = request.getParameter("qrcode") ; |
|
391 |
if (docCode == null||"".equals(docCode)) { |
|
392 |
errJson.addProperty("warning","请传递 doccode 参数【/shopping/panicBuyingOrder.do?m=heXiaoOrder】"); |
|
393 |
json.add("error", errJson); |
|
394 |
this.printJson(response, json.toString()); |
|
395 |
return ; |
|
396 |
} |
|
397 |
|
|
398 |
|
a6a76f
|
399 |
try { |
F |
400 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
401 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
226142
|
402 |
|
a6a76f
|
403 |
//核销活动订单 |
ad9fb8
|
404 |
String docOpenId = panicBuyingOrderIfc.saveHeXiaoAmount( cltCode, cltName, openId, docCode) ; |
a6a76f
|
405 |
|
ad9fb8
|
406 |
//发送 websocket 消息,通知小程序端,显示:已核销 |
6990b5
|
407 |
MessageInfo message=new MessageInfo(); |
J |
408 |
message.setDbId(dataSourceEntity.getDbId()).setUserCode(docOpenId).setUserFromType(UserFromType.miniAppUserForPanicBuying) ; |
7fed88
|
409 |
message.setMsgType(MessageType.MINI_APP_VERIFIED).setMsg("已核销"); |
ad9fb8
|
410 |
WebSocketMessageServer.publishMessageToRedis(message); |
J |
411 |
|
a6a76f
|
412 |
json.addProperty("state", "success"); |
F |
413 |
this.printJson(response, json.toString()); |
|
414 |
return; |
|
415 |
} catch (DataAccessException e) { |
|
416 |
e.printStackTrace(); |
|
417 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
418 |
json.add("error", errJson); |
|
419 |
this.printJson(response, json.toString()); |
|
420 |
return; |
|
421 |
} catch (Exception e) { |
|
422 |
e.printStackTrace(); |
|
423 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
424 |
json.add("error", errJson); |
|
425 |
this.printJson(response, json.toString()); |
|
426 |
return; |
|
427 |
} finally { |
|
428 |
SpObserver.setDBtoInstance(); |
|
429 |
} |
|
430 |
} |
|
431 |
/** |
|
432 |
* |
9275c3
|
433 |
* 由客户发起退款申请 |
a6a76f
|
434 |
*/ |
9275c3
|
435 |
@RequestMapping(params = "m=doReturnOrderByCustomer") |
J |
436 |
public void doReturnOrderByCustomer(HttpServletRequest request, HttpServletResponse response) { |
a6a76f
|
437 |
HttpSession session = request.getSession(); |
F |
438 |
//String hostUrl = SettingKey.getHostUrl(request); |
|
439 |
// 将微信corpid组装成url |
|
440 |
//String wxQueryString = SettingKey.getQueryStringByWx(request); |
|
441 |
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request); |
|
442 |
String soDocCode = request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
|
443 |
//String soRowid = request.getParameter("rowid")==null?"":request.getParameter("rowid"); |
|
444 |
String ReasonIdStr = request.getParameter("reasonid")==null?"":request.getParameter("reasonid"); |
|
445 |
|
|
446 |
String OpenedStr = request.getParameter("opened")==null?"":request.getParameter("opened"); |
|
447 |
String HDMemo = request.getParameter("hdmemo")==null?"":request.getParameter("hdmemo"); |
|
448 |
if (OpenedStr == null || OpenedStr.equals("")) { |
|
449 |
OpenedStr = "0"; |
|
450 |
} |
|
451 |
if (ReasonIdStr == null || ReasonIdStr.equals("")) { |
|
452 |
ReasonIdStr = "0"; |
|
453 |
} |
|
454 |
int Opened = Integer.parseInt(OpenedStr); |
|
455 |
int ReasonId = Integer.parseInt(ReasonIdStr); |
|
456 |
// int Opened=0; //测试时候用 正式用上面的 |
|
457 |
String usercode = (String) session.getAttribute(SessionKey.HRCODE); |
|
458 |
if (usercode == null || "".equals(usercode)) { |
|
459 |
usercode = (String) session.getAttribute(SessionKey.USERCODE); |
|
460 |
} |
|
461 |
if (usercode == null || "".equals(usercode)) { |
|
462 |
usercode = (String) session.getAttribute(SettingKey.CLTCODE); |
|
463 |
} |
|
464 |
|
|
465 |
JsonObject json = new JsonObject(); |
|
466 |
JsonObject errJson = new JsonObject(); |
|
467 |
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID); |
|
468 |
|
|
469 |
// 用户id |
|
470 |
String openId = (String) session.getAttribute(SessionKey.WEIXIN_OPENID); |
|
471 |
// 执行存储过程获取退款单号 |
|
472 |
try { |
|
473 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
474 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
475 |
// 后三个参数测试写死的 正式使用上面的参数 |
226142
|
476 |
DocCodeStateEntity returnDocCodeEntity = panicBuyingOrderIfc.saveReturnOrder(usercode, openId, soDocCode, |
a6a76f
|
477 |
ReasonId, Opened, HDMemo); |
226142
|
478 |
if (returnDocCodeEntity == null ) { |
a6a76f
|
479 |
errJson.addProperty("warning", "创建退货订单失败"); |
F |
480 |
json.add("error", errJson); |
|
481 |
this.printJson(response, json.toString()); |
|
482 |
return; |
|
483 |
} |
|
484 |
json.addProperty("state", "success"); |
226142
|
485 |
json.addProperty("refundDoccode", returnDocCodeEntity.getDocCode()); |
a6a76f
|
486 |
json.addProperty("message", "申请已发出,工作人员正在处理请耐心等待!"); |
F |
487 |
this.printJson(response, json.toString()); |
|
488 |
return; |
|
489 |
} catch (DataAccessException e) { |
|
490 |
e.printStackTrace(); |
|
491 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
492 |
json.add("error", errJson); |
|
493 |
this.printJson(response, json.toString()); |
|
494 |
return; |
|
495 |
} catch (Exception e) { |
|
496 |
e.printStackTrace(); |
|
497 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
498 |
json.add("error", errJson); |
|
499 |
this.printJson(response, json.toString()); |
|
500 |
return; |
|
501 |
} finally { |
|
502 |
SpObserver.setDBtoInstance(); |
|
503 |
} |
|
504 |
} |
226142
|
505 |
|
J |
506 |
|
|
507 |
/** |
|
508 |
* |
|
509 |
* 由活动创建者发起团购失败时退款,同时退款到微信钱包(原路返回), |
|
510 |
*/ |
|
511 |
@RequestMapping(params = "m=doReturnOrderAllByCreator") |
|
512 |
public void doReturnOrderAllByCreator(HttpServletRequest request, HttpServletResponse response) { |
|
513 |
HttpSession session = request.getSession(); |
|
514 |
//String hostUrl = SettingKey.getHostUrl(request); |
|
515 |
String panicBuyingDocCode = request.getParameter(SettingKey.DOCCODE); |
|
516 |
String soFormId = request.getParameter(SettingKey.FORMID) ; |
|
517 |
|
|
518 |
String userCode = (String) session.getAttribute(SessionKey.HRCODE); |
|
519 |
if (userCode == null || "".equals(userCode)) { |
|
520 |
userCode = (String) session.getAttribute(SessionKey.USERCODE); |
|
521 |
} |
|
522 |
if (userCode == null || "".equals(userCode)) { |
|
523 |
userCode = (String) session.getAttribute(SettingKey.CLTCODE); |
|
524 |
} |
|
525 |
// 用户id |
74f517
|
526 |
//String openId = (String) session.getAttribute(SessionKey.WEIXIN_OPENID); |
226142
|
527 |
|
J |
528 |
JsonObject json = new JsonObject(); |
|
529 |
JsonObject errJson = new JsonObject(); |
|
530 |
if (soFormId == null||"".equals(soFormId)) { |
|
531 |
errJson.addProperty("warning","调用api接口【/shopping/panicBuyingOrder.do?m=doReturnOrderAllByCreator】时,必须指定 formid 参数"); |
|
532 |
json.add("error", errJson); |
|
533 |
this.printJson(response, json.toString()); |
|
534 |
return ; |
|
535 |
} |
|
536 |
if (soFormId == null||!"710804".equals(soFormId)) { |
|
537 |
errJson.addProperty("warning","只能团购活动才可以调用api接口【/shopping/panicBuyingOrder.do?m=doReturnOrderAllByCreator】"); |
|
538 |
json.add("error", errJson); |
|
539 |
this.printJson(response, json.toString()); |
|
540 |
return ; |
|
541 |
} |
|
542 |
|
|
543 |
//String formIdStr = request.getParameter(SettingKey.FORMID) ; |
|
544 |
if (panicBuyingDocCode != null && !"".equals(panicBuyingDocCode)) { |
|
545 |
panicBuyingDocCode = panicBuyingDocCode.replaceAll("'", ""); |
|
546 |
} |
|
547 |
try { |
|
548 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
74f517
|
549 |
ReturnOrderResult returnOrderResult = doReturnOrderAll( dataSourceEntity, panicBuyingDocCode); |
226142
|
550 |
JsonArray orderListJsonArray = new JsonArray(); |
74f517
|
551 |
int returnSuccess = 0,returnFailed = 0 ,returnCount = 0; |
J |
552 |
for (int i = 0;returnOrderResult!=null && i < returnOrderResult.getReturnOrderDetailResultList().size(); i++) { |
|
553 |
ReturnOrderDetailResult returnOrderDetailResult = returnOrderResult.getReturnOrderDetailResultList().get(i); |
226142
|
554 |
JsonObject orderJson = new JsonObject(); |
74f517
|
555 |
orderJson.addProperty("SoDocCode", returnOrderDetailResult.getSoDocCode()); |
J |
556 |
orderJson.addProperty("state",returnOrderDetailResult.getState()); |
|
557 |
json.addProperty("message",returnOrderDetailResult.getMessage()); |
|
558 |
if (returnOrderDetailResult.getState().equals("success")) { |
226142
|
559 |
returnSuccess ++; |
74f517
|
560 |
}else { |
J |
561 |
returnFailed ++ ; |
226142
|
562 |
} |
74f517
|
563 |
returnCount ++ ; |
226142
|
564 |
orderListJsonArray.add(orderJson); |
J |
565 |
} |
|
566 |
json.add("returnList", orderListJsonArray); |
|
567 |
|
74f517
|
568 |
json.addProperty("message", "团购失败,应退款"+ returnCount +"单,实退成功"+ returnSuccess + "单,实退失败"+returnFailed +"单" ); |
J |
569 |
|
|
570 |
json.addProperty("returnCount", returnCount); //应退总单数 |
226142
|
571 |
json.addProperty("returnSuccess", returnSuccess); //退款成功单数 |
J |
572 |
json.addProperty("returnFailed", returnFailed); //退款失败单数 |
|
573 |
json.addProperty("state", returnFailed==0? "success":"failed"); |
|
574 |
return ; |
|
575 |
|
|
576 |
} catch (DataAccessException e) { |
|
577 |
e.printStackTrace(); |
|
578 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
579 |
json.add("error", errJson); |
|
580 |
this.printJson(response, json.toString()); |
|
581 |
return; |
|
582 |
} catch (WxPayException e) { |
|
583 |
e.printStackTrace(); |
|
584 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
585 |
json.add("error", errJson); |
|
586 |
this.printJson(response, json.toString()); |
|
587 |
return; |
|
588 |
} catch (Exception e) { |
|
589 |
e.printStackTrace(); |
|
590 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
591 |
json.add("error", errJson); |
|
592 |
this.printJson(response, json.toString()); |
|
593 |
return; |
74f517
|
594 |
} |
J |
595 |
|
|
596 |
} |
|
597 |
|
|
598 |
public static ReturnOrderResult doReturnOrderAll(DataSourceEntity dataSourceEntity,String panicBuyingDocCode) throws Exception { |
|
599 |
try { |
|
600 |
//DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
601 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
602 |
//SettingEntity settingEntity = settingIfc.getSettingEntity() ; |
|
603 |
|
|
604 |
PanicBuyingIfc panicBuyingIfc = (PanicBuyingIfc) FactoryBean.getBean("PanicBuyingImpl"); |
|
605 |
panicBuyingIfc.changeGroupBuyingStatus(panicBuyingDocCode,2) ; //1表示【团购成功】,2表示【团购失败】 |
|
606 |
PanicBuyingEntity panicBuyingEntity = panicBuyingIfc.getPanicBuyingHeader(panicBuyingDocCode); |
|
607 |
if (panicBuyingEntity == null) { |
|
608 |
throw new Exception("原活动单号不存在【单号:"+ panicBuyingDocCode + "】"); |
|
609 |
} |
|
610 |
|
|
611 |
PanicBuyingOrderIfc panicBuyingOrderIfc = (PanicBuyingOrderIfc) FactoryBean.getBean("PanicBuyingOrderImpl"); |
|
612 |
//1.退该活动下的所有订单 |
|
613 |
List<DocCodeStateEntity> returnDocCodeList = panicBuyingOrderIfc.saveReturnOrderAll(panicBuyingEntity.getCltCode(),panicBuyingEntity.getOpenId(), panicBuyingDocCode, |
|
614 |
0, 0, ""); |
|
615 |
|
|
616 |
MaSettingIfc maSettingIfc = (MaSettingIfc) FactoryBean.getBean("MaSettingImpl"); |
|
617 |
//JsonArray orderListJsonArray = new JsonArray(); |
|
618 |
int returnSuccess = 0,returnFailed = 0 ; |
|
619 |
ReturnOrderResult returnOrderResult = new ReturnOrderResult(); |
|
620 |
|
|
621 |
for (int i = 0;returnDocCodeList!=null&& i < returnDocCodeList.size(); i++) { |
|
622 |
DocCodeStateEntity returnDocCodeEntity = returnDocCodeList.get(i) ; |
|
623 |
//2.获取新建退款单据需要退的金额 |
|
624 |
if (returnDocCodeEntity == null) { |
|
625 |
throw new Exception("原活动单号不存在【单号:"+ panicBuyingDocCode + "】"); |
|
626 |
} |
|
627 |
|
|
628 |
|
|
629 |
//3.计算退款单据应退金额 710808 |
|
630 |
int returnAmount = (new BigDecimal(returnDocCodeEntity.getSoWeiXinPayAmount()*100.00)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); |
|
631 |
if (returnAmount == 0) { |
|
632 |
throw new Exception("订单"+ returnDocCodeEntity.getDocCode()+"金额为0,无需退款"); |
|
633 |
} |
|
634 |
|
|
635 |
//取出商品明细,用于显示在“退款到账通知” 上的“商品明细”栏位 |
|
636 |
StringBuffer sb = new StringBuffer() ; |
|
637 |
sb.append(returnDocCodeEntity.getTitle()); |
|
638 |
|
|
639 |
String hostUrl = dataSourceEntity.getCorpURL() ; |
|
640 |
MaSettingEntity maSettingEntity = maSettingIfc.getMaSettingEntity() ; |
|
641 |
if (maSettingEntity != null && maSettingEntity.getHttpHost()!=null&&!"".equals(maSettingEntity.getHttpHost())) { |
|
642 |
hostUrl = maSettingEntity.getHttpHost() ; |
|
643 |
} |
|
644 |
|
|
645 |
//4.计算原始订单金额 710806 |
|
646 |
int orgAmount = (new BigDecimal(returnDocCodeEntity.getSoWeiXinPayAmount()*100.00)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue() ; |
|
647 |
|
|
648 |
//5.执行微信退款 |
|
649 |
boolean state = Wxtransactions.wxRefundMoney(returnDocCodeEntity.getOpenId() ,returnDocCodeEntity.getRefCode() ,returnDocCodeEntity.getRefFormId(), returnDocCodeEntity.getDocCode(), |
|
650 |
returnDocCodeEntity.getFormId(),orgAmount,returnAmount, dataSourceEntity, |
|
651 |
hostUrl+ SettingKey.REFUND_NOTICE_URL_FOR_RETIRN_ORDER,"3",sb.toString()); |
|
652 |
|
|
653 |
ReturnOrderDetailResult returnOrderDetailResult = returnOrderResult.new ReturnOrderDetailResult(); |
|
654 |
returnOrderDetailResult.setSoDocCode(returnDocCodeEntity.getSoDocCode()); |
|
655 |
if (state) { |
|
656 |
returnSuccess ++; |
|
657 |
returnOrderDetailResult.setState("success"); |
|
658 |
returnOrderDetailResult.setMessage("微信退款成功!"); |
|
659 |
|
|
660 |
} else { |
|
661 |
returnFailed ++; |
|
662 |
returnOrderDetailResult.setState("failed"); |
|
663 |
returnOrderDetailResult.setMessage("微信退款失败!"); |
|
664 |
|
|
665 |
} |
|
666 |
returnOrderResult.getReturnOrderDetailResultList().add(returnOrderDetailResult); |
|
667 |
|
|
668 |
} |
|
669 |
returnOrderResult.setMessage("团购失败,应退款"+ (returnDocCodeList!=null?returnDocCodeList.size():0) +"单,实退成功"+ returnSuccess + "单,实退失败"+returnFailed +"单"); |
|
670 |
returnOrderResult.setReturnCount(returnDocCodeList!=null?returnDocCodeList.size():0); //应退总单数 |
|
671 |
returnOrderResult.setReturnFailed(returnFailed); //退款失败单数 |
|
672 |
returnOrderResult.setReturnSuccess(returnSuccess); //退款成功单数 |
|
673 |
returnOrderResult.setState(returnFailed==0? "success":"failed"); |
|
674 |
return returnOrderResult ; |
|
675 |
|
|
676 |
} catch (DataAccessException e) { |
|
677 |
throw e ; |
|
678 |
} catch (WxPayException e) { |
|
679 |
throw e ; |
|
680 |
} catch (Exception e) { |
|
681 |
throw e ; |
226142
|
682 |
} finally { |
J |
683 |
SpObserver.setDBtoInstance(); |
|
684 |
} |
|
685 |
} |
|
686 |
|
b3acab
|
687 |
|
F |
688 |
/** |
|
689 |
* |
9275c3
|
690 |
* 由活动创建者发起退款,同时退款到微信钱包(原路返回), |
J |
691 |
*/ |
|
692 |
@RequestMapping(params = "m=doReturnOrderByCreator") |
|
693 |
public void doReturnOrderByCreator(HttpServletRequest request, HttpServletResponse response) { |
|
694 |
HttpSession session = request.getSession(); |
|
695 |
//String hostUrl = SettingKey.getHostUrl(request); |
|
696 |
String soDocCode = request.getParameter(SettingKey.DOCCODE); |
|
697 |
String soFormId = request.getParameter(SettingKey.FORMID) ; |
|
698 |
|
|
699 |
//String soDocCode = request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
|
700 |
//String soRowid = request.getParameter("rowid")==null?"":request.getParameter("rowid"); |
|
701 |
String reasonIdStr = request.getParameter("reasonid")==null?"":request.getParameter("reasonid"); |
|
702 |
|
|
703 |
String openedStr = request.getParameter("opened")==null?"":request.getParameter("opened"); |
|
704 |
String hdMemo = request.getParameter("hdmemo")==null?"":request.getParameter("hdmemo"); |
|
705 |
if (openedStr == null || openedStr.equals("")) { |
|
706 |
openedStr = "0"; |
|
707 |
} |
|
708 |
if (reasonIdStr == null || reasonIdStr.equals("")) { |
|
709 |
reasonIdStr = "0"; |
|
710 |
} |
|
711 |
int opened = Integer.parseInt(openedStr); |
|
712 |
int reasonId = Integer.parseInt(reasonIdStr); |
|
713 |
|
|
714 |
String userCode = (String) session.getAttribute(SessionKey.HRCODE); |
|
715 |
if (userCode == null || "".equals(userCode)) { |
|
716 |
userCode = (String) session.getAttribute(SessionKey.USERCODE); |
|
717 |
} |
|
718 |
if (userCode == null || "".equals(userCode)) { |
|
719 |
userCode = (String) session.getAttribute(SettingKey.CLTCODE); |
|
720 |
} |
|
721 |
// 用户id |
|
722 |
String openId = (String) session.getAttribute(SessionKey.WEIXIN_OPENID); |
|
723 |
|
|
724 |
JsonObject json = new JsonObject(); |
|
725 |
JsonObject errJson = new JsonObject(); |
|
726 |
if (soFormId == null||"".equals(soFormId)) { |
|
727 |
errJson.addProperty("warning","调用api接口【/shopping/panicBuyingOrder.do?m=doReturnOrderByCreator】时,必须指定 formid 参数"); |
|
728 |
json.add("error", errJson); |
|
729 |
this.printJson(response, json.toString()); |
|
730 |
return ; |
|
731 |
} |
|
732 |
//String formIdStr = request.getParameter(SettingKey.FORMID) ; |
|
733 |
if (soDocCode != null && !"".equals(soDocCode)) { |
|
734 |
soDocCode = soDocCode.replaceAll("'", ""); |
|
735 |
} |
|
736 |
try { |
|
737 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
738 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
739 |
//SettingEntity settingEntity = settingIfc.getSettingEntity() ; |
|
740 |
|
2b1479
|
741 |
//检查商家余额是否足够退款 |
J |
742 |
CheckServiceBalanceWhenRefundResult checkServiceBalanceWhenRefundResult = panicBuyingOrderIfc.CheckServiceBalanceWhenRefund(soDocCode); |
|
743 |
if (checkServiceBalanceWhenRefundResult==null|| !checkServiceBalanceWhenRefundResult.isAllowRefund()) { |
|
744 |
json.addProperty("state", "failed"); |
|
745 |
json.addProperty("message", "商家["+checkServiceBalanceWhenRefundResult.getServiceCltName()+"]账户余额[" + (0.0 - checkServiceBalanceWhenRefundResult.getServiceBalance().doubleValue()) + "元]不足以扣除本单退款所需要的金额[" +checkServiceBalanceWhenRefundResult.getPayableAmount() + "元],请与客户协商,退款失败!"); |
|
746 |
json.addProperty("isAllowRefund", checkServiceBalanceWhenRefundResult.isAllowRefund()) ; |
|
747 |
json.addProperty("serviceCltCode", checkServiceBalanceWhenRefundResult.getServiceCltCode()) ; |
|
748 |
json.addProperty("serviceCltName", checkServiceBalanceWhenRefundResult.getServiceCltName()) ; |
|
749 |
json.addProperty("serviceTelephone", checkServiceBalanceWhenRefundResult.getServiceTelephone()) ; |
473089
|
750 |
json.addProperty("serviceTelephoneMask",StringReplaceUtil.getTelephoneMask( checkServiceBalanceWhenRefundResult.getServiceTelephone())) ; |
2b1479
|
751 |
json.addProperty("sellerId", checkServiceBalanceWhenRefundResult.getSellerId()) ; |
J |
752 |
json.addProperty("sellerName", checkServiceBalanceWhenRefundResult.getSellerName()) ; |
|
753 |
json.addProperty("sellerTelephone", checkServiceBalanceWhenRefundResult.getSellerTelephone()) ; |
473089
|
754 |
json.addProperty("sellerTelephoneMask", StringReplaceUtil.getTelephoneMask(checkServiceBalanceWhenRefundResult.getSellerTelephone())) ; |
2b1479
|
755 |
json.addProperty("payableAmount", checkServiceBalanceWhenRefundResult.getPayableAmount()) ; |
J |
756 |
json.addProperty("serviceBalance", 0.0 - checkServiceBalanceWhenRefundResult.getServiceBalance().doubleValue()) ; //要转换成负数输出 |
|
757 |
json.addProperty("paidFeeAmount", checkServiceBalanceWhenRefundResult.getPaidFeeAmount()) ; |
|
758 |
json.addProperty("customerCltCode", checkServiceBalanceWhenRefundResult.getCustomerCltCode()) ; |
|
759 |
json.addProperty("customerCltName", checkServiceBalanceWhenRefundResult.getCustomerCltName()) ; |
|
760 |
json.addProperty("customerTelephone", checkServiceBalanceWhenRefundResult.getCustomerTelephone()) ; |
473089
|
761 |
json.addProperty("customerTelephoneMask", StringReplaceUtil.getTelephoneMask(checkServiceBalanceWhenRefundResult.getCustomerTelephone())) ; |
2b1479
|
762 |
|
J |
763 |
this.printJson(response, json.toString()); |
|
764 |
return ; |
|
765 |
} |
|
766 |
|
9275c3
|
767 |
//1.新建退款单据 |
226142
|
768 |
DocCodeStateEntity returnDocCodeEntity = panicBuyingOrderIfc.saveReturnOrder(userCode, openId, soDocCode, |
9275c3
|
769 |
reasonId, opened, hdMemo); |
J |
770 |
|
|
771 |
//2.获取新建退款单据需要退的金额 |
|
772 |
if (returnDocCodeEntity == null) { |
|
773 |
errJson.addProperty("warning", "原活动订单不存在【单号:"+ soDocCode + "】"); |
|
774 |
json.add("error", errJson); |
|
775 |
this.printJson(response, json.toString()); |
|
776 |
return ; |
|
777 |
} |
2b1479
|
778 |
|
9275c3
|
779 |
|
J |
780 |
//3.计算退款单据应退金额 710808 |
|
781 |
int returnAmount = (new BigDecimal(returnDocCodeEntity.getWeiXinPayAmount()*100.00)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue(); |
|
782 |
if (returnAmount == 0) { |
|
783 |
errJson.addProperty("warning", "金额为0,无需退款"); |
|
784 |
json.add("error", errJson); |
|
785 |
this.printJson(response, json.toString()); |
|
786 |
return ; |
|
787 |
} |
|
788 |
|
|
789 |
//取出商品明细,用于显示在“退款到账通知” 上的“商品明细”栏位 |
|
790 |
StringBuffer sb = new StringBuffer() ; |
|
791 |
sb.append(returnDocCodeEntity.getTitle()); |
|
792 |
|
|
793 |
String hostUrl = dataSourceEntity.getCorpURL() ; |
|
794 |
MaSettingEntity maSettingEntity = maSettingIfc.getMaSettingEntity() ; |
|
795 |
if (maSettingEntity != null && maSettingEntity.getHttpHost()!=null&&!"".equals(maSettingEntity.getHttpHost())) { |
|
796 |
hostUrl = maSettingEntity.getHttpHost() ; |
|
797 |
} |
|
798 |
|
|
799 |
//4.计算原始订单金额 710806 |
226142
|
800 |
int orgAmount = (new BigDecimal(returnDocCodeEntity.getSoWeiXinPayAmount()*100.00)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue() ; |
9275c3
|
801 |
|
J |
802 |
//5.执行微信退款 |
226142
|
803 |
boolean state = Wxtransactions.wxRefundMoney(returnDocCodeEntity.getOpenId() ,soDocCode ,returnDocCodeEntity.getFormId(), returnDocCodeEntity.getDocCode(), |
74f517
|
804 |
Integer.parseInt(soFormId),orgAmount,returnAmount, dataSourceEntity, |
9275c3
|
805 |
hostUrl+ SettingKey.REFUND_NOTICE_URL_FOR_RETIRN_ORDER,"3",sb.toString()); |
J |
806 |
|
|
807 |
if (state) { |
|
808 |
json.addProperty("state", "success"); |
|
809 |
json.addProperty("message", "微信退款成功!"); |
|
810 |
this.printJson(response, json.toString()); |
|
811 |
return; |
|
812 |
|
|
813 |
} else { |
|
814 |
json.addProperty("state", "failed"); |
|
815 |
json.addProperty("message", "微信退款失败!"); |
|
816 |
this.printJson(response, json.toString()); |
|
817 |
return; |
|
818 |
} |
|
819 |
|
|
820 |
} catch (DataAccessException e) { |
|
821 |
e.printStackTrace(); |
|
822 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
823 |
json.add("error", errJson); |
|
824 |
this.printJson(response, json.toString()); |
|
825 |
return; |
|
826 |
} catch (WxPayException e) { |
|
827 |
e.printStackTrace(); |
|
828 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
829 |
json.add("error", errJson); |
|
830 |
this.printJson(response, json.toString()); |
|
831 |
return; |
|
832 |
} catch (Exception e) { |
|
833 |
e.printStackTrace(); |
|
834 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
835 |
json.add("error", errJson); |
|
836 |
this.printJson(response, json.toString()); |
|
837 |
return; |
|
838 |
} finally { |
|
839 |
SpObserver.setDBtoInstance(); |
|
840 |
} |
|
841 |
|
|
842 |
} |
|
843 |
|
|
844 |
/** |
|
845 |
* |
b3acab
|
846 |
* 获取我的订单列表 |
F |
847 |
*/ |
2837f1
|
848 |
@RequestMapping(params = "m=getOrderListForMe") |
J |
849 |
public void getOrderListForMe(HttpServletRequest request, HttpServletResponse response) { |
b3acab
|
850 |
HttpSession session = request.getSession(); |
02cac6
|
851 |
String hostUrl = SettingKey.getHostUrl(request); |
b3acab
|
852 |
// 将微信corpid组装成url |
F |
853 |
//String wxQueryString = SettingKey.getQueryStringByWx(request); |
|
854 |
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request); |
|
855 |
|
|
856 |
// int Opened=0; //测试时候用 正式用上面的 |
|
857 |
String usercode = (String) session.getAttribute(SessionKey.HRCODE); |
|
858 |
if (usercode == null || "".equals(usercode)) { |
|
859 |
usercode = (String) session.getAttribute(SessionKey.USERCODE); |
|
860 |
} |
|
861 |
if (usercode == null || "".equals(usercode)) { |
|
862 |
usercode = (String) session.getAttribute(SettingKey.CLTCODE); |
|
863 |
} |
|
864 |
String cltCode = (session.getAttribute(SettingKey.CLTCODE) == null ? "" |
|
865 |
: (String) session.getAttribute(SettingKey.CLTCODE)); |
|
866 |
JsonObject json = new JsonObject(); |
|
867 |
JsonObject errJson = new JsonObject(); |
|
868 |
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID); |
|
869 |
|
|
870 |
// 用户id |
e42ed7
|
871 |
String openId = (String) session.getAttribute(SessionKey.WEIXIN_OPENID); |
b3acab
|
872 |
// 执行存储过程获取退款单号 |
F |
873 |
try { |
|
874 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
875 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
876 |
SettingEntity settingEntity = settingIfc.getSettingEntity() ; |
|
877 |
// 后三个参数测试写死的 正式使用上面的参数 |
8bf658
|
878 |
List<PanicBuyingOrderEntity> dataList = panicBuyingOrderIfc.getOrderHeaderListForMe(cltCode); |
b3acab
|
879 |
|
8bf658
|
880 |
//待支付(草稿) |
J |
881 |
JsonArray draftListJsonArray = new JsonArray(); |
|
882 |
List<PanicBuyingOrderEntity> draftList = dataList.stream().filter(s->s.getDocStatus().intValue()==0).collect(Collectors.toList()); |
|
883 |
for (int i = 0;draftList!=null&& i < draftList.size(); i++) { |
|
884 |
PanicBuyingOrderEntity orderEntity = draftList.get(i) ; |
e42ed7
|
885 |
draftListJsonArray.add(getOrderEntityJsonObject( orderEntity, hostUrl, cltCode, settingEntity, dataSourceEntity.getDbId()+"",openId)); |
8bf658
|
886 |
} |
J |
887 |
json.add("draftList", draftListJsonArray); |
|
888 |
|
|
889 |
//已支付 |
b3acab
|
890 |
JsonArray orderListJsonArray = new JsonArray(); |
8bf658
|
891 |
List<PanicBuyingOrderEntity> orderList = dataList.stream().filter(s->s.getDocStatus().intValue()==100).collect(Collectors.toList()); |
J |
892 |
for (int i = 0;orderList!=null&& i < orderList.size(); i++) { |
|
893 |
PanicBuyingOrderEntity orderEntity = orderList.get(i) ; |
e42ed7
|
894 |
orderListJsonArray.add(getOrderEntityJsonObject( orderEntity, hostUrl, cltCode, settingEntity, dataSourceEntity.getDbId()+"",openId)); |
b3acab
|
895 |
} |
8bf658
|
896 |
json.add("orderList", orderListJsonArray); |
b3acab
|
897 |
|
8bf658
|
898 |
//已取消 |
J |
899 |
JsonArray cancelListJsonArray = new JsonArray(); |
|
900 |
List<PanicBuyingOrderEntity> cancelList = dataList.stream().filter(s->s.getDocStatus().intValue()==-200).collect(Collectors.toList()); |
|
901 |
for (int i = 0;cancelList!=null&& i < cancelList.size(); i++) { |
|
902 |
PanicBuyingOrderEntity orderEntity = cancelList.get(i) ; |
e42ed7
|
903 |
cancelListJsonArray.add(getOrderEntityJsonObject( orderEntity, hostUrl, cltCode, settingEntity, dataSourceEntity.getDbId()+"",openId)); |
8bf658
|
904 |
} |
J |
905 |
json.add("cancelList", cancelListJsonArray); |
b3acab
|
906 |
|
F |
907 |
this.printJson(response, json.toString()); |
|
908 |
return; |
|
909 |
} catch (DataAccessException e) { |
|
910 |
e.printStackTrace(); |
|
911 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
912 |
json.add("error", errJson); |
|
913 |
this.printJson(response, json.toString()); |
|
914 |
return; |
|
915 |
} catch (Exception e) { |
|
916 |
e.printStackTrace(); |
|
917 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
918 |
json.add("error", errJson); |
|
919 |
this.printJson(response, json.toString()); |
|
920 |
return; |
|
921 |
} finally { |
|
922 |
SpObserver.setDBtoInstance(); |
|
923 |
} |
|
924 |
} |
|
925 |
|
|
926 |
|
|
927 |
/** |
|
928 |
* |
226142
|
929 |
* 获取我的订单明细 |
b3acab
|
930 |
*/ |
F |
931 |
@RequestMapping(params = "m=getOrderDetail") |
|
932 |
public void getOrderDetail(HttpServletRequest request, HttpServletResponse response) { |
|
933 |
HttpSession session = request.getSession(); |
02cac6
|
934 |
String hostUrl = SettingKey.getHostUrl(request); |
b3acab
|
935 |
// 将微信corpid组装成url |
F |
936 |
//String wxQueryString = SettingKey.getQueryStringByWx(request); |
|
937 |
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request); |
|
938 |
|
|
939 |
// int Opened=0; //测试时候用 正式用上面的 |
|
940 |
String usercode = (String) session.getAttribute(SessionKey.HRCODE); |
|
941 |
if (usercode == null || "".equals(usercode)) { |
|
942 |
usercode = (String) session.getAttribute(SessionKey.USERCODE); |
|
943 |
} |
|
944 |
if (usercode == null || "".equals(usercode)) { |
|
945 |
usercode = (String) session.getAttribute(SettingKey.CLTCODE); |
|
946 |
} |
|
947 |
String cltCode = (session.getAttribute(SettingKey.CLTCODE) == null ? "" |
|
948 |
: (String) session.getAttribute(SettingKey.CLTCODE)); |
|
949 |
JsonObject json = new JsonObject(); |
|
950 |
JsonObject errJson = new JsonObject(); |
|
951 |
|
|
952 |
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
|
953 |
|
|
954 |
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID); |
|
955 |
|
|
956 |
// 用户id |
e42ed7
|
957 |
String openId = (String) session.getAttribute(SessionKey.WEIXIN_OPENID); |
b3acab
|
958 |
// 执行存储过程获取退款单号 |
F |
959 |
try { |
|
960 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
961 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
962 |
SettingEntity settingEntity = settingIfc.getSettingEntity() ; |
02cac6
|
963 |
|
J |
964 |
PanicBuyingOrderEntity orderEntity = panicBuyingOrderIfc.getOrderHeaderEntity(docCode); |
b3acab
|
965 |
|
F |
966 |
JsonArray orderListJsonArray = new JsonArray(); |
|
967 |
if (orderEntity!=null) { |
e42ed7
|
968 |
orderListJsonArray.add(getOrderEntityJsonObject( orderEntity, hostUrl, cltCode, settingEntity, dataSourceEntity.getDbId()+"",openId)); |
b3acab
|
969 |
} |
F |
970 |
json.add("list", orderListJsonArray); |
02cac6
|
971 |
|
bd8e71
|
972 |
List<PanicBuyingSellerEntity> orderSellerList = panicBuyingOrderIfc.getPanicBuyingOrderSellerList( docCode); |
J |
973 |
JsonArray orderSellerListJsonArray = new JsonArray(); |
|
974 |
for (int i = 0; orderSellerList!=null&&i < orderSellerList.size(); i++) { |
|
975 |
PanicBuyingSellerEntity panicBuyingSellerEntity = orderSellerList.get(i); |
|
976 |
JsonObject orderSellerEntityJsonObject = new JsonObject(); |
|
977 |
orderSellerEntityJsonObject.addProperty("DocItem", panicBuyingSellerEntity.getDocItem()); |
|
978 |
orderSellerEntityJsonObject.addProperty("SellerId", panicBuyingSellerEntity.getSellerId()); |
|
979 |
orderSellerEntityJsonObject.addProperty("SellerName", panicBuyingSellerEntity.getSellerName()); |
|
980 |
orderSellerEntityJsonObject.addProperty("Telephone", panicBuyingSellerEntity.getTelephone()); |
473089
|
981 |
orderSellerEntityJsonObject.addProperty("TelephoneMask",StringReplaceUtil.getTelephoneMask(panicBuyingSellerEntity.getTelephone())); |
5c3d44
|
982 |
orderSellerEntityJsonObject.addProperty("isDefaultSellerName", panicBuyingSellerEntity.getIsDefaultSellerName()); |
bd8e71
|
983 |
orderSellerListJsonArray.add(orderSellerEntityJsonObject); |
02cac6
|
984 |
} |
bd8e71
|
985 |
json.add("sellerList", orderSellerListJsonArray); |
b3acab
|
986 |
|
F |
987 |
this.printJson(response, json.toString()); |
|
988 |
return; |
|
989 |
} catch (DataAccessException e) { |
|
990 |
e.printStackTrace(); |
|
991 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
992 |
json.add("error", errJson); |
|
993 |
this.printJson(response, json.toString()); |
|
994 |
return; |
|
995 |
} catch (Exception e) { |
|
996 |
e.printStackTrace(); |
|
997 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
998 |
json.add("error", errJson); |
|
999 |
this.printJson(response, json.toString()); |
|
1000 |
return; |
|
1001 |
} finally { |
|
1002 |
SpObserver.setDBtoInstance(); |
|
1003 |
} |
|
1004 |
} |
|
1005 |
|
226142
|
1006 |
/** |
J |
1007 |
* |
4241b5
|
1008 |
* 取消待支付单个订单 |
J |
1009 |
*/ |
|
1010 |
@RequestMapping(params = "m=cancelExpiredOrder") |
|
1011 |
public void cancelExpiredOrder(HttpServletRequest request, HttpServletResponse response) { |
|
1012 |
JsonObject json = new JsonObject(); |
|
1013 |
JsonObject errJson = new JsonObject(); |
|
1014 |
|
|
1015 |
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
|
1016 |
// 执行存储过程获取退款单号 |
|
1017 |
try { |
|
1018 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
1019 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
1020 |
//SettingEntity settingEntity = settingIfc.getSettingEntity() ; |
b6cfc5
|
1021 |
PanicBuyingOrderEntity panicBuyingOrderEntity = panicBuyingOrderIfc.getOrderHeaderEntity(docCode); |
J |
1022 |
if (panicBuyingOrderEntity != null) { |
|
1023 |
if (panicBuyingOrderEntity.getDocStatus().intValue() == -200) { |
|
1024 |
errJson.addProperty("warning", "已取消"); |
|
1025 |
json.add("error", errJson); |
|
1026 |
this.printJson(response, json.toString()); |
|
1027 |
return; |
|
1028 |
} |
|
1029 |
if (panicBuyingOrderEntity.getDocStatus().intValue() == 100) { |
|
1030 |
errJson.addProperty("warning", "订单已支付,不能取消"); |
|
1031 |
json.add("error", errJson); |
|
1032 |
this.printJson(response, json.toString()); |
|
1033 |
return; |
|
1034 |
} |
|
1035 |
if (panicBuyingOrderEntity.getDocStatus().intValue() != 0) { |
|
1036 |
errJson.addProperty("warning", "订单不是待支付状态,不能取消"); |
|
1037 |
json.add("error", errJson); |
|
1038 |
this.printJson(response, json.toString()); |
|
1039 |
return; |
|
1040 |
} |
|
1041 |
|
|
1042 |
panicBuyingOrderIfc.deletePayingExpiredOrder(docCode); |
|
1043 |
} |
4241b5
|
1044 |
json.addProperty("state", "success"); |
J |
1045 |
this.printJson(response, json.toString()); |
|
1046 |
return; |
|
1047 |
} catch (DataAccessException e) { |
|
1048 |
e.printStackTrace(); |
|
1049 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
1050 |
json.add("error", errJson); |
|
1051 |
this.printJson(response, json.toString()); |
|
1052 |
return; |
|
1053 |
} catch (Exception e) { |
|
1054 |
e.printStackTrace(); |
|
1055 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
1056 |
json.add("error", errJson); |
|
1057 |
this.printJson(response, json.toString()); |
|
1058 |
return; |
|
1059 |
} finally { |
|
1060 |
SpObserver.setDBtoInstance(); |
|
1061 |
} |
|
1062 |
} |
|
1063 |
|
|
1064 |
/** |
|
1065 |
* |
226142
|
1066 |
* 按扫码获取我的订单明细 |
J |
1067 |
*/ |
|
1068 |
@RequestMapping(params = "m=getOrderDetailByQrCode") |
|
1069 |
public void getOrderDetailByQrCode(HttpServletRequest request, HttpServletResponse response) { |
|
1070 |
HttpSession session = request.getSession(); |
|
1071 |
String hostUrl = SettingKey.getHostUrl(request); |
e42ed7
|
1072 |
String openId = (session.getAttribute(SessionKey.WEIXIN_OPENID) == null ? "" |
J |
1073 |
: (String) session.getAttribute(SessionKey.WEIXIN_OPENID) ) ; |
226142
|
1074 |
String cltCode = (session.getAttribute(SettingKey.CLTCODE) == null?"": (String)session.getAttribute(SettingKey.CLTCODE)) ; |
J |
1075 |
//String cltName = (session.getAttribute(SettingKey.CLTNAME) == null?"": (String)session.getAttribute(SettingKey.CLTNAME)) ; |
|
1076 |
|
|
1077 |
JsonObject json = new JsonObject(); |
|
1078 |
JsonObject errJson = new JsonObject(); |
|
1079 |
|
|
1080 |
String qrCode = request.getParameter("qrcode") ; |
|
1081 |
if (qrCode == null||"".equals(qrCode)) { |
|
1082 |
errJson.addProperty("warning","请传递 qrcode 参数【/shopping/panicBuyingOrder.do?m=getOrderDetailByQrCode】"); |
|
1083 |
json.add("error", errJson); |
|
1084 |
this.printJson(response, json.toString()); |
|
1085 |
return ; |
|
1086 |
} |
|
1087 |
|
|
1088 |
|
|
1089 |
try { |
|
1090 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
1091 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
1092 |
SettingEntity settingEntity = settingIfc.getSettingEntity() ; |
|
1093 |
QrCodeForAppEntity qrCodeForAppEntity = matCodeIfc.getQrCodeEntity( qrCode) ; //获取存在的二维码 |
|
1094 |
if (qrCodeForAppEntity == null) { |
|
1095 |
errJson.addProperty("warning","该二维码不存在!" + qrCode ); |
|
1096 |
json.add("error", errJson); |
|
1097 |
this.printJson(response, json.toString()); |
|
1098 |
return ; |
|
1099 |
} |
|
1100 |
|
|
1101 |
PanicBuyingOrderEntity orderEntity = panicBuyingOrderIfc.getOrderHeaderEntity(qrCodeForAppEntity.getRefDocCode()); |
|
1102 |
|
|
1103 |
JsonArray orderListJsonArray = new JsonArray(); |
|
1104 |
if (orderEntity!=null) { |
e42ed7
|
1105 |
orderListJsonArray.add(getOrderEntityJsonObject( orderEntity, hostUrl, cltCode, settingEntity, dataSourceEntity.getDbId()+"",openId)); |
226142
|
1106 |
} |
J |
1107 |
|
ad9fb8
|
1108 |
//发送 websocket 消息,通知小程序端,显示:已扫码 |
6990b5
|
1109 |
MessageInfo message=new MessageInfo(); |
J |
1110 |
message.setDbId(dataSourceEntity.getDbId()).setUserCode(orderEntity.getOpenId()).setUserFromType(UserFromType.miniAppUserForPanicBuying); |
7fed88
|
1111 |
message.setMsgType(MessageType.MINI_APP_VERIFYING).setMsg("已扫码"); |
ad9fb8
|
1112 |
WebSocketMessageServer.publishMessageToRedis(message); |
J |
1113 |
|
|
1114 |
|
|
1115 |
json.add("list", orderListJsonArray); |
226142
|
1116 |
json.addProperty("state", "success"); |
J |
1117 |
this.printJson(response, json.toString()); |
|
1118 |
return; |
|
1119 |
} catch (DataAccessException e) { |
|
1120 |
e.printStackTrace(); |
|
1121 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
1122 |
json.add("error", errJson); |
|
1123 |
this.printJson(response, json.toString()); |
|
1124 |
return; |
|
1125 |
} catch (Exception e) { |
|
1126 |
e.printStackTrace(); |
|
1127 |
errJson.addProperty("warning", e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
|
1128 |
json.add("error", errJson); |
|
1129 |
this.printJson(response, json.toString()); |
|
1130 |
return; |
|
1131 |
} finally { |
|
1132 |
SpObserver.setDBtoInstance(); |
|
1133 |
} |
|
1134 |
} |
b3acab
|
1135 |
|
e42ed7
|
1136 |
private JsonObject getOrderEntityJsonObject(PanicBuyingOrderEntity orderEntity,String hostUrl,String cltCode,SettingEntity settingEntity,String dbid,String openId) { |
02cac6
|
1137 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd") ; |
J |
1138 |
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ; |
|
1139 |
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm") ; |
|
1140 |
|
|
1141 |
JsonObject orderEntityJsonObject = new JsonObject(); |
|
1142 |
//status : 0 所有,1.待付款,2.待核销,3.已核销,4.已取消 |
|
1143 |
String groupBy = "所有" ; |
|
1144 |
if (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(0)) { |
|
1145 |
groupBy = "待付款"; |
|
1146 |
} |
|
1147 |
|
|
1148 |
if (orderEntity.getDocStatus().equals(100) ) { |
7a058b
|
1149 |
if (orderEntity.getHeXiaoStatus().equals(0)) { |
J |
1150 |
groupBy = "待核销"; // orderEntity.getHeXiaoStatus(); //待核销,已核销 |
|
1151 |
}else { |
|
1152 |
groupBy = "已核销"; // orderEntity.getHeXiaoStatus(); //待核销,已核销 |
|
1153 |
} |
02cac6
|
1154 |
} |
J |
1155 |
|
|
1156 |
if (orderEntity.getDocStatus().equals(-200)) { |
|
1157 |
groupBy = "已取消"; |
|
1158 |
} |
|
1159 |
orderEntityJsonObject.addProperty("GroupBy", groupBy); |
|
1160 |
|
|
1161 |
|
|
1162 |
orderEntityJsonObject.addProperty(SettingKey.DOCCODE, orderEntity.getDocCode()); |
|
1163 |
orderEntityJsonObject.addProperty("FormId", orderEntity.getFormId()); |
|
1164 |
orderEntityJsonObject.addProperty("DocType", orderEntity.getDocType()); //单据类型:微信订单 、微信团购订单 |
ad9fb8
|
1165 |
orderEntityJsonObject.addProperty("RefCode", orderEntity.getRefCode()); //原始活动单号 |
J |
1166 |
//orderEntityJsonObject.addProperty("refFormId", orderEntity.getRefFormId()); //原始活动单号 |
|
1167 |
//orderEntityJsonObject.addProperty("refFormType", orderEntity.getRefFormType()); //原始活动单号 |
|
1168 |
|
226142
|
1169 |
orderEntityJsonObject.addProperty("CcCode", orderEntity.getCcCode()); //商家编号 |
J |
1170 |
orderEntityJsonObject.addProperty("CcName", orderEntity.getCcName()); //商家名称 |
|
1171 |
orderEntityJsonObject.addProperty("Street", orderEntity.getStreet()); //门牌地址 |
|
1172 |
orderEntityJsonObject.addProperty("FullAddress", orderEntity.getFullAddress()); //地址 |
|
1173 |
orderEntityJsonObject.addProperty("FullAddressName", orderEntity.getFullAddressName()); //地址名称 |
|
1174 |
|
|
1175 |
orderEntityJsonObject.addProperty("Digit",orderEntity.getDigit()); //订单总数量 |
|
1176 |
orderEntityJsonObject.addProperty("Price",orderEntity.getPrice()); //订单价格 |
|
1177 |
orderEntityJsonObject.addProperty("Amount",orderEntity.getAmount()); //订单金额 |
02cac6
|
1178 |
orderEntityJsonObject.addProperty("PayableAmount",orderEntity.getPayableAmount()); //优惠后订单总金额 |
J |
1179 |
orderEntityJsonObject.addProperty("ReduceMoney",orderEntity.getReduceMoney()); //优惠金额 |
|
1180 |
orderEntityJsonObject.addProperty("TransCosts",orderEntity.getTransCosts()); //运费 |
|
1181 |
orderEntityJsonObject.addProperty("HandlingCharges",orderEntity.getHandlingCharges()); //搬运费 |
|
1182 |
|
|
1183 |
orderEntityJsonObject.addProperty("Currency",orderEntity.getCurrency()); //币种 |
|
1184 |
orderEntityJsonObject.addProperty("CurrencySign",orderEntity.getCurrencySign()); //货币符号 |
226142
|
1185 |
orderEntityJsonObject.addProperty("PropertyAddress",orderEntity.getPropertyAddress()); //地址 |
02cac6
|
1186 |
orderEntityJsonObject.addProperty("LinkMan",orderEntity.getLinkMan() != null &&!"".equals(orderEntity.getLinkMan())?orderEntity.getLinkMan(): orderEntity.getCltName()); //联系人 |
J |
1187 |
orderEntityJsonObject.addProperty("Telephone",orderEntity.getTelephone()); //联系人电话 |
473089
|
1188 |
orderEntityJsonObject.addProperty("TelephoneMask",StringReplaceUtil.getTelephoneMask(orderEntity.getTelephone())); //联系人电话 |
02cac6
|
1189 |
orderEntityJsonObject.addProperty("DeliveryMethod",orderEntity.getDeliveryMethod()); |
J |
1190 |
orderEntityJsonObject.addProperty("DeliveryDate",sdf.format(orderEntity.getDocDate())); |
|
1191 |
orderEntityJsonObject.addProperty("InvoiceType","电子普通发票"); |
|
1192 |
orderEntityJsonObject.addProperty("HDMemo",orderEntity.getHdMemo()); |
7a058b
|
1193 |
|
02cac6
|
1194 |
|
J |
1195 |
//orderEntityJsonObject.addProperty("LogisticsCode",orderEntity.getLogisticsCode()); //物流单号 |
|
1196 |
//orderEntityJsonObject.addProperty("ShipperCode",orderEntity.getShipperCode()); //快递公司编号 |
|
1197 |
//orderEntityJsonObject.addProperty("ShipperName",orderEntity.getShipperName()); //快递公司名称 |
|
1198 |
orderEntityJsonObject.addProperty("isAllowPayable",orderEntity.getIsAllowPayable()); //是否可支付 isAllowPayable 状态: 0.不能支付,1.可支付,2.已支付 ,3.正在退款,4.已退款,5.无需支付 |
|
1199 |
orderEntityJsonObject.addProperty("DocStatus",orderEntity.getDocStatus()); //单据状态 |
|
1200 |
|
|
1201 |
orderEntityJsonObject.addProperty("DocDate",orderEntity.getDocDate()==null?"":sdf.format(orderEntity.getDocDate())); |
|
1202 |
orderEntityJsonObject.addProperty("EnterDate",orderEntity.getEnterDate()==null?"":sdf2.format(orderEntity.getEnterDate())); |
|
1203 |
//orderEntityJsonObject.addProperty("PreSendDate",orderEntity.getPreSendDate()==null?"":sdf3.format(orderEntity.getPreSendDate())); |
|
1204 |
orderEntityJsonObject.addProperty("PayableSecondBalance",orderEntity.getPayableSecondBalance()!=null&& orderEntity.getPayableSecondBalance().intValue() >0?orderEntity.getPayableSecondBalance():0); //下单后支付倒计时秒数 |
|
1205 |
//orderEntityJsonObject.addProperty("GroupBuyingDocCode",orderEntity.getGroupBuyingDocCode()); //团购订单号 |
|
1206 |
//orderEntityJsonObject.addProperty("GroupBuyingMembers",orderEntity.getGroupBuyingMembers()); //需要多少人成团 |
|
1207 |
//orderEntityJsonObject.addProperty("GroupBuyingHasMembers",orderEntity.getGroupBuyingHasMembers()); //已有多少人成团 |
|
1208 |
//orderEntityJsonObject.addProperty("GroupBuyingMembersBalance",orderEntity.getGroupBuyingMembersBalance()); //还差多少人成团 |
|
1209 |
|
|
1210 |
//获取单据状态描述 |
|
1211 |
String docStatusDesc = getDocStatusDescription(orderEntity) ; |
|
1212 |
|
|
1213 |
orderEntityJsonObject.addProperty("DocStatusDesc", docStatusDesc); |
|
1214 |
|
|
1215 |
//是否显示:支付按钮 |
|
1216 |
orderEntityJsonObject.addProperty("isShowPayButton",cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(0) |
|
1217 |
&&orderEntity.getCltCode()!=null&&orderEntity.getCltCode().equals(cltCode) |
|
1218 |
&&orderEntity.getIsAllowPayable()!=null&&orderEntity.getIsAllowPayable().equals(1)?true:false); |
|
1219 |
|
|
1220 |
//是否显示:取消订单按钮 |
|
1221 |
orderEntityJsonObject.addProperty("isShowCancelButton",settingEntity.isAllowReturnOrder()&& cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&(orderEntity.getDocStatus().equals(100)||orderEntity.getDocStatus().equals(0)) ?true:false); |
|
1222 |
|
|
1223 |
//是否显示:查看物流按钮 |
|
1224 |
//boolean isShowLogisticsButton = (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&& orderEntity.getLogisticsCode()!=null && !orderEntity.getLogisticsCode().equals("")?true:false); |
|
1225 |
//orderEntityJsonObject.addProperty("isShowLogisticsButton",(cltCode.equals(orderEntity.getCltCode()))&&isShowLogisticsButton&&orderEntity.getShipperCode()!=null&& !orderEntity.getShipperCode().equals("") ); |
|
1226 |
//是否显示:收货按钮 |
|
1227 |
//orderEntityJsonObject.addProperty("isShowReceiptButton", cltCode.equals(orderEntity.getCltCode()) && isShowLogisticsButton && |
|
1228 |
// orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&!orderEntity.isReceiptGoodsByCustomer() ?true:false); |
|
1229 |
|
|
1230 |
//是否显示:删除按钮 |
|
1231 |
orderEntityJsonObject.addProperty("isShowDeleteButton", orderEntity.getDocStatus().equals(0) ||(orderEntity.getDocStatus()!=null &&orderEntity.getDocStatus().equals(-200)) ?true:false); |
|
1232 |
//generateOrderProcess : 0.生成订单可立即支付 ,1.生成订单,导购审核后才能支付(适用于生鲜类卖家,卖牛肉牛排的 ,他们按份卖,客户下单 时1份,假设1份 500克,实际卖出时是按称重卖的,可能有 510克,那最后付款也是按 510克付。) |
|
1233 |
//orderEntityJsonObject.addProperty("generateOrderProcess",settingEntity.getGenerateOrderProcess() ); |
|
1234 |
|
|
1235 |
orderEntityJsonObject.addProperty("title", orderEntity.getTitle()); //活动标题 |
|
1236 |
orderEntityJsonObject.addProperty("coverImage", orderEntity.getCoverImage()); //产品图片 |
|
1237 |
orderEntityJsonObject.addProperty("coverImageUrl", SettingKey.getUrl(hostUrl, orderEntity.getCoverImageUrl(), dbid,null) ); //产品图片 |
|
1238 |
orderEntityJsonObject.addProperty("originalPrice", orderEntity.getOriginalPrice()); //原价 |
|
1239 |
orderEntityJsonObject.addProperty("salesPrice", orderEntity.getSalesPrice()); //秒杀价,报名邀约时是报名费 |
|
1240 |
orderEntityJsonObject.addProperty("numberOfTeam", orderEntity.getNumberOfTeam()); //成团人数 |
|
1241 |
orderEntityJsonObject.addProperty("effectiveStartDate",orderEntity.getEffectiveStartDate()==null?"":sdf3.format(orderEntity.getEffectiveStartDate())); //开始时间 |
|
1242 |
orderEntityJsonObject.addProperty("effectiveEndDate",orderEntity.getEffectiveEndDate()==null?"":sdf3.format(orderEntity.getEffectiveEndDate())); //结束时间 |
|
1243 |
orderEntityJsonObject.addProperty("effectiveStartDateBalance", orderEntity.getEffectiveStartDateBalance()); //开始时间 秒数 |
|
1244 |
orderEntityJsonObject.addProperty("effectiveEndDateBalance", orderEntity.getEffectiveEndDateBalance()); //结束时间 秒数 |
|
1245 |
orderEntityJsonObject.addProperty("quantity", orderEntity.getQuantity()); //秒杀总量 |
|
1246 |
orderEntityJsonObject.addProperty("restrictBuyingQuantity", orderEntity.getRestrictBuyingQuantity()); //限购数量 |
|
1247 |
orderEntityJsonObject.addProperty("freeId", orderEntity.getFreeId()); //配送方式 : 到店自提,送货上门 |
|
1248 |
orderEntityJsonObject.addProperty("freeName", orderEntity.getFreeName()); //配送方式 : 到店自提,送货上门 |
|
1249 |
orderEntityJsonObject.addProperty("isRequiredAddress", orderEntity.isRequiredAddress()); //下单时检查收货地址,如果需要检查,则有可能填写了配送费,需要在页面上显示给客户看 |
|
1250 |
orderEntityJsonObject.addProperty("transCosts", orderEntity.getTransCosts()); //送货上门时 配送费 |
|
1251 |
orderEntityJsonObject.addProperty("description", orderEntity.getDescription()); //活动规则图片描述 |
|
1252 |
orderEntityJsonObject.addProperty("images", orderEntity.getImages()); //活动规则图片描述 |
226142
|
1253 |
//取出导购上传的图片 |
J |
1254 |
JsonArray orderDetailImageJsonArray = new JsonArray(); |
|
1255 |
if (orderEntity.getImagesUrl()!=null && !orderEntity.getImagesUrl().equals("")) { |
|
1256 |
String images[] = orderEntity.getImagesUrl().split(";") ; |
|
1257 |
for (int j = 0; j < images.length; j++) { |
|
1258 |
orderDetailImageJsonArray.add(SettingKey.getUrl(hostUrl, images[j], dbid,null) ); |
|
1259 |
} |
|
1260 |
} |
|
1261 |
orderEntityJsonObject.add("imagesUrl",orderDetailImageJsonArray) ; //活动规则图片描述 |
02cac6
|
1262 |
orderEntityJsonObject.addProperty("visiteTimes", orderEntity.getVisiteTimes()); //浏览人数 |
473089
|
1263 |
orderEntityJsonObject.addProperty("sharedTimes", orderEntity.getSharedTimes()); //转发次数 |
J |
1264 |
orderEntityJsonObject.addProperty("orderTimes", orderEntity.getOrderTimes()); //订单次数 |
|
1265 |
orderEntityJsonObject.addProperty("orderDigit", orderEntity.getOrderDigit()); //订单数量 |
|
1266 |
orderEntityJsonObject.addProperty("orderAmount", orderEntity.getOrderAmount()); //订单金额 |
02cac6
|
1267 |
|
J |
1268 |
orderEntityJsonObject.addProperty("panicBuyingStatus", orderEntity.getPanicBuyingStatus()); //活动状态: 0 未发布; 1 未开始; 2 进行中; 3 已停止; |
|
1269 |
String statusName = "起草" ; |
|
1270 |
switch (orderEntity.getPanicBuyingStatus()) { |
|
1271 |
case 0: |
|
1272 |
statusName = "起草" ; |
|
1273 |
break; |
|
1274 |
case 1: |
|
1275 |
statusName = "未开始" ; |
|
1276 |
break; |
|
1277 |
case 2: |
|
1278 |
statusName = "进行中" ; |
|
1279 |
break; |
|
1280 |
case 3: |
|
1281 |
statusName = "已停止" ; |
|
1282 |
break; |
|
1283 |
default: |
|
1284 |
break; |
|
1285 |
} |
|
1286 |
orderEntityJsonObject.addProperty("panicBuyingStatusName", statusName); //活动状态: 0 未发布; 1 未开始; 2 进行中; 3 已停止; |
|
1287 |
String formName = "秒杀"; |
|
1288 |
switch (orderEntity.getRefFormId().intValue()) { |
|
1289 |
case 710802: |
|
1290 |
formName = "秒杀"; |
|
1291 |
break; |
|
1292 |
case 710803: |
|
1293 |
formName = "邀约"; |
|
1294 |
break; |
|
1295 |
case 710804: |
|
1296 |
formName = "拼团"; |
|
1297 |
break; |
|
1298 |
|
|
1299 |
default: |
|
1300 |
break; |
|
1301 |
} |
|
1302 |
orderEntityJsonObject.addProperty("formName", formName); |
226142
|
1303 |
orderEntityJsonObject.addProperty("qrCode", orderEntity.getQrCode()); |
e42ed7
|
1304 |
|
J |
1305 |
orderEntityJsonObject.addProperty("HeXiaoStatus",orderEntity.getHeXiaoStatus()); |
|
1306 |
orderEntityJsonObject.addProperty("HeXiaoStatusName",orderEntity.getHeXiaoStatusName()); |
b8896c
|
1307 |
orderEntityJsonObject.addProperty("isShowHeXiaoButton",((openId).equals(orderEntity.getPanicBuyingOpenId()) || (openId).equals(orderEntity.getSellerOpenId()))&&orderEntity.getHeXiaoStatus()!=null&&orderEntity.getHeXiaoStatus().equals(0)); |
e42ed7
|
1308 |
orderEntityJsonObject.addProperty("SellerId",orderEntity.getSellerId()); |
J |
1309 |
orderEntityJsonObject.addProperty("SellerName",orderEntity.getSellerName()); |
|
1310 |
orderEntityJsonObject.addProperty("SellerTelephone",orderEntity.getSellerTelephone()); |
473089
|
1311 |
orderEntityJsonObject.addProperty("SellerTelephoneMask",StringReplaceUtil.getTelephoneMask(orderEntity.getSellerTelephone())); |
b8896c
|
1312 |
orderEntityJsonObject.addProperty("ReturnStatus",orderEntity.getReturnStatus()); |
J |
1313 |
orderEntityJsonObject.addProperty("ReturnStatusName",orderEntity.getReturnStatusName()); |
|
1314 |
orderEntityJsonObject.addProperty("isShowReturnButton",((openId).equals(orderEntity.getPanicBuyingOpenId()) || (openId).equals(orderEntity.getSellerOpenId()))&orderEntity.getReturnStatus()!=null&&orderEntity.getReturnStatus().equals(0)); |
02cac6
|
1315 |
return orderEntityJsonObject ; |
J |
1316 |
} |
|
1317 |
|
|
1318 |
private String getDocStatusDescription(PanicBuyingOrderEntity orderEntity) { |
b3acab
|
1319 |
if (orderEntity.getDocStatus().equals(-200)) { |
F |
1320 |
return "已取消"; |
|
1321 |
} |
|
1322 |
|
|
1323 |
if (orderEntity.getDocStatus().equals(0)) { |
|
1324 |
//是否可支付 isAllowPayable 状态: 0.不能支付,1.可支付,2.已支付 ,3.正在退款,4.已退款,5.无需支付 |
|
1325 |
if (orderEntity.getIsAllowPayable().equals(0)) { |
|
1326 |
return "待卖家确认"; |
|
1327 |
}else if (orderEntity.getIsAllowPayable().equals(1)) { |
|
1328 |
return "待买家付款"; |
|
1329 |
}else if (orderEntity.getIsAllowPayable().equals(2)) { |
|
1330 |
return "待商家发货" ; // "买家已付款"; |
|
1331 |
}else if (orderEntity.getIsAllowPayable().equals(3)) { |
|
1332 |
return "正在退款"; |
|
1333 |
}else if (orderEntity.getIsAllowPayable().equals(4)){ |
|
1334 |
return "已退款"; |
|
1335 |
}else if (orderEntity.getIsAllowPayable().equals(5)){ |
|
1336 |
return "待商家发货"; |
|
1337 |
} |
|
1338 |
|
|
1339 |
} |
|
1340 |
|
|
1341 |
|
b89d6f
|
1342 |
if (orderEntity.getDocStatus().equals(100)) { |
74f517
|
1343 |
if (orderEntity.getTuiHuoRuKuDigit() >= orderEntity.getDigit()) { |
J |
1344 |
return "已退款"; |
|
1345 |
}if (orderEntity.getHeXiaoStatus().intValue() == 1) { |
|
1346 |
return "已核销"; |
|
1347 |
}else if (orderEntity.getIsAllowPayable().equals(2)) { |
b3acab
|
1348 |
return "买家已付款"; |
F |
1349 |
}else if (orderEntity.getIsAllowPayable().equals(3)) { |
|
1350 |
return "正在退款"; |
|
1351 |
}else if (orderEntity.getIsAllowPayable().equals(4)){ |
|
1352 |
return "已退款"; |
|
1353 |
}else if (orderEntity.getIsAllowPayable().equals(5)){ |
|
1354 |
return "待商家发货"; |
|
1355 |
} |
|
1356 |
} |
|
1357 |
return "交易完成" ; |
|
1358 |
} |
|
1359 |
|
|
1360 |
/** |
|
1361 |
* 修改单据状态,客户删单,单据对客户隐藏 |
|
1362 |
* |
|
1363 |
* @param request |
|
1364 |
* @param response |
|
1365 |
*/ |
|
1366 |
@RequestMapping(params = "m=deleteOrder") |
|
1367 |
public void orderDelete(HttpServletRequest request, |
|
1368 |
HttpServletResponse response) { |
|
1369 |
HttpSession session = request.getSession(); |
|
1370 |
JsonObject json = new JsonObject(); |
|
1371 |
JsonObject errJson = new JsonObject(); |
|
1372 |
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE); |
|
1373 |
String cltCode = (session.getAttribute(SettingKey.CLTCODE)==null?"":(String)session.getAttribute(SettingKey.CLTCODE)); |
|
1374 |
String hostUrl = SettingKey.getHostUrl(request); |
|
1375 |
// 将微信corpid组装成url |
|
1376 |
String wxQueryString = SettingKey.getQueryStringByWx(request); |
|
1377 |
boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request); |
|
1378 |
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID); |
|
1379 |
try { |
|
1380 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
1381 |
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源 |
|
1382 |
|
|
1383 |
|
|
1384 |
Boolean issuccess = panicBuyingOrderIfc.deletePanicBuyingOrder(cltCode,docCode); |
|
1385 |
if (!issuccess) { |
|
1386 |
json.addProperty("success", "删除订单失败!"); |
|
1387 |
json.addProperty("state", issuccess ? "success": "falied"); |
|
1388 |
this.printJson(response, json.toString()); |
|
1389 |
return; |
|
1390 |
} |
|
1391 |
json.addProperty("state", issuccess ? "success": "falied"); |
|
1392 |
json.addProperty("success", "删除订单成功!"); |
|
1393 |
String redirect = hostUrl |
|
1394 |
+ "/shopping/" |
|
1395 |
+ (isMoblieBrowser ? "mobile/" : "") |
|
1396 |
+ "account/order.jsp?"+ SettingKey.DOCCODE + "=" |
|
1397 |
+ docCode |
|
1398 |
+ "" |
|
1399 |
+ (wxQueryString == null || "".equals(wxQueryString) ? "" |
|
1400 |
: "&" + wxQueryString); |
|
1401 |
json.addProperty("redirect", redirect); |
|
1402 |
this.printJson(response, json.toString()); |
|
1403 |
return; |
|
1404 |
} catch (DataAccessException e) { |
|
1405 |
|
|
1406 |
e.printStackTrace(); |
|
1407 |
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage()); |
|
1408 |
json.add("error", errJson); |
|
1409 |
this.printJson(response, json.toString()); |
|
1410 |
return; |
|
1411 |
} catch (Exception e) { |
|
1412 |
e.printStackTrace(); |
|
1413 |
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage()); |
|
1414 |
json.add("error", errJson); |
|
1415 |
this.printJson(response, json.toString()); |
|
1416 |
return; |
|
1417 |
} finally { |
|
1418 |
SpObserver.setDBtoInstance(); |
|
1419 |
} |
|
1420 |
} |
226142
|
1421 |
|
J |
1422 |
|
|
1423 |
|
|
1424 |
/** |
|
1425 |
* 展示需核销订单的二维码 |
|
1426 |
* @param request |
|
1427 |
* @param response |
|
1428 |
*/ |
|
1429 |
@RequestMapping(params = "m=getQrCode") |
|
1430 |
public void getQrCode(HttpServletRequest request, HttpServletResponse response) { |
|
1431 |
//HttpSession session = request.getSession(); |
|
1432 |
JsonObject json = new JsonObject(); |
|
1433 |
JsonObject errJson = new JsonObject(); |
|
1434 |
String qrCode = request.getParameter("qrcode") ; |
|
1435 |
if (qrCode == null||"".equals(qrCode)) { |
|
1436 |
errJson.addProperty("warning","请传递 qrcode 参数【/shopping/panicBuyingOrder.do?m=getQrCode】"); |
|
1437 |
json.add("error", errJson); |
|
1438 |
this.printJson(response, json.toString()); |
|
1439 |
return ; |
|
1440 |
} |
|
1441 |
|
|
1442 |
try { |
|
1443 |
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ; |
|
1444 |
SpObserver.setDBtoInstance("_" + dataSourceEntity.getDbId());// 切换数据源 |
|
1445 |
SettingEntity settingEntity = settingIfc.getSettingEntity(); |
|
1446 |
|
|
1447 |
QrCodeForAppEntity qrCodeForAppEntity = matCodeIfc.getQrCodeEntity( qrCode) ; //获取存在的二维码 |
|
1448 |
if (qrCodeForAppEntity == null) { |
|
1449 |
errJson.addProperty("warning","该二维码不存在!" + qrCode ); |
|
1450 |
json.add("error", errJson); |
|
1451 |
this.printJson(response, json.toString()); |
|
1452 |
return ; |
|
1453 |
} |
|
1454 |
|
|
1455 |
String qrCodeImage = imgData.getImageUrl(qrCodeForAppEntity.getQrCodeUnid(), settingEntity.getImagePopupWidth(), |
|
1456 |
settingEntity.getImagePopupHeight(), settingEntity.isShowPopupOrgImage(), |
|
1457 |
settingEntity.isFromCached(), request); |
|
1458 |
|
|
1459 |
json.addProperty("qrCodeImage", qrCodeImage); |
|
1460 |
json.addProperty("state", "success"); |
|
1461 |
this.printJson(response, json.toString()); |
|
1462 |
return; |
|
1463 |
|
|
1464 |
} catch (DataAccessException e) { |
|
1465 |
e.printStackTrace(); |
|
1466 |
errJson.addProperty("warning", (e.getCause()!=null?e.getCause().getMessage():e.getMessage())); |
|
1467 |
json.add("error", errJson); |
|
1468 |
this.printJson(response, json.toString()); |
|
1469 |
return; |
|
1470 |
}catch (Exception e ){ |
|
1471 |
e.printStackTrace(); |
|
1472 |
errJson.addProperty("warning",(e.getCause()!=null?e.getCause().getMessage():e.getMessage())); |
|
1473 |
json.add("error", errJson); |
|
1474 |
this.printJson(response, json.toString()); |
|
1475 |
return; |
|
1476 |
} finally { |
|
1477 |
SpObserver.setDBtoInstance(); |
|
1478 |
} |
|
1479 |
} |
a6a76f
|
1480 |
} |