当前位置:   article > 正文

商家订单之Java版SpringCloud+SpringBoot+Mybatis+Vue+Uniapp 分布式、微服务、多商家入驻b2b2c电子商务云平台_java 多商户电商系统 免费 springcloud

java 多商户电商系统 免费 springcloud

 源码地址来源: https://minglisoft.cn/honghu2/business.html

  1. package com.honghu.cloud.controller;
  2. import java.math.BigDecimal;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import javax.servlet.http.HttpServletRequest;
  9. import org.apache.http.HttpResponse;
  10. import org.apache.http.client.methods.HttpPost;
  11. import org.apache.http.entity.StringEntity;
  12. import org.apache.http.impl.client.DefaultHttpClient;
  13. import org.apache.http.util.EntityUtils;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.web.bind.annotation.CrossOrigin;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import com.alibaba.fastjson.JSON;
  23. import com.alibaba.fastjson.JSONException;
  24. import com.google.common.collect.Lists;
  25. import com.google.common.collect.Maps;
  26. import com.honghu.cloud.bean.DaDaAppConfig;
  27. import com.honghu.cloud.bean.DaDaService;
  28. import com.honghu.cloud.bean.DadaApiResponse;
  29. import com.honghu.cloud.bean.ShopAddModel;
  30. import com.honghu.cloud.bean.Store;
  31. import com.honghu.cloud.code.ResponseCode;
  32. import com.honghu.cloud.dto.AreaDto;
  33. import com.honghu.cloud.dto.CouponInfoDto;
  34. import com.honghu.cloud.dto.EvaluateDto;
  35. import com.honghu.cloud.dto.ExpressCompanyCommonDto;
  36. import com.honghu.cloud.dto.ExpressCompanyDto;
  37. import com.honghu.cloud.dto.ExpressInfoDto;
  38. import com.honghu.cloud.dto.GoodsDto;
  39. import com.honghu.cloud.dto.MessageDto;
  40. import com.honghu.cloud.dto.OrderFormDto;
  41. import com.honghu.cloud.dto.OrderFormLogDto;
  42. import com.honghu.cloud.dto.RefundApplyFormDto;
  43. import com.honghu.cloud.dto.ReturnGoodsLogDto;
  44. import com.honghu.cloud.dto.ShipAddressDto;
  45. import com.honghu.cloud.dto.SysConfigDto;
  46. import com.honghu.cloud.dto.TransInfoDto;
  47. import com.honghu.cloud.dto.UserDto;
  48. import com.honghu.cloud.feign.AreaFeignClient;
  49. import com.honghu.cloud.feign.CouponInfoFeignClient;
  50. import com.honghu.cloud.feign.EvaluateFeignClient;
  51. import com.honghu.cloud.feign.ExpressCompanyCommonFeignClient;
  52. import com.honghu.cloud.feign.ExpressCompanyFeignClient;
  53. import com.honghu.cloud.feign.ExpressInfoFeignClient;
  54. import com.honghu.cloud.feign.GoodsFeignClient;
  55. import com.honghu.cloud.feign.MessageFeignClient;
  56. import com.honghu.cloud.feign.ModularClassFeignClient;
  57. import com.honghu.cloud.feign.MsgToolsFeignClient;
  58. import com.honghu.cloud.feign.OrderFormFeignClient;
  59. import com.honghu.cloud.feign.OrderFormLogFeignClient;
  60. import com.honghu.cloud.feign.OrderFormToolsFeignClient;
  61. import com.honghu.cloud.feign.RefundApplyFormFeignClient;
  62. import com.honghu.cloud.feign.ReturnGoodsLogFeignClient;
  63. import com.honghu.cloud.feign.ShipAddressFeignClient;
  64. import com.honghu.cloud.feign.ShipToolsFeignClient;
  65. import com.honghu.cloud.feign.SysConfigFeignClient;
  66. import com.honghu.cloud.feign.UserFeignClient;
  67. import com.honghu.cloud.service.IStoreService;
  68. import com.honghu.cloud.tools.DadaRequestClient;
  69. import com.honghu.cloud.tools.JSONUtil;
  70. import com.honghu.cloud.tools.QueryTools;
  71. import com.honghu.cloud.tools.SecurityUserHolder;
  72. import com.honghu.cloud.utils.CommUtil;
  73. import com.honghu.cloud.utils.StringUtils;
  74. import com.honghu.cloud.utils.tools.Md5Encrypt;
  75. import lombok.extern.slf4j.Slf4j;
  76. import net.sf.json.JSONObject;
  77. @CrossOrigin(origins = "*", maxAge = 3600)
  78. @Slf4j
  79. @RestController
  80. @RequestMapping(value = "/applet/storeOrder")
  81. public class AppletStoreOrderController {
  82. private final Logger logger = LoggerFactory.getLogger(AppletStoreOrderController.class);
  83. @Autowired
  84. private IStoreService storeService;
  85. @Autowired
  86. private OrderFormFeignClient orderFormFeignClient;
  87. @Autowired
  88. private UserFeignClient userFeignClient;
  89. @Autowired
  90. private GoodsFeignClient goodsFeignClient;
  91. @Autowired
  92. private QueryTools queryTools;
  93. @Autowired
  94. private RefundApplyFormFeignClient refundapplyformfeignclient;
  95. @Autowired
  96. private MessageFeignClient messagefeignclient;
  97. @Autowired
  98. private ReturnGoodsLogFeignClient returnGoodsLogFeignClient;
  99. @Autowired
  100. private ShipToolsFeignClient shipToolsFeignClient;
  101. @Autowired
  102. private OrderFormToolsFeignClient orderFormToolsFeignClient;
  103. @Autowired
  104. private OrderFormLogFeignClient orderFormLogFeignClient;
  105. @Autowired
  106. private MsgToolsFeignClient msgToolsFeignClient;
  107. @Autowired
  108. private ExpressCompanyCommonFeignClient companyCommonFeignClient;
  109. @Autowired
  110. private ShipAddressFeignClient shipAddressFeignClient;
  111. @Autowired
  112. private SysConfigFeignClient sysConfigFeignClient;
  113. @Autowired
  114. private ExpressInfoFeignClient expressInfoFeignClient;
  115. @Autowired
  116. private EvaluateFeignClient evaluateFeignClient;
  117. @Autowired
  118. private ExpressCompanyFeignClient expressCompanyFeignClient;
  119. @Autowired
  120. private ExpressCompanyCommonFeignClient expressCompanyCommonFeignClient;
  121. @Autowired
  122. private AreaFeignClient areaFeignClient;
  123. @Autowired
  124. private ModularClassFeignClient modularClassFeignClient;
  125. @Autowired
  126. private CouponInfoFeignClient couponInfoFeignClient;
  127. /**
  128. * 卖家订单列表
  129. * @param request
  130. * @param response
  131. * @param currentPage
  132. * @param order_status
  133. * @param order_id
  134. * @param beginTime
  135. * @param endTime
  136. * @param buyer_userName
  137. * @return
  138. */
  139. @RequestMapping( value = { "/order" } , method = RequestMethod.POST)
  140. public Map<String,Object> order(HttpServletRequest request,
  141. @RequestBody JSONObject json) {
  142. String currentPage = json.optString("currentPage");
  143. String order_status = json.optString("order_status");
  144. String order_id = json.optString("order_id");
  145. /*String beginTime = json.optString("beginTime");
  146. String endTime = json.optString("endTime");*/
  147. String order_id_userName = json.optString("order_id_userName");
  148. Map<String,Object> maps= this.queryTools.getParams(currentPage,"addTime", "desc");
  149. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  150. if(user == null){
  151. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  152. }
  153. if (user.getParent_id()!=null) {
  154. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  155. }
  156. if(user.getStore_id() == null){
  157. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  158. }
  159. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  160. .getStore_id()));
  161. if(store != null){
  162. maps.put("store_id", store.getId());
  163. }else{
  164. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  165. }
  166. /* maps.put("order_cat_no", 2);
  167. */ Map<String, Object> map = Maps.newHashMap();
  168. if (!CommUtil.null2String(order_status).equals("")) {
  169. if (order_status.equals("order_submit")) {//代付款
  170. maps.put("order_status1", Integer.valueOf(10));
  171. maps.put("order_status2", Integer.valueOf(16));
  172. }
  173. if (order_status.equals("order_pay")) { //代发货
  174. maps.put("order_status1", Integer.valueOf(20));
  175. maps.put("order_status2", Integer.valueOf(14));
  176. }
  177. if (order_status.equals("order_shipping")) {//待收货 已发货
  178. //maps.put("order_status", Integer.valueOf(30));
  179. maps.put("order_status_0", Integer.valueOf(30));
  180. maps.put("order_status_1", Integer.valueOf(31));
  181. maps.put("order_status_2", Integer.valueOf(32));
  182. }
  183. if (order_status.equals("order_evaluate")) {// 已收货 待评价
  184. maps.put("order_status", Integer.valueOf(40));
  185. }
  186. if (order_status.equals("order_finish")) { //评论完
  187. maps.put("order_status", Integer.valueOf(50));
  188. }
  189. if (order_status.equals("order_cancel")) {//订单取消
  190. maps.put("order_status", Integer.valueOf(0));
  191. }
  192. if (order_status.equals("order_refund")) {//退款中
  193. maps.put("order_status", Integer.valueOf(21));
  194. }
  195. }
  196. if (!CommUtil.null2String(order_id).equals("")) {
  197. maps.put("order_id_like", order_id);
  198. }
  199. /*if (!CommUtil.null2String(beginTime).equals("")) {
  200. maps.put("add_Time_more_than_equal", CommUtil.formatDate(beginTime));
  201. map.put("beginTime", beginTime);
  202. }
  203. if (!CommUtil.null2String(endTime).equals("")) {
  204. String ends = endTime + " 23:59:59";
  205. maps.put("add_Time_less_than_equal", CommUtil.formatDate(ends,"yyyy-MM-dd hh:mm:ss"));
  206. map.put("endTime", endTime);
  207. }*/
  208. if (!CommUtil.null2String(order_id_userName).equals("")) {
  209. maps.put("order_id_userName", order_id_userName);
  210. }
  211. Map<String, Object> list = this.orderFormFeignClient.list(maps);
  212. map.putAll(list);
  213. /*map.put("list", list);*/
  214. map.put("order_id", order_id);
  215. map.put("order_status", order_status == null ? "all" : order_status);
  216. return ResponseCode.buildSuccessMap(map);
  217. }
  218. /**
  219. * 卖家订单
  220. * @param request
  221. * @param response
  222. * @param currentPage
  223. * @param order_status
  224. * @param order_id
  225. * @param beginTime
  226. * @param endTime
  227. * @param buyer_userName
  228. * @return
  229. */
  230. @RequestMapping( value = { "/orderHome" } , method = RequestMethod.POST)
  231. public Map<String,Object> orderHome(HttpServletRequest request) {
  232. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  233. if(user == null){
  234. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  235. }
  236. if (user.getParent_id()!=null) {
  237. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  238. }
  239. if(user.getStore_id() == null){
  240. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  241. }
  242. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  243. .getStore_id()));
  244. if(store == null){
  245. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  246. }
  247. Map<String, Object> map = Maps.newHashMap();
  248. map.put("store_id", store.getId());
  249. //代付款1
  250. map.put("order_status1", Integer.valueOf(10));
  251. map.put("order_status2", Integer.valueOf(16));
  252. Integer order_submit = this.orderFormFeignClient.selectCount(map);
  253. //代发货1
  254. map.clear();
  255. map.put("store_id", store.getId());
  256. map.put("order_status", Integer.valueOf(20));
  257. Integer order_pay = this.orderFormFeignClient.selectCount(map);
  258. //待收货 已发货 1
  259. map.clear();
  260. map.put("store_id", store.getId());
  261. map.put("order_status", Integer.valueOf(30));
  262. Integer order_shipping = this.orderFormFeignClient.selectCount(map);
  263. // 已收货 待评价1
  264. map.clear();
  265. map.put("store_id", store.getId());
  266. map.put("order_status", Integer.valueOf(40));
  267. Integer order_evaluate = this.orderFormFeignClient.selectCount(map);
  268. //退款中1
  269. map.clear();
  270. map.put("store_id", store.getId());
  271. map.put("refundStatus", 1);
  272. Integer order_refund = this.orderFormFeignClient.selectCount(map);
  273. map.put("selectCount_refund", order_refund);
  274. map.clear();
  275. map.put("store_id", user.getStore_id());
  276. int selectCount = this.returnGoodsLogFeignClient.selectCount(map);
  277. if(order_refund == null){
  278. order_refund = 0;
  279. }
  280. order_refund = order_refund + selectCount;
  281. map.clear();
  282. map.put("order_submit", order_submit);
  283. map.put("order_pay", order_pay);
  284. map.put("order_shipping", order_shipping);
  285. map.put("order_evaluate", order_evaluate);
  286. map.put("order_refund", order_refund);
  287. return ResponseCode.buildSuccessMap(map);
  288. }
  289. /**订单详情
  290. * @param request
  291. * @param json
  292. * @return
  293. */
  294. @RequestMapping(value = { "/order_view" } , method = RequestMethod.POST)
  295. public Map<String , Object> order_view(HttpServletRequest request,
  296. @RequestBody JSONObject json) {
  297. String id = json.optString("id");
  298. OrderFormDto obj = this.orderFormFeignClient
  299. .selectByPrimaryKey(CommUtil.null2Long(id));
  300. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  301. .getCurrentUser(request).getId());
  302. if(user == null){
  303. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  304. }
  305. if (user.getParent_id()!=null) {
  306. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  307. }
  308. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  309. .getStore_id()));
  310. if(store == null){
  311. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  312. }
  313. if(user.getStore_id() == null){
  314. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  315. }
  316. if (user.getStore_id().equals(store.getId())) {
  317. Map<String , Object> maps = Maps.newHashMap();
  318. if(obj.getOrder_status() == 10){
  319. SysConfigDto sys = this.sysConfigFeignClient.getSysConfig();
  320. Integer auto_order_cancel = sys.getAuto_order_cancel();
  321. Date addTime = obj.getAddTime();
  322. Date date = new Date();
  323. /*System.out.println(((addTime.getTime() - date.getTime()) / (24 * 60 * 60 * 1000))/ 365 + "年");
  324. System.out.println((addTime.getTime() - date.getTime()) / (24 * 60 * 60 * 1000) + "天");
  325. System.out.println((((addTime.getTime() - date.getTime()) / (60 * 60 * 1000)) % 24) + "小时");
  326. System.out.println((((addTime.getTime() - date.getTime()) / 1000) % 60) + "分钟");
  327. System.out.println(((addTime.getTime() - date.getTime()) / (60 * 1000)) % 60 + "秒");*/
  328. maps.put("obj", obj);
  329. maps.put("second", (((addTime.getTime() - date.getTime()) / 1000)) + auto_order_cancel*60*60);
  330. }
  331. maps.put("obj", obj);
  332. return ResponseCode.buildSuccessMap(maps);
  333. } else {
  334. return ResponseCode.buildEnumMap(ResponseCode.FAILURE, null);
  335. }
  336. }
  337. /**
  338. * 卖家取消订单
  339. * @param request
  340. * @param response
  341. * @param id
  342. * @param currentPage
  343. * @return
  344. */
  345. @RequestMapping(value ={ "/order_cancel" } ,method = RequestMethod.POST)
  346. public Map<String , Object> order_cancel(HttpServletRequest request , @RequestBody JSONObject jsonv) {
  347. String id = jsonv.optString("id");
  348. if (SecurityUserHolder.getCurrentUserId(request)==null) {
  349. return ResponseCode.buildCodeMap("1111", "userid为空", null);
  350. }
  351. UserDto seller = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  352. OrderFormDto obj = this.orderFormFeignClient.selectByPrimaryKey(CommUtil.null2Long(id));
  353. if(seller == null){
  354. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  355. }
  356. if (seller.getParent_id()!=null) {
  357. seller = this.userFeignClient.selectByPrimaryKey(seller.getParent_id());
  358. }
  359. //user = user.getParent_id() == null ? user : user.getParent();
  360. if(seller.getStore_id() == null){
  361. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  362. }
  363. //System.out.println("---------user--getStore_id-------------"+seller
  364. //.getStore_id());
  365. Store store = this.storeService.selectByPrimaryKey(seller
  366. .getStore_id());
  367. //System.out.println("---------user---------------"+seller.getId());
  368. //System.out.println("------------obj-------------"+obj.getId());
  369. //System.out.println("---------seller---------------"+seller.getStore_id());
  370. if(store == null){
  371. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  372. }
  373. System.out.println("-----------store--------------"+store.getId());
  374. if ((seller.getStore_id() != null)&& (CommUtil.null2String(obj.getStore_id()).equals(seller.getStore_id().toString()))) {
  375. return ResponseCode.buildSuccessMap(obj);
  376. } else {
  377. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  378. }
  379. }
  380. /**
  381. * 卖家取消订单保存
  382. * @param request
  383. * @param response
  384. * @param id
  385. * @param currentPage
  386. * @return
  387. */
  388. @RequestMapping(value ={ "/order_cancel_save" } ,method = RequestMethod.POST)
  389. public Map<String , Object> order_cancel_save(HttpServletRequest request , @RequestBody JSONObject jsonv) {
  390. String id = jsonv.optString("id");
  391. String state_info = jsonv.optString("state_info");
  392. String other_state_info = jsonv.optString("other_state_info");
  393. UserDto seller = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  394. OrderFormDto obj = this.orderFormFeignClient.selectByPrimaryKey(CommUtil.null2Long(id));
  395. if(seller == null){
  396. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  397. }
  398. if (seller.getParent_id()!=null) {
  399. seller = this.userFeignClient.selectByPrimaryKey(seller.getParent_id());
  400. }
  401. //user = user.getParent_id() == null ? user : user.getParent();
  402. if(seller.getStore_id() == null){
  403. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  404. }
  405. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(seller
  406. .getStore_id()));
  407. if(store == null){
  408. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  409. }
  410. Date nowDate = new Date();
  411. if ((seller.getStore_id() != null)&& (CommUtil.null2String(obj.getStore_id()).equals(seller.getStore_id().toString()))) {
  412. obj.setOrder_status(0);
  413. if ((obj.getCoupon_info() != null)
  414. && (!"".equals(obj.getCoupon_info()))) {
  415. Map m = JSON.parseObject(obj.getCoupon_info());
  416. CouponInfoDto cpInfo = this.couponInfoFeignClient.selectByPrimaryKey(CommUtil
  417. .null2Long(m.get("couponinfo_id")));
  418. if (cpInfo != null) {
  419. if (nowDate.before(cpInfo.getEndDate())) {
  420. cpInfo.setStatus(0);
  421. } else {
  422. cpInfo.setStatus(-1);
  423. }
  424. }
  425. }
  426. orderFormFeignClient.updateById(obj);
  427. OrderFormLogDto ofl = new OrderFormLogDto();
  428. ofl.setAddTime(new Date());
  429. ofl.setLog_info("取消订单");
  430. ofl.setLog_user_id(seller.getId());
  431. ofl.setLog_user_name(seller.getUserName());
  432. ofl.setOf_id(obj.getId());
  433. if (state_info.equals("其他原因")) {
  434. ofl.setState_info(other_state_info);
  435. } else {
  436. ofl.setState_info(state_info);
  437. }
  438. this.orderFormLogFeignClient.saveEntity(ofl);
  439. /* UserDto buyer = this.userFeignClient.selectByPrimaryKey(CommUtil.null2Long(obj
  440. .getUser_id()));
  441. Map<String, Object> map = Maps.newHashMap();
  442. map.put("buyer_id", buyer.getId().toString());
  443. map.put("seller_id", store.getUser_id());
  444. map.put("order_id", obj.getId());
  445. String json = JSON.toJSONString(map);*/
  446. /*if (obj.getOrder_form() == 0) {
  447. try {
  448. this.msgToolsFeignClient.sendEmailCharge(CommUtil.getURL(request),
  449. "email_tobuyer_order_cancel_notify", buyer.getEmail(),
  450. json, null, obj.getStore_id());
  451. this.msgToolsFeignClient.sendSmsCharge(CommUtil.getURL(request),
  452. "sms_tobuyer_order_cancel_notify", buyer.getMobile(),
  453. json, null, obj.getStore_id());
  454. } catch (Exception e) {
  455. // TODO Auto-generated catch block
  456. e.printStackTrace();
  457. }
  458. } else {
  459. try {
  460. this.msgToolsFeignClient.sendEmailFree(CommUtil.getURL(request),
  461. "email_tobuyer_order_cancel_notify", buyer.getEmail(),
  462. json, null);
  463. this.msgToolsFeignClient.sendSmsFree(CommUtil.getURL(request),
  464. "sms_tobuyer_order_cancel_notify", buyer.getMobile(),
  465. json, null);
  466. } catch (Exception e) {
  467. // TODO Auto-generated catch block
  468. e.printStackTrace();
  469. }
  470. }*/
  471. return ResponseCode.buildSuccessMap(null);
  472. } else {
  473. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  474. }
  475. }
  476. /**
  477. * 订单退款申请单
  478. * @param request
  479. * @param response
  480. * @param currentPage
  481. * @param orderBy
  482. * @param orderType
  483. * @param status
  484. * @return
  485. */
  486. @RequestMapping(value = { "/refund_apply_form" } , method = RequestMethod.POST)
  487. public Map<String,Object> refund_apply_form(HttpServletRequest request,
  488. @RequestBody JSONObject json) {
  489. String currentPage = json.optString("currentPage");
  490. String orderType = json.optString("orderType");
  491. String orderBy = json.optString("orderBy");
  492. //状态 0:待审核 5:审核拒绝 10:审核通过待退款 15:已退款
  493. String refundStatus = json.optString("refundStatus");
  494. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  495. if(user == null){
  496. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  497. }
  498. if (user.getParent_id()!=null) {
  499. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  500. }
  501. if(user.getStore_id() == null){
  502. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  503. }
  504. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  505. .getStore_id()));
  506. Map<String,Object> maps= this.queryTools.getParams(currentPage, orderBy, orderType);
  507. if ((refundStatus == null) || (refundStatus.equals(""))) {
  508. maps.put("refundStatus", CommUtil.null2Int(Integer.valueOf(0)));
  509. } else {
  510. maps.put("refundStatus", CommUtil.null2Int(Integer.valueOf(refundStatus)));
  511. }
  512. if(store != null){
  513. maps.put("store_id", store.getId());
  514. }else{
  515. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  516. }
  517. Map<String, Object> data = this.orderFormFeignClient.refundApplyFormList(maps);
  518. data.put("refundStatus", refundStatus);
  519. return ResponseCode.buildSuccessMap(data);
  520. }
  521. /**
  522. * 订单退款申请单详情
  523. * @param request
  524. * @param response
  525. * @param order_id
  526. * @return
  527. */
  528. @RequestMapping(value = { "/refund_orderform_view" } , method = RequestMethod.POST)
  529. public Map<String,Object> refund_orderform_view(HttpServletRequest request, @RequestBody JSONObject json) {
  530. Map<Object, Object> map = Maps.newHashMap();
  531. map.put("reason","");
  532. if (StringUtils.isBlank(json.optString("order_id"))) {
  533. return ResponseCode.buildReturnMap(ResponseCode.PARAM_ERROR, null);
  534. }
  535. String apply_from_id = json.optString("apply_from_id");
  536. if (StringUtils.isBlank(apply_from_id)) {
  537. return ResponseCode.buildReturnMap(ResponseCode.PARAM_ERROR, null);
  538. }
  539. OrderFormDto obj = this.orderFormFeignClient.selectByPrimaryKey(CommUtil.null2Long(json.optString("order_id")));
  540. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj.getStore_id()));
  541. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  542. if(user == null){
  543. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  544. }
  545. if (user.getParent_id()!=null) {
  546. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  547. }
  548. RefundApplyFormDto RefundApplyFormDto = refundapplyformfeignclient.selectByPrimaryKey(CommUtil.null2Long(apply_from_id));
  549. if(RefundApplyFormDto!=null){
  550. map.put("reason",RefundApplyFormDto.getReturn_content()); //退款原因
  551. }
  552. //user = user.getParent_id() == null ? user : user.getParent();
  553. if(user.getStore_id() == null){
  554. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  555. }
  556. if(store == null){
  557. return ResponseCode.buildReturnMap(ResponseCode.REQUEST_FORBIDDEN, null);
  558. }
  559. if(!user.getStore_id().equals(store.getId()) ||store.getStore_status()!=15){ //验证是否是当前商家 , 并且正常营业
  560. return ResponseCode.buildReturnMap(ResponseCode.REQUEST_FORBIDDEN, null);
  561. }
  562. if (obj != null) {
  563. String temp = obj.getSpecial_invoice();
  564. if ((temp != null) && (!"".equals(temp))) {
  565. Map of_va = JSON.parseObject(temp);
  566. map.put("of_va", of_va);
  567. }
  568. }
  569. map.put("obj", obj);
  570. String queryExInfo = this.queryExInfo(obj.getExpress_info(), "express_company_name");
  571. map.put("store", store);
  572. map.put("express_company_name", queryExInfo);
  573. //map.put("express_company_name", this.orderFormTools.queryExInfo(obj.getExpress_info(), "express_company_name"));
  574. ReturnGoodsLogDto returnGoodsLogDto = returnGoodsLogFeignClient.selectByOrderId(obj.getId());
  575. map.put("returnGoodsLogDto", returnGoodsLogDto);
  576. return ResponseCode.buildSuccessMap(map);
  577. }
  578. public String queryExInfo(String json, String key) {
  579. Map<String, Object> map = Maps.newHashMap();
  580. if ((json != null) && (!json.equals(""))) {
  581. map = JSON.parseObject(json);
  582. }
  583. return CommUtil.null2String(map.get(key));
  584. }
  585. /**
  586. * 订单退款申请单审核
  587. * @param request
  588. * @param result
  589. * @param apply_form_id
  590. * @param currentPage
  591. * @return
  592. */
  593. @RequestMapping({ "/refund_audit" })
  594. public Map<String, Object> refund_audit(HttpServletRequest request, @RequestBody JSONObject json) {
  595. UserDto user = SecurityUserHolder.getCurrentUser(request);
  596. Store store = null ;
  597. if(user == null){
  598. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  599. }
  600. if (user.getParent_id()!=null) {
  601. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  602. }
  603. store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  604. .getStore_id()));
  605. if(store == null){
  606. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  607. }
  608. RefundApplyFormDto refundApplyForm = this.refundapplyformfeignclient
  609. .selectByPrimaryKey(CommUtil.null2Long(json.optString("apply_from_id")));
  610. //TODO
  611. //Store store = (user.getParent() == null ? user : user.getParent()).getStore();
  612. if ((store != null) && (store.getId().toString().equals(refundApplyForm.getStore_id()))&&refundApplyForm.getOrder_form_id()!=null) {
  613. OrderFormDto orderForm = this.orderFormFeignClient.selectByPrimaryKey(refundApplyForm.getOrder_form_id());
  614. refundApplyForm.setAudit_date(new Date());
  615. refundApplyForm.setAudit_user_name(user.getUserName());
  616. if (StringUtils.isNotBlank(json.optString("result"))) {
  617. refundApplyForm.setStatus(10);
  618. this.refundapplyformfeignclient.updateById(refundApplyForm);
  619. orderForm.setOrder_status(22);
  620. this.orderFormFeignClient.updateById(orderForm);
  621. MessageDto msg = new MessageDto();
  622. String msg_content = "您订单号为:" + orderForm.getOrder_id() + "的订单退款申请已通过,我们会尽快将" + "退款金额打入您的预存款中。";
  623. msg.setAddTime(new Date());
  624. msg.setStatus(0);
  625. msg.setType(0);
  626. msg.setContent(msg_content);
  627. //msg.setFromu(user);
  628. //msg.setToUser(this.userFeignClient.selectByPrimaryKey(CommUtil.null2Long(orderForm.getUser_id())));
  629. msg.setFromUser_id(user.getId());
  630. msg.setToUser_id(CommUtil.null2Long(orderForm.getUser_id()));
  631. this.messagefeignclient.saveEntity(msg);
  632. } else {
  633. refundApplyForm.setStatus(5);
  634. this.refundapplyformfeignclient.updateById(refundApplyForm);
  635. orderForm.setOrder_status(20);
  636. this.orderFormFeignClient.updateById(orderForm);
  637. MessageDto msg = new MessageDto();
  638. String msg_content = "您订单号为:" + orderForm.getOrder_id() + "的订单退款申请未通过。";
  639. msg.setAddTime(new Date());
  640. msg.setStatus(0);
  641. msg.setType(0);
  642. msg.setContent(msg_content);
  643. msg.setFromUser(user);
  644. msg.setToUser_id(CommUtil.null2Long(orderForm.getUser_id()));
  645. this.messagefeignclient.saveEntity(msg);
  646. }
  647. }else {
  648. //店铺不存在, 或者登录用户不为该订单商铺
  649. return ResponseCode.buildReturnMap(ResponseCode.REQUEST_FORBIDDEN, null);
  650. }
  651. return ResponseCode.buildSuccessMap(null);
  652. }
  653. /**
  654. * 退货列表
  655. * @param request
  656. * @param response
  657. * @param currentPage
  658. * @param orderBy
  659. * @param orderType
  660. * @param name
  661. * @param user_name
  662. * @param return_service_id
  663. * @return
  664. */
  665. @RequestMapping(value = { "/return" } , method = RequestMethod.POST)
  666. public Map<String, Object> seller_return(HttpServletRequest request,@RequestBody JSONObject json) {
  667. String currentPage = json.optString("currentPage");
  668. String orderBy = json.optString("orderBy");
  669. String orderType = json.optString("orderType");
  670. String name = json.optString("name");
  671. String user_name = json.optString("user_name");
  672. String return_service_id = json.optString("return_service_id");
  673. Map<String,Object> maps= this.queryTools.getParams(currentPage, "addTime", "desc");
  674. maps.put("goods_type", 1);
  675. if ((user_name != null) && (!user_name.equals(""))) {
  676. maps.put("user_name", user_name);
  677. }
  678. if ((name != null) && (!name.equals(""))) {
  679. maps.put("goods_name_like", name);
  680. }
  681. if ((return_service_id != null) && (!return_service_id.equals(""))) {
  682. maps.put("return_service_id", return_service_id);
  683. }
  684. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  685. if(user == null){
  686. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  687. }
  688. if (user.getParent_id()!=null) {
  689. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  690. }
  691. //user = user.getParent_id() == null ? user : user.getParent();
  692. if(user.getStore_id() == null){
  693. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  694. }
  695. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  696. .getStore_id()));
  697. if(store != null){
  698. maps.put("store_id", store.getId());
  699. }else{
  700. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  701. }
  702. maps.put("store_id", user.getStore_id());
  703. Map<String , Object> data = this.returnGoodsLogFeignClient.list(maps);
  704. data.put("name", name);
  705. data.put("user_name", user_name);
  706. data.put("return_service_id", return_service_id);
  707. data.put("store", store);
  708. return ResponseCode.buildSuccessMap(data);
  709. }
  710. /**
  711. * 退货详情数据
  712. * @param request
  713. * @param response
  714. * @param currentPage
  715. * @param id
  716. * @return
  717. */
  718. @RequestMapping(value = { "/return_check" } , method = RequestMethod.POST)
  719. public Map<String, Object> return_check(HttpServletRequest request,
  720. @RequestBody JSONObject json) {
  721. String id = json.optString("id");
  722. ReturnGoodsLogDto obj = this.returnGoodsLogFeignClient.selectByPrimaryKey(CommUtil
  723. .null2Long(id));
  724. Map<String, Object> map = Maps.newHashMap();
  725. if (obj.getGoods_return_status().equals("7")) {
  726. TransInfoDto transInfo = this.shipToolsFeignClient.query_Ordership_getData(CommUtil.null2String(obj.getId()));
  727. map.put("transInfo", transInfo);
  728. Map<String, Object> mapa = JSON.parseObject(obj
  729. .getReturn_express_info());
  730. //物流名称
  731. map.put("express_company_name",mapa.get("express_company_name"));
  732. }
  733. map.put("obj", obj);
  734. return ResponseCode.buildSuccessMap(map);
  735. }
  736. /**
  737. * 退货订单 审核or拒绝
  738. * @param request
  739. * @param id
  740. * @param goods_return_status
  741. * @param self_address
  742. */
  743. @RequestMapping( value = { "/return_check_save" } , method = RequestMethod.POST)
  744. public Map<String , Object> return_check_saveEntity(HttpServletRequest request,@RequestBody JSONObject jsonv) {
  745. String id = jsonv.optString("id");
  746. /*String currentPage = jsonv.optString("currentPage");*/
  747. /*String cmd = jsonv.optString("cmd");*/
  748. // 退货商品状态 -2为超过退货时间未能输入退货物流 -1为申请被拒绝 1为可以退货 5为退货申请中 6为审核通过可进行退货 7为退货中 10为退货完成,等待退款,11为平台退款完成
  749. String goods_return_status = jsonv.optString("goods_return_status");
  750. // 收货时向买家发送的收货地址,买家通过此将货物发送给卖家
  751. String self_address = jsonv.optString("self_address");
  752. UserDto seller = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  753. // UserDto seller = this.userFeignClient.selectByPrimaryKey(445L);
  754. if(seller == null){
  755. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  756. }
  757. if (seller.getParent_id()!=null) {
  758. seller = this.userFeignClient.selectByPrimaryKey(seller.getParent_id());
  759. }
  760. //user = user.getParent_id() == null ? user : user.getParent();
  761. if(seller.getStore_id() == null){
  762. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  763. }
  764. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(seller
  765. .getStore_id()));
  766. // Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(62));
  767. if(store == null){
  768. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  769. }
  770. ReturnGoodsLogDto obj = this.returnGoodsLogFeignClient.selectByPrimaryKey(Long.valueOf(Long.parseLong(id)));
  771. String message = "审核为未通过";
  772. String code = "10001";
  773. if ((seller.getStore_id() != null)&& (CommUtil.null2String(obj.getStore_id()).equals(seller.getStore_id().toString()))) {
  774. obj.setGoods_return_status(goods_return_status);
  775. obj.setSelf_address(self_address);
  776. obj.setRefund_time(new Date()); //审核时间
  777. this.returnGoodsLogFeignClient.updateById(obj);
  778. UserDto user = this.userFeignClient.selectByPrimaryKey(obj.getUser_id());
  779. String msg_content =null;
  780. if (goods_return_status.equals("6")) {
  781. message = "审核通过";
  782. code = "10000";
  783. msg_content = "退货申请审核通过,请在'退货/退款'-'查看返修/退换记录'中提交退货物流信息。";
  784. } else {
  785. /* OrderFormDto of = this.orderFormFeignClient.selectByPrimaryKey(Long.valueOf(obj.getReturn_order_id()));
  786. of.setOrder_status(18); //申请未通过, 用户取消退款确认收货/人工仲裁
  787. this.orderFormFeignClient.updateById(of);*/
  788. message = "提交成功";
  789. code = "10000";
  790. msg_content = "订单号:" + obj.getReturn_service_id()
  791. + "退货申请审核未通过,请在'退货/退款'-'查看返修/退换记录'中提交退货物流信息。";
  792. }
  793. MessageDto msg = new MessageDto();
  794. msg.setAddTime(new Date());
  795. msg.setStatus(0);
  796. msg.setType(0);
  797. msg.setContent(msg_content);
  798. msg.setFromUser(SecurityUserHolder.getCurrentUser(request));
  799. msg.setToUser(user);
  800. this.messagefeignclient.saveEntity(msg);
  801. } else {
  802. message = "信息有误";
  803. code = "10001";
  804. }
  805. return ResponseCode.buildCodeMap(code,message, null);
  806. }
  807. /**
  808. * 确认退货收货
  809. * @param request
  810. * @param response
  811. * @param id
  812. * @return
  813. */
  814. @RequestMapping( value = { "/return_confirm" } , method = RequestMethod.POST)
  815. public Map<String , Object> return_confirm(HttpServletRequest request , @RequestBody JSONObject jsonv) {
  816. String id = jsonv.optString("id");
  817. UserDto seller = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  818. ReturnGoodsLogDto obj = this.returnGoodsLogFeignClient.selectByPrimaryKey(Long.valueOf(Long.parseLong(id)));
  819. if(seller == null){
  820. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  821. }
  822. if (seller.getParent_id()!=null) {
  823. seller = this.userFeignClient.selectByPrimaryKey(seller.getParent_id());
  824. }
  825. //user = user.getParent_id() == null ? user : user.getParent();
  826. if(seller.getStore_id() == null){
  827. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  828. }
  829. // Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(seller
  830. // .getStore_id()));
  831. Store store = this.storeService.selectByPrimaryKey(seller.getStore_id());
  832. if(store == null){
  833. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  834. }
  835. if ((seller.getStore_id() != null)&& (CommUtil.null2String(obj.getStore_id()).equals(seller.getStore_id().toString()))) {
  836. obj.setGoods_return_status("10");
  837. this.returnGoodsLogFeignClient.updateById(obj);
  838. }
  839. return ResponseCode.buildSuccessMap(null);
  840. }
  841. /**
  842. * 卖家调整订单费用
  843. * @param request
  844. * @param response
  845. * @param id
  846. * @param currentPage
  847. * @return
  848. */
  849. @RequestMapping(value = { "/order_fee" } , method = RequestMethod.POST)
  850. public Map<String , Object> order_fee(HttpServletRequest request,
  851. @RequestBody JSONObject json) {
  852. String id = json.optString("id");
  853. OrderFormDto obj = this.orderFormFeignClient
  854. .selectByPrimaryKey(CommUtil.null2Long(id));
  855. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  856. .getCurrentUser(request).getId());
  857. if(user == null){
  858. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  859. }
  860. if (user.getParent_id()!=null) {
  861. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  862. }
  863. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  864. .getStore_id()));
  865. if(store == null){
  866. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  867. }
  868. //user = user.getParent_id() == null ? user : user.getParent();
  869. if(user.getStore_id() == null){
  870. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  871. }
  872. if (user.getStore_id().equals(store.getId())) {
  873. return ResponseCode.buildSuccessMap(obj);
  874. } else {
  875. return ResponseCode.buildEnumMap(ResponseCode.FAILURE, null);
  876. }
  877. }
  878. /**
  879. * 卖家调整订单费用保存
  880. * @param request
  881. * @param response
  882. * @param id
  883. * @param currentPage
  884. * @param goods_amount
  885. * @param ship_price
  886. * @param totalPrice
  887. * @return
  888. * @throws Exception
  889. */
  890. @RequestMapping( value = { "/order_fee_save" } , method = RequestMethod.POST)
  891. public Map<String, Object> order_fee_saveEntity(HttpServletRequest request,@RequestBody JSONObject jsonv)
  892. {
  893. String id = jsonv.optString("id");
  894. String goods_amount = jsonv.optString("goods_amount"); //商品总价格
  895. String ship_price = jsonv.optString("ship_price"); // 配送价格
  896. String totalPrice = jsonv.optString("totalPrice"); // 订单总价格
  897. OrderFormDto obj = this.orderFormFeignClient
  898. .selectByPrimaryKey(CommUtil.null2Long(id));
  899. if (CommUtil.null2Double(obj.getCommission_amount()) <= CommUtil
  900. .null2Double(goods_amount)) {
  901. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  902. .getCurrentUser(request).getId());
  903. if(user == null){
  904. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  905. }
  906. if (user.getParent_id()!=null) {
  907. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  908. }
  909. if(user.getStore_id() == null){
  910. return ResponseCode.buildReturnMap(ResponseCode.FAILURE,null);
  911. }
  912. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  913. .getStore_id()));
  914. if(store == null){
  915. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE,null);
  916. }
  917. //user = user.getParent_id() == null ? user : user.getParent();
  918. if (user.getStore_id().toString().equals(store.getId().toString())) {
  919. obj.setGoods_amount(BigDecimal.valueOf(CommUtil
  920. .null2Double(goods_amount)));
  921. obj.setShip_price(BigDecimal.valueOf(CommUtil
  922. .null2Double(ship_price)));
  923. obj.setTotalPrice(BigDecimal.valueOf(CommUtil
  924. .null2Double(totalPrice)));
  925. obj.setOperation_price_count(obj.getOperation_price_count() + 1);
  926. this.orderFormFeignClient.updateById(obj);
  927. OrderFormLogDto ofl = new OrderFormLogDto();
  928. ofl.setAddTime(new Date());
  929. ofl.setLog_info("调整订单费用");
  930. ofl.setState_info("调整订单总金额为:" + totalPrice + ",调整运费金额为:"
  931. + ship_price);
  932. ofl.setLog_user_id(SecurityUserHolder.getCurrentUser(request).getId());
  933. ofl.setLog_user_name(SecurityUserHolder.getCurrentUser(request)
  934. .getUserName());
  935. ofl.setOf_id(obj.getId());
  936. this.orderFormLogFeignClient.saveEntity(ofl);
  937. /* UserDto buyer = this.userFeignClient.selectByPrimaryKey(CommUtil.null2Long(obj
  938. .getUser_id()));
  939. Map<String, Object> map = Maps.newHashMap();
  940. map.put("buyer_id", buyer.getId().toString());
  941. map.put("seller_id", store.getUser_id());
  942. map.put("order_id", obj.getId());
  943. String json = JSON.toJSONString(map);
  944. if (obj.getOrder_form() == 0) {
  945. this.msgToolsFeignClient.sendEmailCharge(CommUtil.getURL(request),
  946. "email_tobuyer_order_update_fee_notify",
  947. buyer.getEmail(), json, null, obj.getStore_id());
  948. this.msgToolsFeignClient.sendSmsCharge(CommUtil.getURL(request),
  949. "sms_tobuyer_order_fee_notify", buyer.getMobile(),
  950. json, null, obj.getStore_id());
  951. } else {
  952. this.msgToolsFeignClient.sendEmailFree(CommUtil.getURL(request),
  953. "email_tobuyer_order_update_fee_notify",
  954. buyer.getEmail(), json, null);
  955. this.msgToolsFeignClient.sendSmsFree(CommUtil.getURL(request),
  956. "sms_tobuyer_order_fee_notify", buyer.getMobile(),
  957. json, null);
  958. }*/
  959. }else{
  960. return ResponseCode.buildReturnMap(ResponseCode.FAILURE,null);
  961. }
  962. }else{
  963. return ResponseCode.buildReturnMap(ResponseCode.FAILURE,null);
  964. }
  965. return ResponseCode.buildSuccessMap(null);
  966. }
  967. /**
  968. * 卖家发货
  969. * @param request
  970. * @param response
  971. * @param id
  972. * @param currentPage
  973. * @param page_status
  974. * @return
  975. */
  976. @RequestMapping(value = { "/order_shipping" } , method = RequestMethod.POST)
  977. public Map<String, Object> order_shipping(HttpServletRequest request,@RequestBody JSONObject json) {
  978. String id = json.optString("id");
  979. String page_status = json.optString("page_status");
  980. OrderFormDto obj = this.orderFormFeignClient
  981. .selectByPrimaryKey(CommUtil.null2Long(id));
  982. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  983. .getCurrentUser(request).getId());
  984. if(user == null){
  985. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  986. }
  987. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  988. .getStore_id()));
  989. if (user.getParent_id()!=null) {
  990. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  991. }
  992. Store store1 = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  993. .getStore_id()));
  994. if(store1 == null ||store == null){
  995. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  996. }
  997. //user = user.getParent_id() == null ? user : user.getParent();
  998. if(user.getStore_id() == null){
  999. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1000. }
  1001. Map<String, Object> map = Maps.newHashMap();
  1002. if (user.getStore_id().equals(store.getId())) {
  1003. map.put("obj", obj);
  1004. List<GoodsDto> list_goods = queryOfGoods(obj);
  1005. List<GoodsDto> deliveryGoods = Lists.newArrayList();
  1006. boolean physicalGoods = false;
  1007. for (GoodsDto g : list_goods) {
  1008. if (g.getGoods_choice_type() == 1) {
  1009. deliveryGoods.add(g);
  1010. } else {
  1011. physicalGoods = true;
  1012. }
  1013. }
  1014. Map<String, Object> params = Maps.newHashMap();
  1015. params.put("ecc_type", Integer.valueOf(0));
  1016. params.put("ecc_store_id", store.getId());
  1017. List<ExpressCompanyCommonDto> eccs = this.companyCommonFeignClient.queryPages(params);
  1018. params.clear();
  1019. params.put("sa_type", Integer.valueOf(0));
  1020. params.put("sa_user_id", user.getId());
  1021. params.put("orderBy", "obj.sa_default desc,obj.sa_sequence");
  1022. params.put("orderType", "asc");
  1023. List<ShipAddressDto> shipAddrs = this.shipAddressFeignClient.queryPages(params);
  1024. map.put("eccs", eccs);
  1025. map.put("shipAddrs", shipAddrs);
  1026. map.put("physicalGoods", Boolean.valueOf(physicalGoods));
  1027. map.put("deliveryGoods", deliveryGoods);
  1028. map.put("page_status", page_status);
  1029. //用改方法查询虚拟商品的数量
  1030. /*map.put("queryOfGoodsCount", this.queryOfGoodsCount);*/
  1031. } else {
  1032. return ResponseCode.buildEnumMap(ResponseCode.PARAM_ERROR, null);
  1033. }
  1034. return ResponseCode.buildSuccessMap(map);
  1035. }
  1036. /**
  1037. * 根据订单id和商品id查询该商品在该订单中的数量
  1038. * @param order_id
  1039. * @param goods_id
  1040. * @return
  1041. */
  1042. public int queryOfGoodsCount(String order_id, String goods_id) {
  1043. int count = 0;
  1044. OrderFormDto of = this.orderFormFeignClient.selectByPrimaryKey(CommUtil
  1045. .null2Long(order_id));
  1046. List<Map> map_list = this.orderFormToolsFeignClient.queryGoodsInfo(of.getGoods_info());
  1047. for (Map map : map_list) {
  1048. if (CommUtil.null2String(map.get("goods_id")).equals(goods_id)) {
  1049. count = CommUtil.null2Int(map.get("goods_count"));
  1050. break;
  1051. }
  1052. }
  1053. if ((count == 0)
  1054. && (!CommUtil.null2String(of.getChild_order_detail())
  1055. .equals(""))) { // 主订单无数量信息,继续从子订单中查询
  1056. List<Map> maps = this.orderFormToolsFeignClient.queryGoodsInfo(of.getChild_order_detail());
  1057. for (Map map : maps) {
  1058. OrderFormDto child_order = this.orderFormFeignClient
  1059. .selectByPrimaryKey(CommUtil.null2Long(map
  1060. .get("order_id")));
  1061. map_list.clear();
  1062. map_list = this.orderFormToolsFeignClient.queryGoodsInfo(child_order.getGoods_info());
  1063. for (Map map1 : map_list) {
  1064. if (CommUtil.null2String(map1.get("goods_id")).equals(
  1065. goods_id)) {
  1066. count = CommUtil.null2Int(map1.get("goods_count"));
  1067. break;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. return count;
  1073. }
  1074. /**
  1075. * 根据订单id查询该订单中所有商品,包括子订单中的商品
  1076. * @param main_order
  1077. * @return
  1078. */
  1079. public List<GoodsDto> queryOfGoods(OrderFormDto main_order) {
  1080. List<Map> map_list =this.orderFormToolsFeignClient.queryGoodsInfo(main_order.getGoods_info());
  1081. List<GoodsDto> goods_list = Lists.newArrayList();
  1082. for (Map map : map_list) {
  1083. GoodsDto goods = this.goodsFeignClient.selectByPrimaryKey(CommUtil
  1084. .null2Long(map.get("goods_id")));
  1085. if(goods != null){
  1086. goods_list.add(goods);
  1087. }
  1088. }
  1089. if (!CommUtil.null2String(main_order.getChild_order_detail())
  1090. .equals("")) {
  1091. List<Map> maps = this.orderFormToolsFeignClient.queryGoodsInfo(main_order.getChild_order_detail());
  1092. for (Map<String, Object> map : maps) {
  1093. OrderFormDto child_order = this.orderFormFeignClient
  1094. .selectByPrimaryKey(CommUtil.null2Long(map
  1095. .get("order_id")));
  1096. map_list.clear();
  1097. map_list =this.orderFormToolsFeignClient.queryGoodsInfo(child_order.getGoods_info());
  1098. for (Map map1 : map_list) {
  1099. GoodsDto good = this.goodsFeignClient.selectByPrimaryKey(CommUtil
  1100. .null2Long(map1.get("goods_id")));
  1101. goods_list.add(good);
  1102. }
  1103. }
  1104. }
  1105. return goods_list;
  1106. }
  1107. /**
  1108. * 卖家修改物流
  1109. * @param request
  1110. * @param response
  1111. * @param id
  1112. * @param currentPage
  1113. * @return
  1114. */
  1115. @RequestMapping(value = { "/order_shipping_code" } , method = RequestMethod.POST)
  1116. public Map<String , Object> order_shipping_code(HttpServletRequest request,@RequestBody JSONObject json) {
  1117. String id = json.optString("id");
  1118. OrderFormDto obj = this.orderFormFeignClient
  1119. .selectByPrimaryKey(CommUtil.null2Long(id));
  1120. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1121. .getCurrentUser(request).getId());
  1122. if(user == null){
  1123. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1124. }
  1125. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  1126. .getStore_id()));
  1127. if (user.getParent_id()!=null) {
  1128. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1129. }
  1130. //user = user.getParent_id() == null ? user : user.getParent();
  1131. if(user.getStore_id() == null){
  1132. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1133. }
  1134. Store store1 = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1135. .getStore_id()));
  1136. if(store1 == null || store == null){
  1137. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1138. }
  1139. if (user.getStore_id().equals(store.getId())) {
  1140. return ResponseCode.buildSuccessMap(obj);
  1141. } else {
  1142. return ResponseCode.buildEnumMap(ResponseCode.FAILURE, null);
  1143. }
  1144. }
  1145. /**
  1146. * 卖家修改物流保存
  1147. * @param request
  1148. * @param response
  1149. * @param id
  1150. * @param currentPage
  1151. * @param shipCode
  1152. * @param state_info
  1153. * @return
  1154. */
  1155. @RequestMapping(value = { "/order_shipping_code_save" } , method = RequestMethod.POST)
  1156. public Map<String , Object> order_shipping_code_saveEntity(HttpServletRequest request,@RequestBody JSONObject json) {
  1157. String id = json.optString("id");
  1158. String shipCode = json.optString("shipCode");
  1159. String state_info = json.optString("state_info");
  1160. OrderFormDto obj = this.orderFormFeignClient
  1161. .selectByPrimaryKey(CommUtil.null2Long(id));
  1162. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1163. .getCurrentUser(request).getId());
  1164. if(user == null){
  1165. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1166. }
  1167. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  1168. .getStore_id()));
  1169. if (user.getParent_id()!=null) {
  1170. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1171. }
  1172. Store store1 = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1173. .getStore_id()));
  1174. if(store1 == null || store == null){
  1175. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1176. }
  1177. //user = user.getParent_id() == null ? user : user.getParent();
  1178. if(user.getStore_id() == null){
  1179. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1180. }
  1181. Map<String, Object> map = Maps.newHashMap();
  1182. if (user.getStore_id().equals(store.getId())) {
  1183. obj.setShipCode(shipCode);
  1184. this.orderFormFeignClient.updateById(obj);
  1185. OrderFormLogDto ofl = new OrderFormLogDto();
  1186. ofl.setAddTime(new Date());
  1187. ofl.setLog_info("修改物流信息");
  1188. ofl.setState_info(state_info);
  1189. ofl.setLog_user_id(SecurityUserHolder.getCurrentUser(request).getId());
  1190. ofl.setLog_user_name(SecurityUserHolder.getCurrentUser(request)
  1191. .getUserName());
  1192. ofl.setOf(obj);
  1193. this.orderFormLogFeignClient.saveEntity(ofl);
  1194. if (this.sysConfigFeignClient.getSysConfig().getKuaidi_type() == 1) {
  1195. JSONObject info = new JSONObject();
  1196. Map express_map = JSON.parseObject(obj.getExpress_info());
  1197. info.put("company", CommUtil.null2String(express_map
  1198. .get("express_company_mark")));
  1199. info.put("number", obj.getShipCode());
  1200. info.put("from", CommUtil.null2String(obj.getShip_addr()));
  1201. info.put("to", obj.getReceiver_area());
  1202. info.put("key", this.sysConfigFeignClient.getSysConfig()
  1203. .getKuaidi_id2());
  1204. JSONObject param_info = new JSONObject();
  1205. param_info.put("callbackurl", CommUtil.getURL(request)
  1206. + "/kuaidi_callback?order_id=" + obj.getId()
  1207. + "&orderType=0");
  1208. param_info.put("salt",
  1209. Md5Encrypt.md5(CommUtil.null2String(obj.getId()))
  1210. .substring(0, 16));
  1211. info.put("parameters", param_info);
  1212. try {
  1213. String result = Post(
  1214. "http://highapi.kuaidi.com/openapi-receive.html",
  1215. info.toString());
  1216. Map remap = JSON.parseObject(result);
  1217. if ("success".equals(CommUtil.null2String(remap
  1218. .get("message")))) {
  1219. ExpressInfoDto ei = new ExpressInfoDto();
  1220. ei.setAddTime(new Date());
  1221. ei.setOrder_id(obj.getId());
  1222. ei.setOrder_express_id(obj.getShipCode());
  1223. ei.setOrder_type(0);
  1224. Map ec_map = JSON.parseObject(CommUtil.null2String(obj
  1225. .getExpress_info()));
  1226. if (ec_map != null) {
  1227. ei.setOrder_express_name(CommUtil
  1228. .null2String(ec_map
  1229. .get("express_company_name")));
  1230. }
  1231. this.expressInfoFeignClient.saveEntity(ei);
  1232. System.out.println("订阅成功");
  1233. } else {
  1234. System.out.println("订阅失败");
  1235. }
  1236. } catch (JSONException e) {
  1237. e.printStackTrace();
  1238. }
  1239. }
  1240. }
  1241. return ResponseCode.buildSuccessMap(null);
  1242. }
  1243. /**
  1244. * 快递Post请求
  1245. * @param url
  1246. * @param param
  1247. * @return
  1248. */
  1249. @SuppressWarnings("resource")
  1250. public static String Post(String url, String param) {
  1251. try {
  1252. DefaultHttpClient httpClient = new DefaultHttpClient();
  1253. HttpPost method = new HttpPost(url);
  1254. StringEntity entity = new StringEntity(param, "utf-8");// 解决中文乱码问题
  1255. entity.setContentEncoding("UTF-8");
  1256. entity.setContentType("application/json");
  1257. method.setEntity(entity);
  1258. HttpResponse result = httpClient.execute(method);
  1259. // 请求结束,返回结果
  1260. return EntityUtils.toString(result.getEntity());
  1261. } catch (Exception e) {
  1262. e.printStackTrace();
  1263. throw new RuntimeException(e.getMessage());
  1264. }
  1265. }
  1266. /**
  1267. * 卖家物流详情
  1268. * @param request
  1269. * @param response
  1270. * @param id
  1271. * @return
  1272. */
  1273. @RequestMapping( value = { "/ship_view" } , method = RequestMethod.POST)
  1274. public Map<String , Object> order_ship_view(HttpServletRequest request,@RequestBody JSONObject json) {
  1275. String id = json.optString("id");
  1276. OrderFormDto obj = this.orderFormFeignClient
  1277. .selectByPrimaryKey(CommUtil.null2Long(id));
  1278. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1279. .getCurrentUser(request).getId());
  1280. if(user == null){
  1281. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1282. }
  1283. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  1284. .getStore_id()));
  1285. if (user.getParent_id()!=null) {
  1286. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1287. }
  1288. Store store1 = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1289. .getStore_id()));
  1290. if(store1 == null || store == null){
  1291. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1292. }
  1293. //user = user.getParent_id() == null ? user : user.getParent();
  1294. if(user.getStore_id() == null){
  1295. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1296. }
  1297. Map<String, Object> map = Maps.newHashMap();
  1298. if (user.getStore_id().equals(store.getId())) {
  1299. map.put("obj", obj);
  1300. TransInfoDto transInfo = this.shipToolsFeignClient
  1301. .query_Ordership_getData(CommUtil.null2String(obj.getId()));
  1302. map.put("transInfo", transInfo);
  1303. return ResponseCode.buildSuccessMap(map);
  1304. } else {
  1305. return ResponseCode.buildEnumMap(ResponseCode.FAILURE, null);
  1306. }
  1307. }
  1308. /**
  1309. * 商品评价列表
  1310. * @param request
  1311. * @param response
  1312. * @param currentPage
  1313. * @param orderBy
  1314. * @param orderType
  1315. * @param status
  1316. * @return
  1317. */
  1318. @RequestMapping({ "/evaluate_list" })
  1319. public Map<String , Object> evaluate_list(HttpServletRequest request,@RequestBody JSONObject json) {
  1320. String currentPage = json.getString("currentPage");
  1321. String orderBy = json.getString("orderBy");
  1322. String orderType = json.getString("orderType");
  1323. String status = json.getString("status");
  1324. String evaluate_buyer_val = json.getString("evaluate_buyer_val");
  1325. Map<String,Object> maps= this.queryTools.getParams(currentPage, orderBy, orderType);
  1326. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  1327. if(user == null){
  1328. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1329. }
  1330. if (user.getParent_id()!=null) {
  1331. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1332. }
  1333. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1334. .getStore_id()));
  1335. if(store == null){
  1336. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1337. }
  1338. maps.put("evaluate_goods_goods_store_id", store.getId());
  1339. maps.put("evaluate_status", 0);
  1340. maps.put("evaluate_type", "goods");
  1341. if ("yes".equals(status)) {
  1342. maps.put("reply_status", 1);
  1343. maps.put("status", status);
  1344. }
  1345. if ("no".equals(status)) {
  1346. maps.put("reply_status", 0);
  1347. maps.put("status", status);
  1348. }
  1349. //买家评价,评价类型,1为好评,0为中评,-1为差评
  1350. if(StringUtils.isNotBlank(evaluate_buyer_val)){
  1351. maps.put("evaluate_buyer_val", evaluate_buyer_val);
  1352. }
  1353. Map<String, Object> map = this.evaluateFeignClient.list(maps);
  1354. map.put("status", status);
  1355. return ResponseCode.buildSuccessMap(map);
  1356. }
  1357. /**
  1358. * 商品评价内容查看
  1359. * @param request
  1360. * @param response
  1361. * @param id
  1362. * @return
  1363. */
  1364. @RequestMapping( value = { "/evaluate_info" } ,method = RequestMethod.POST)
  1365. public Map<String , Object> evaluate_info(HttpServletRequest request,@RequestBody JSONObject json) {
  1366. String id = json.optString("id");
  1367. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1368. .getCurrentUser(request).getId());
  1369. if(user == null){
  1370. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1371. }
  1372. if (user.getParent_id()!=null) {
  1373. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1374. }
  1375. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1376. .getStore_id()));
  1377. if(store == null){
  1378. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1379. }
  1380. EvaluateDto evl = this.evaluateFeignClient.selectByPrimaryKey(CommUtil.null2Long(id));
  1381. //TODO
  1382. if (evl != null){
  1383. OrderFormDto of = this.orderFormFeignClient.selectByPrimaryKey(evl.getOf_id());
  1384. UserDto euser = userFeignClient.selectByPrimaryKey(evl.getEvaluate_user_id());
  1385. if((of.getStore_id().equals(user.getStore_id()+""))) {
  1386. /*mv.addObject("evl", evl);*/
  1387. /*mv.addObject("imageTools", this.imageTools);*/
  1388. Map<String , Object> maps = Maps.newHashMap();
  1389. maps.put("evl", evl);
  1390. maps.put("euser", euser);
  1391. return ResponseCode.buildSuccessMap(maps);
  1392. } else {
  1393. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1394. }
  1395. }else{
  1396. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1397. }
  1398. }
  1399. /**
  1400. * 商品评价内容回复
  1401. * @param request
  1402. * @param response
  1403. * @param id
  1404. * @param reply
  1405. */
  1406. @RequestMapping( value = { "/evaluate_reply_save" } , method = RequestMethod.POST)
  1407. public Map<String, Object> evaluate_reply_saveEntity(HttpServletRequest request,@RequestBody JSONObject json) {
  1408. String id = json.optString("id");
  1409. String reply = json.optString("reply");
  1410. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  1411. if(user == null){
  1412. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1413. }
  1414. if (user.getParent_id()!=null) {
  1415. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1416. }
  1417. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1418. .getStore_id()));
  1419. if(store == null){
  1420. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1421. }
  1422. EvaluateDto evl = this.evaluateFeignClient.selectByPrimaryKey(CommUtil.null2Long(id));
  1423. if (evl != null){
  1424. OrderFormDto of = this.orderFormFeignClient.selectByPrimaryKey(evl.getOf_id());
  1425. if((of.getStore_id().equals(user.getStore_id()+""))) {
  1426. /*mv.addObject("evl", evl);*/
  1427. /*mv.addObject("imageTools", this.imageTools);*/
  1428. evl.setReply(reply);
  1429. evl.setReply_status(1);
  1430. this.evaluateFeignClient.updateById(evl);
  1431. return ResponseCode.buildSuccessMap(evl);
  1432. } else {
  1433. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1434. }
  1435. }else{
  1436. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1437. }
  1438. }
  1439. /**
  1440. * 常用快递公司
  1441. * @param request
  1442. * @param response
  1443. * @param currentPage
  1444. * @param orderBy
  1445. * @param orderType
  1446. * @return
  1447. */
  1448. @RequestMapping(value = { "/ecc_set" } ,method = RequestMethod.POST)
  1449. public Map<String , Object> ecc_set(HttpServletRequest request) {
  1450. Map<String, Object> params = Maps.newHashMap();
  1451. /*List<ExpressCompanyDto> ecs = this.expressCompanyFeignClient.queryPageList(params);*/
  1452. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1453. .getCurrentUser(request).getId());
  1454. if(user == null){
  1455. return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE, null);
  1456. }
  1457. if (user.getParent_id()!=null) {
  1458. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1459. }
  1460. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1461. .getStore_id()));
  1462. if(store == null){
  1463. return ResponseCode.buildEnumMap(ResponseCode.NOTSTORE, null);
  1464. }
  1465. List<ExpressCompanyCommonDto> eccs = Lists.newArrayList();
  1466. if ((store != null) && (user.getUserRole().indexOf("SELLER") >= 0)) {
  1467. params.put("ecc_type", Integer.valueOf(0));
  1468. params.put("ecc_store_id", store.getId());
  1469. eccs = this.expressCompanyCommonFeignClient.queryPages(params);
  1470. }
  1471. /*mv.addObject("ecs", ecs);
  1472. mv.addObject("transportTools", this.transportTools);*/
  1473. return ResponseCode.buildSuccessMap(eccs);
  1474. }
  1475. // public int query_common_ec(HttpServletRequest request,String id) {
  1476. // int ret = 0;
  1477. // if (!CommUtil.null2String(id).equals("")) {
  1478. // Map<String, Object> params = Maps.newHashMap();
  1479. // UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1480. // .getCurrentUser(request).getId());
  1481. // if(user == null){
  1482. // return ret;
  1483. // }
  1484. // if (user.getParent_id()!=null) {
  1485. // user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1486. // }
  1487. // Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1488. // .getStore_id()));
  1489. // if(store == null){
  1490. // return ret;
  1491. // }
  1492. // List<ExpressCompanyCommonDto> eccs = Lists.newArrayList();
  1493. // if ((store != null) && (user.getUserRole().indexOf("SELLER") >= 0)) {
  1494. // params.put("ecc_type", Integer.valueOf(0));
  1495. // params.put("ecc_store_id", store.getId());
  1496. // eccs = this.expressCompanyCommon.queryPageList(params);
  1497. //
  1498. // for (ExpressCompanyCommonDto ecc : eccs) {
  1499. // if (ecc.getEcc_ec_id().equals(CommUtil.null2Long(id))) {
  1500. // ret = 1;
  1501. // }
  1502. // }
  1503. // } else {
  1504. // params.put("ecc_type", Integer.valueOf(1));
  1505. // eccs = this.expressCompanyCommon.queryPageList(params);
  1506. //
  1507. // for (ExpressCompanyCommonDto ecc : eccs) {
  1508. // if (ecc.getEcc_ec_id().equals(CommUtil.null2Long(id))) {
  1509. // ret = 1;
  1510. // }
  1511. // }
  1512. // }
  1513. // }
  1514. // return ret;
  1515. // }
  1516. /**
  1517. * 常用快递公司删除
  1518. * @param request
  1519. * @param response
  1520. * @param id
  1521. * @param currentPage
  1522. * @return
  1523. */
  1524. @RequestMapping(value = { "/ecc_delete" } , method = RequestMethod.POST)
  1525. public Map<String, Object> ecc_deleteById(HttpServletRequest request,@RequestBody JSONObject json) {
  1526. String id = json.optString("id");
  1527. ExpressCompanyCommonDto ecc = this.expressCompanyCommonFeignClient
  1528. .selectByPrimaryKey(CommUtil.null2Long(id));
  1529. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1530. .getCurrentUser(request).getId());
  1531. if(user == null){
  1532. return ResponseCode.buildReturnMap(ResponseCode.TOKEN_EXPIRE, null);
  1533. }
  1534. if (user.getParent_id()!=null) {
  1535. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1536. }
  1537. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1538. .getStore_id()));
  1539. if(store == null){
  1540. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1541. }
  1542. if (ecc.getEcc_store_id().equals(store.getId())) {
  1543. this.expressCompanyCommonFeignClient.deleteById(CommUtil.null2Long(id));
  1544. return ResponseCode.buildSuccessMap(null);
  1545. }else{
  1546. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1547. }
  1548. }
  1549. /**
  1550. * 所有未选择的常用快递公司
  1551. * @param request
  1552. * @param response
  1553. * @param id
  1554. * @param currentPage
  1555. * @return
  1556. */
  1557. @RequestMapping(value = { "/ecc_saveEntityView" } , method = RequestMethod.POST)
  1558. public Map<String, Object> ecc_saveEntityView(HttpServletRequest request,@RequestBody JSONObject json) {
  1559. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1560. .getCurrentUser(request).getId());
  1561. if(user == null){
  1562. return ResponseCode.buildEnumMap( ResponseCode.TOKEN_EXPIRE, null);
  1563. }
  1564. if (user.getParent_id()!=null) {
  1565. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1566. }
  1567. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1568. .getStore_id()));
  1569. if(store == null){
  1570. return ResponseCode.buildEnumMap(ResponseCode.NOTSTORE,null);
  1571. }
  1572. Map<String, Object> params = Maps.newHashMap();
  1573. params.put("company_status", Integer.valueOf(0));
  1574. params.put("orderBy", "company_sequence");
  1575. params.put("orderType", "asc");
  1576. List<ExpressCompanyDto> excs = this.expressCompanyFeignClient.queryPages(params);
  1577. List<ExpressCompanyCommonDto> eccs = Lists.newArrayList();
  1578. List<ExpressCompanyDto> execs = Lists.newArrayList();
  1579. if ((store != null) && (user.getUserRole().indexOf("SELLER") >= 0)) {
  1580. params.clear();
  1581. params.put("ecc_type", Integer.valueOf(0));
  1582. params.put("ecc_store_id", store.getId());
  1583. eccs = this.expressCompanyCommonFeignClient.queryPages(params);
  1584. for (ExpressCompanyDto exc : excs) {
  1585. int i= 0;
  1586. for (ExpressCompanyCommonDto ecc : eccs) {
  1587. if (ecc.getEcc_ec_id().equals(CommUtil.null2Long(exc.getId()))) {
  1588. i=1;
  1589. break;
  1590. }
  1591. }
  1592. if(i == 0){
  1593. execs.add(exc);
  1594. }
  1595. }
  1596. }
  1597. return ResponseCode.buildSuccessMap(execs);
  1598. }
  1599. /**
  1600. * 常用快递公司添加
  1601. * @param request
  1602. * @param response
  1603. * @param id
  1604. * @param currentPage
  1605. * @return
  1606. */
  1607. @RequestMapping(value = { "/ecc_saveEntity" } , method = RequestMethod.POST)
  1608. public Map<String, Object> ecc_saveEntity(HttpServletRequest request,@RequestBody JSONObject json) {
  1609. String ids = json.optString("ids");
  1610. String[] ec_ids= null;
  1611. if(ids != null){
  1612. ec_ids = ids.split(",");
  1613. }
  1614. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1615. .getCurrentUser(request).getId());
  1616. if(user == null){
  1617. return ResponseCode.buildReturnMap(ResponseCode.TOKEN_EXPIRE, null);
  1618. }
  1619. if (user.getParent_id()!=null) {
  1620. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1621. }
  1622. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1623. .getStore_id()));
  1624. if(store == null){
  1625. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1626. }
  1627. for (String ec_id : ec_ids) {
  1628. if (!CommUtil.null2String(ec_id).equals("")) {
  1629. ExpressCompanyDto ec = this.expressCompanyFeignClient.selectByPrimaryKey(CommUtil.null2Long(ec_id));
  1630. ExpressCompanyCommonDto ecc = new ExpressCompanyCommonDto();
  1631. ecc.setAddTime(new Date());
  1632. ecc.setEcc_code(ec.getCompany_mark());
  1633. ecc.setEcc_ec_id(ec.getId());
  1634. ecc.setEcc_name(ec.getCompany_name());
  1635. ecc.setEcc_store_id(store.getId());
  1636. ecc.setEcc_template(ec.getCompany_template());
  1637. ecc.setEcc_template_heigh(ec.getCompany_template_heigh());
  1638. ecc.setEcc_template_width(ec.getCompany_template_width());
  1639. ecc.setEcc_template_offset(ec.getCompany_template_offset());
  1640. ecc.setEcc_type(0);
  1641. ecc.setEcc_ec_type(ec.getCompany_type());
  1642. this.expressCompanyCommonFeignClient.saveEntity(ecc);
  1643. }
  1644. }
  1645. return ResponseCode.buildSuccessMap(null);
  1646. }
  1647. /**
  1648. * 发货地址列表
  1649. * @param request
  1650. * @param response
  1651. * @param currentPage
  1652. * @param orderBy
  1653. * @param orderType
  1654. * @return
  1655. */
  1656. @RequestMapping(value = { "/ship_address" } ,method = RequestMethod.POST)
  1657. public Map<String,Object> ship_address(HttpServletRequest request,@RequestBody JSONObject json) {
  1658. String currentPage = json.optString("currentPage");
  1659. String orderBy = json.optString("orderBy");
  1660. String orderType = json.optString("orderType");
  1661. Map<String,Object> maps= this.queryTools.getParams(currentPage, orderBy, orderType);
  1662. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder.getCurrentUser(request).getId());
  1663. List<Long> sa_user_ids = Lists.newArrayList();
  1664. sa_user_ids.add(user.getId());
  1665. if(user!=null && user.getParent_id()!=null){
  1666. UserDto userParent = this.userFeignClient.selectByPrimaryKey(user.getParent().getId());
  1667. sa_user_ids.add(userParent.getId());
  1668. List<UserDto> childs = userParent.getChilds();
  1669. for (UserDto uc : childs) {
  1670. sa_user_ids.add(uc.getId());
  1671. }
  1672. }
  1673. if(user!=null && user.getChilds()!=null && user.getChilds().size()>0){
  1674. List<UserDto> childs = user.getChilds();
  1675. for (UserDto uc : childs) {
  1676. sa_user_ids.add(uc.getId());
  1677. }
  1678. }
  1679. maps.put("sa_type", 0);
  1680. maps.put("sa_user_ids", sa_user_ids);
  1681. Map<String, Object> data = this.shipAddressFeignClient.list(maps);
  1682. HashMap<Object, Object> result = new HashMap<>();
  1683. result.put("data", data);
  1684. Store store = storeService.selectByPrimaryKey(user.getStore_id());
  1685. if (store!=null) {
  1686. List<Map> ms_list = Lists.newArrayList();
  1687. if (store.getStore_service_info() != null) {
  1688. ms_list = JSON.parseArray(store.getStore_service_info(),Map.class);
  1689. }
  1690. result.put("ms_list", ms_list);
  1691. if (store.getMc_id()!=null&&store.getMc_id()==22) {
  1692. result.put("scenic", 1); //为景点商品
  1693. }else{
  1694. result.put("scenic", 0); //普通商品
  1695. }
  1696. }
  1697. return ResponseCode.buildSuccessMap(result);
  1698. }
  1699. /**
  1700. * 新增发货地址的地区
  1701. * @param request
  1702. * @param response
  1703. * @param currentPage
  1704. * @return
  1705. */
  1706. @RequestMapping(value = { "/ship_address_add" } , method = RequestMethod.POST)
  1707. public Map<String , Object> ship_address_add(HttpServletRequest request, @RequestBody JSONObject json) {
  1708. String parent_id = json.optString("parent_id");
  1709. Map<String, Object> maps = Maps.newHashMap();
  1710. if(StringUtils.isNotBlank(parent_id)){
  1711. maps.put("parent_id", parent_id);
  1712. }else{
  1713. maps.put("parent_id", -1);
  1714. }
  1715. /*List<AreaDto> areas = this.areaFeignClient.queryPageList(maps);*/
  1716. List<AreaDto> areas = this.areaFeignClient.queryPages(maps);
  1717. return ResponseCode.buildSuccessMap(areas);
  1718. }
  1719. /**
  1720. * 编辑发货地址
  1721. * @param request
  1722. * @param response
  1723. * @param id
  1724. * @param currentPage
  1725. * @return
  1726. */
  1727. @RequestMapping(value = { "/ship_address_edit" } , method = RequestMethod.POST)
  1728. public Map<String , Object> ship_address_edit(HttpServletRequest request,@RequestBody JSONObject json) {
  1729. String id = json.optString("id");
  1730. ShipAddressDto obj = this.shipAddressFeignClient.selectByPrimaryKey(CommUtil
  1731. .null2Long(id));
  1732. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1733. .getCurrentUser(request).getId());
  1734. if(user == null){
  1735. return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE,null);
  1736. }
  1737. if (user.getParent_id()!=null) {
  1738. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1739. }
  1740. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1741. .getStore_id()));
  1742. if(store == null){
  1743. return ResponseCode.buildEnumMap(ResponseCode.NOTSTORE,null);
  1744. }
  1745. if ((obj != null) && (obj.getSa_user_id().equals(user.getId()))) {
  1746. Map<String, Object> maps = Maps.newHashMap();
  1747. AreaDto sa_area = this.areaFeignClient.selectByPrimaryKeyFullParent(obj.getSa_area_id());
  1748. obj.setSa_area_name(sa_area.getParent().getParent().getAreaName()+sa_area.getParent().getAreaName()+sa_area.getAreaName());
  1749. maps.put("obj", obj);
  1750. return ResponseCode.buildSuccessMap(maps);
  1751. } else {
  1752. return ResponseCode.buildEnumMap(ResponseCode.PARAM_ERROR, null);
  1753. }
  1754. }
  1755. /**
  1756. * 保存发货地址
  1757. * @param request
  1758. * @param response
  1759. * @param id
  1760. * @param currentPage
  1761. */
  1762. @RequestMapping( value = { "/ship_address_save" } ,method = RequestMethod.POST)
  1763. public Map<String , Object> ship_address_saveEntity(HttpServletRequest request,@RequestBody ShipAddressDto shipaddress) {
  1764. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1765. .getCurrentUser(request).getId());
  1766. if(user == null){
  1767. return ResponseCode.buildEnumMap(ResponseCode.TOKEN_EXPIRE,null);
  1768. }
  1769. if (user.getParent_id()!=null) {
  1770. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1771. }
  1772. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1773. .getStore_id()));
  1774. if(store == null){
  1775. return ResponseCode.buildEnumMap(ResponseCode.NOTSTORE,null);
  1776. }
  1777. if(shipaddress == null){
  1778. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1779. }
  1780. if (StringUtils.isBlank(shipaddress.getId()+"")) {
  1781. shipaddress.setAddTime(new Date());
  1782. shipaddress.setDeleteStatus(0);
  1783. } else {
  1784. ShipAddressDto obj = this.shipAddressFeignClient.selectByPrimaryKey(shipaddress.getId());
  1785. shipaddress.setAddTime(obj.getAddTime());
  1786. shipaddress.setDeleteStatus(obj.getDeleteStatus());
  1787. }
  1788. //判断是不是第一个发货地址 如果是则设置成默认的
  1789. Map< String , Object> maps = Maps.newHashMap();
  1790. List<Long> sa_user_ids = Lists.newArrayList();
  1791. sa_user_ids.add(user.getId());
  1792. if(user!=null && user.getParent_id()!=null){
  1793. UserDto userParent = this.userFeignClient.selectByPrimaryKey(user.getParent().getId());
  1794. sa_user_ids.add(userParent.getId());
  1795. List<UserDto> childs = userParent.getChilds();
  1796. for (UserDto uc : childs) {
  1797. sa_user_ids.add(uc.getId());
  1798. }
  1799. }
  1800. if(user!=null && user.getChilds()!=null && user.getChilds().size()>0){
  1801. List<UserDto> childs = user.getChilds();
  1802. for (UserDto uc : childs) {
  1803. sa_user_ids.add(uc.getId());
  1804. }
  1805. }
  1806. maps.put("sa_type", 0);
  1807. maps.put("sa_user_ids", sa_user_ids);
  1808. List<ShipAddressDto> queryPages = this.shipAddressFeignClient.queryPages(maps);
  1809. if(queryPages.size()>0){
  1810. shipaddress.setSa_default(0);
  1811. }else{
  1812. shipaddress.setSa_default(1);
  1813. }
  1814. shipaddress.setStore_id(store.getId());
  1815. shipaddress.setSa_type(0);
  1816. shipaddress.setSa_user_id(SecurityUserHolder.getCurrentUser(request).getId());
  1817. shipaddress.setSa_user_name(SecurityUserHolder.getCurrentUser(request)
  1818. .getUsername());
  1819. // 根据行业 决定是否需要创建达达门店
  1820. if (modularClassFeignClient.selectByPrimaryKey(store.getMc_id()).isTimely()) { // 若为附近配送,
  1821. SysConfigDto sysConfig = sysConfigFeignClient.getSysConfig();
  1822. if (sysConfig.getDada_appkey()!=null&& sysConfig.getDada_appsecret()!=null) {
  1823. // 1.初始化配置(isOnline表示是否测试环境)
  1824. DaDaAppConfig appConfig = new DaDaAppConfig(store.getSource_id() + "", sysConfig.getDada_appkey(), sysConfig.getDada_appsecret());
  1825. // 2.初始化model
  1826. ShopAddModel shopAddModel = new ShopAddModel();
  1827. if (StringUtils.isBlank(shipaddress.getId()+"")) { //不存在走更新
  1828. // 根据实际信息来填写门店地址
  1829. String order_suffix = CommUtil.formatTime("yyyyMMddHHmmss", new Date());
  1830. shopAddModel.setOriginShopId(order_suffix + store.getId()); // 门店编码,可自定义,但必须唯一;若不填写,则系统自动生成
  1831. shipaddress.setShop_no(order_suffix + store.getId()); // 保存门店编码
  1832. }else{
  1833. shopAddModel.setOriginShopId(shipaddress.getShop_no());
  1834. }
  1835. shopAddModel.setStationName(shipaddress.getSa_name()); // 门店名称
  1836. shopAddModel.setBusiness(13); // 业务类型, 13 水果生鲜
  1837. AreaDto area = areaFeignClient.selectByPrimaryKeyFullParent(shipaddress.getSa_area_id());
  1838. // shipaddress
  1839. shopAddModel.setCityName(area.getParent().getAreaName()); // 城市名称
  1840. shopAddModel.setAreaName(area.getAreaName()); // 区域名称
  1841. shopAddModel.setStationAddress(shipaddress.getSa_addr()); // 详细地址
  1842. shopAddModel.setLng(BigDecimal.valueOf(shipaddress.getSa_lng())); // 经纬度
  1843. shopAddModel.setLat(BigDecimal.valueOf(shipaddress.getSa_lat()));
  1844. shopAddModel.setContactName(shipaddress.getSa_user());
  1845. shopAddModel.setPhone(shipaddress.getSa_telephone());
  1846. // 3.初始化service (门店新增比较特殊,是一个批量新增接口)
  1847. List<ShopAddModel> shopAddList = new ArrayList<ShopAddModel>();
  1848. shopAddList.add(shopAddModel);
  1849. String dadaUrl = null;
  1850. if (StringUtils.isBlank(shipaddress.getId()+"")) {
  1851. dadaUrl = "/api/shop/add";
  1852. } else {
  1853. // 更新门店信息
  1854. dadaUrl = "/api/shop/update";
  1855. }
  1856. DaDaService shopAddService = new DaDaService(dadaUrl, JSONUtil.toJson(shopAddList));
  1857. // 4.初始化客户端
  1858. DadaRequestClient dadaClient = new DadaRequestClient(shopAddService, appConfig);
  1859. DadaApiResponse callRpc = dadaClient.callRpc();
  1860. if (callRpc.getCode() != 0) { // 不成功 ,返回错误信息
  1861. return ResponseCode.buildCodeMap("100", callRpc.getMsg(), null);
  1862. }
  1863. }
  1864. }
  1865. if (StringUtils.isBlank(shipaddress.getId()+"")) {
  1866. this.shipAddressFeignClient.saveEntity(shipaddress);
  1867. } else {
  1868. this.shipAddressFeignClient.updateById(shipaddress);
  1869. }
  1870. return ResponseCode.buildSuccessMap(null);
  1871. }
  1872. /**
  1873. * 发货地址删除
  1874. * @param request
  1875. * @param response
  1876. * @param mulitId
  1877. * @param currentPage
  1878. * @return
  1879. */
  1880. @RequestMapping(value = { "/ship_address_del" } , method = RequestMethod.POST)
  1881. public Map<String , Object> ship_address_del(HttpServletRequest request,@RequestBody JSONObject json) {
  1882. String id = json.optString("id");
  1883. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1884. .getCurrentUser(request).getId());
  1885. if(user == null){
  1886. return ResponseCode.buildReturnMap(ResponseCode.TOKEN_EXPIRE, null);
  1887. }
  1888. if (user.getParent_id()!=null) {
  1889. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1890. }
  1891. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1892. .getStore_id()));
  1893. if(store == null){
  1894. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1895. }
  1896. if (StringUtils.isNotBlank(id)) {
  1897. ShipAddressDto obj = this.shipAddressFeignClient.selectByPrimaryKey(CommUtil
  1898. .null2Long(id));
  1899. if ((obj != null) && (obj.getSa_type() == 0)
  1900. && (obj.getSa_user_id().equals(user.getId()))) {
  1901. this.shipAddressFeignClient.deleteById(obj.getId());
  1902. }
  1903. }
  1904. return ResponseCode.buildSuccessMap(null);
  1905. }
  1906. /**
  1907. * 设置默认发货地址
  1908. * @param request
  1909. * @param response
  1910. * @param id
  1911. * @param currentPage
  1912. * @return
  1913. */
  1914. @RequestMapping( value = { "/ship_address_default" } , method = RequestMethod.POST)
  1915. public Map<String , Object> ship_address_default(HttpServletRequest request, @RequestBody JSONObject json) {
  1916. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1917. .getCurrentUser(request).getId());
  1918. if(user == null){
  1919. return ResponseCode.buildReturnMap(ResponseCode.TOKEN_EXPIRE, null);
  1920. }
  1921. if (user.getParent_id()!=null) {
  1922. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1923. }
  1924. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(user
  1925. .getStore_id()));
  1926. if(store == null){
  1927. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1928. }
  1929. Map<String, Object> params = Maps.newHashMap();
  1930. params.put("sa_default", Integer.valueOf(1));
  1931. params.put("sa_user_id", user.getId());
  1932. List<ShipAddressDto> sa_list = this.shipAddressFeignClient.queryPages(params);
  1933. for (ShipAddressDto sa : sa_list) {
  1934. sa.setSa_default(0);
  1935. this.shipAddressFeignClient.updateById(sa);
  1936. }
  1937. String id = json.optString("id");
  1938. ShipAddressDto obj = this.shipAddressFeignClient.selectByPrimaryKey(CommUtil
  1939. .null2Long(id));
  1940. if (obj.getSa_user_id().equals(user.getId())) {
  1941. obj.setSa_default(1);
  1942. this.shipAddressFeignClient.updateById(obj);
  1943. }
  1944. return ResponseCode.buildSuccessMap(null);
  1945. }
  1946. /**
  1947. * 设置修改收货地址
  1948. * @param request
  1949. * @param response
  1950. * @param id
  1951. * @param currentPage
  1952. * @return
  1953. */
  1954. @RequestMapping(value = { "/upShippingAddress" } , method = RequestMethod.POST)
  1955. public Map<String , Object> upShippingAddress(HttpServletRequest request,
  1956. @RequestBody JSONObject json) {
  1957. String id = json.optString("id");
  1958. OrderFormDto obj = this.orderFormFeignClient
  1959. .selectByPrimaryKey(CommUtil.null2Long(id));
  1960. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  1961. .getCurrentUser(request).getId());
  1962. if(user == null){
  1963. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  1964. }
  1965. if (user.getParent_id()!=null) {
  1966. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  1967. }
  1968. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  1969. .getStore_id()));
  1970. if(store == null){
  1971. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  1972. }
  1973. //user = user.getParent_id() == null ? user : user.getParent();
  1974. if(user.getStore_id() == null){
  1975. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  1976. }
  1977. if (user.getStore_id().equals(store.getId())) {
  1978. return ResponseCode.buildSuccessMap(obj);
  1979. } else {
  1980. return ResponseCode.buildEnumMap(ResponseCode.FAILURE, null);
  1981. }
  1982. }
  1983. /**
  1984. * 设置修改收货地址保存
  1985. * @param request
  1986. * @param response
  1987. * @param id
  1988. * @param currentPage
  1989. * @return
  1990. */
  1991. @RequestMapping(value = { "/upShippingAddress_save" } , method = RequestMethod.POST)
  1992. public Map<String , Object> upShippingAddress_save(HttpServletRequest request,
  1993. @RequestBody JSONObject json) {
  1994. String id = json.optString("id");
  1995. String receiver_name = json.optString("receiver_name");// 收货人姓名,确认订单后,将买家的收货地址所有信息添加到订单中,该订单与买家收货地址没有任何关联
  1996. String receiver_area = json.optString("receiver_area");// 收货人地区,例如:福建省厦门市海沧区
  1997. String receiver_area_info = json.optString("receiver_area_info");// 收货人详细地址,例如:凌空二街56-1号,4单元21
  1998. //String receiver_zip = json.optString("receiver_zip");// 收货人邮政编码
  1999. String receiver_telephone = json.optString("receiver_telephone");// 收货人联系电话
  2000. String receiver_mobile = json.optString("receiver_mobile");// 收货人手机号码
  2001. String lat = json.optString("lat");// 经纬度
  2002. String lng = json.optString("lng");//
  2003. OrderFormDto obj = this.orderFormFeignClient
  2004. .selectByPrimaryKey(CommUtil.null2Long(id));
  2005. if(obj == null){
  2006. return ResponseCode.buildReturnMap(ResponseCode.PARAM_ERROR, null);
  2007. }
  2008. UserDto user = this.userFeignClient.selectByPrimaryKey(SecurityUserHolder
  2009. .getCurrentUser(request).getId());
  2010. if(user == null){
  2011. return ResponseCode.buildReturnMap(ResponseCode.USER_DOES_NOT_EXIST, null);
  2012. }
  2013. if (user.getParent_id()!=null) {
  2014. user = this.userFeignClient.selectByPrimaryKey(user.getParent_id());
  2015. }
  2016. Store store = this.storeService.selectByPrimaryKey(CommUtil.null2Long(obj
  2017. .getStore_id()));
  2018. if(store == null){
  2019. return ResponseCode.buildReturnMap(ResponseCode.NOTSTORE, null);
  2020. }
  2021. //user = user.getParent_id() == null ? user : user.getParent();
  2022. if(user.getStore_id() == null){
  2023. return ResponseCode.buildReturnMap(ResponseCode.FAILURE, null);
  2024. }
  2025. if (CommUtil.null2String(user.getStore_id()).equals(CommUtil.null2String(store.getId()))) {
  2026. obj.setReceiver_Name(receiver_name);
  2027. obj.setReceiver_area(receiver_area);
  2028. obj.setReceiver_area_info(receiver_area_info);
  2029. //obj.setReceiver_zip(receiver_zip);
  2030. obj.setReceiver_telephone(receiver_telephone);
  2031. obj.setReceiver_mobile(receiver_mobile);
  2032. if (StringUtils.isNotBlank(lat)&&StringUtils.isNotBlank(lng)) {
  2033. obj.setUser_lat(CommUtil.null2Double(lat));
  2034. obj.setUser_lng(CommUtil.null2Double(lng));
  2035. }
  2036. orderFormFeignClient.updateById(obj);
  2037. return ResponseCode.buildSuccessMap(obj);
  2038. } else {
  2039. return ResponseCode.buildEnumMap(ResponseCode.FAILURE, null);
  2040. }
  2041. }
  2042. }

 源码地址来源: https://minglisoft.cn/honghu2/business.html
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/999813
推荐阅读
相关标签
  

闽ICP备14008679号