PosOrderController.java 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800
  1. package com.ruoyi.app.order;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import cn.hutool.core.util.StrUtil;
  4. import com.alibaba.fastjson.JSON;
  5. import com.alibaba.fastjson.JSONArray;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  9. import com.baomidou.mybatisplus.core.metadata.IPage;
  10. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  11. import com.fasterxml.jackson.databind.ObjectMapper;
  12. import com.fasterxml.jackson.databind.SerializationFeature;
  13. import com.ruoyi.app.order.dto.OrderPositionInfo;
  14. import com.ruoyi.app.order.dto.OrderPushBodyDto;
  15. import com.ruoyi.app.order.dto.PositionDto;
  16. import com.ruoyi.app.order.dto.QsDto;
  17. import com.ruoyi.app.pay.PayController;
  18. import com.ruoyi.app.service.WalletService;
  19. import com.ruoyi.app.user.dto.StoreOutput;
  20. import com.ruoyi.app.utils.DateUtil;
  21. import com.ruoyi.app.utils.PayPush;
  22. import com.ruoyi.app.utils.event.PushEventService;
  23. import com.ruoyi.common.annotation.Anonymous;
  24. import com.ruoyi.common.annotation.Log;
  25. import com.ruoyi.common.annotation.RepeatSubmit;
  26. import com.ruoyi.common.core.controller.BaseController;
  27. import com.ruoyi.common.core.domain.AjaxResult;
  28. import com.ruoyi.common.core.domain.entity.SysDictData;
  29. import com.ruoyi.common.core.page.TableDataInfo;
  30. import com.ruoyi.common.enums.BusinessType;
  31. import com.ruoyi.common.exception.ServiceException;
  32. import com.ruoyi.common.utils.DictUtils;
  33. import com.ruoyi.common.utils.MessageUtils;
  34. import com.ruoyi.common.utils.StringUtils;
  35. import com.ruoyi.common.utils.poi.ExcelUtil;
  36. import com.ruoyi.system.domain.*;
  37. import com.ruoyi.system.domain.vo.OrderDTO;
  38. import com.ruoyi.system.mapper.PosFoodMapper;
  39. import com.ruoyi.system.mapper.PosOrderMapper;
  40. import com.ruoyi.system.mapper.RiderPositionMapper;
  41. import com.ruoyi.system.mapper.UserBillingMapper;
  42. import com.ruoyi.system.service.*;
  43. import com.ruoyi.system.utils.Auth;
  44. import com.ruoyi.system.utils.GetArea;
  45. import com.ruoyi.system.utils.JwtUtil;
  46. import lombok.SneakyThrows;
  47. import org.jetbrains.annotations.NotNull;
  48. import org.springframework.beans.BeanUtils;
  49. import org.springframework.beans.factory.annotation.Autowired;
  50. import org.springframework.security.access.prepost.PreAuthorize;
  51. import org.springframework.transaction.annotation.Isolation;
  52. import org.springframework.transaction.annotation.Transactional;
  53. import org.springframework.web.bind.annotation.*;
  54. import jakarta.servlet.http.HttpServletResponse;
  55. import java.math.BigDecimal;
  56. import java.text.DecimalFormat;
  57. import java.text.SimpleDateFormat;
  58. import java.util.*;
  59. import java.util.stream.Collectors;
  60. /**
  61. * posorderController
  62. *
  63. * @author ruoyi
  64. * @date 2023-05-23
  65. */
  66. @RestController
  67. @RequestMapping("/system/order")
  68. public class PosOrderController extends BaseController {
  69. @Autowired
  70. private IPosOrderService posOrderService;
  71. @Autowired
  72. private IInfoUserService infoUserService;
  73. @Autowired
  74. private IPosStoreService posStoreService;
  75. @Autowired
  76. private IInfoAddressService infoAddressService;
  77. @Autowired
  78. private IUserFootprintService userFootprintService;
  79. @Autowired
  80. private PosOrderMapper posOrderMapper;
  81. @Autowired
  82. private IRiderPositionService riderPositionService;
  83. @Autowired
  84. private IUserBillingService userBillingService;
  85. @Autowired
  86. private UserBillingMapper userBillingMapper;
  87. @Autowired
  88. private IPosMarginService posMarginService;
  89. @Autowired
  90. private ISalesPromotionService salesPromotionService;
  91. @Autowired
  92. private IPosAppealService posAppealService;
  93. @Autowired //商品
  94. private IPosFoodService posFoodService;
  95. @Autowired //经营时间
  96. private IOperatingHoursService operatingHoursService;
  97. @Autowired
  98. private IVipUserQuanyiService userQuanyiService;
  99. @Autowired
  100. private ISysPointControlService pointControlService;
  101. @Autowired
  102. private IUserWalletService userWalletService;
  103. @Autowired
  104. private RiderPositionMapper riderPositionMapper;
  105. @Autowired
  106. private IPointsTransactionService pointsTransactionService;
  107. @Autowired
  108. private PayController payController;
  109. @Autowired
  110. private PushEventService pushEventService;
  111. @Autowired
  112. private IPosOrderRatingService posOrderRatingService;
  113. @Autowired
  114. private IFoodStatisticsService foodStatisticsService;
  115. @Autowired
  116. private IOrderParentService orderParentService;
  117. @Autowired
  118. private WalletService walletService;
  119. @Autowired
  120. private PosFoodMapper posFoodMapper;
  121. //查询用户足迹
  122. @Anonymous
  123. @Auth
  124. @GetMapping("/getuserfootlist")
  125. public AjaxResult getuserfootlist(@RequestHeader String token, @RequestParam Integer page, @RequestParam Integer size) {
  126. JwtUtil jwtUtil = new JwtUtil();
  127. String id = jwtUtil.getusid(token);
  128. IPage<UserFootprint> palist = new Page<>(page, size);
  129. QueryWrapper<UserFootprint> queryWrapper = new QueryWrapper<>();
  130. queryWrapper.select().orderByDesc("cretim");
  131. queryWrapper.eq("user_id", id);
  132. IPage<UserFootprint> list = userFootprintService.page(palist, queryWrapper);
  133. List<UserFootprint> footprints = list.getRecords();
  134. // 收集所有门店ID(Integer类型)
  135. List<Long> storeIds = footprints.stream()
  136. .map(UserFootprint::getMdId)
  137. .toList();
  138. // 使用MyBatis Plus一次性查询所有门店的商品(避免N+1查询问题)
  139. Map<Integer, List<PosFood>> foodMap = new java.util.HashMap<>();
  140. if (!storeIds.isEmpty()) {
  141. // 将Integer类型的门店ID转换为Long类型用于查询(因为mdid是Long类型)
  142. List<Long> storeIdsLong = storeIds.stream()
  143. .map(x->x)
  144. .collect(Collectors.toList());
  145. // 使用MyBatis Plus的Mapper方法,在数据库查询时就限制每个门店只返回6条商品
  146. List<PosFood> allFoods = posFoodMapper.selectFoodsByStoreIdsWithLimit(storeIdsLong, "3", 6);
  147. // 按门店ID分组(查询结果已经限制为每个门店最多6条)
  148. foodMap = allFoods.stream()
  149. .collect(Collectors.groupingBy(food -> food.getMdid().intValue()));
  150. }
  151. // 转换为StoreOutput并设置每个门店的商品列表(每个门店最多6条)
  152. List<StoreOutput> storeOutputList = new ArrayList<>();
  153. for (UserFootprint collect : footprints) {
  154. PosStore store=posStoreService.getById(collect.getMdId());
  155. if(store!=null){
  156. StoreOutput storeOutput = new StoreOutput();
  157. // 复制PosStore的所有属性
  158. BeanUtils.copyProperties(store, storeOutput);
  159. // 从分组结果中获取该门店的商品列表(已限制为最多6条)
  160. List<PosFood> foodList = foodMap.getOrDefault(store.getId(), new ArrayList<>());
  161. storeOutput.setFoodList(foodList);
  162. storeOutputList.add(storeOutput);
  163. }
  164. }
  165. Page<StoreOutput> result = new Page<>(page, 10);
  166. result.setTotal(list.getTotal());
  167. result.setRecords(storeOutputList);
  168. return success(result);
  169. }
  170. //修改订单
  171. @Anonymous
  172. @Auth
  173. @RepeatSubmit(interval = 1000, message = "请求过于频繁")
  174. @PostMapping("/setorderuzt")
  175. public AjaxResult setorderuzt(@RequestHeader String token, @RequestBody PosOrder posOrder) {
  176. JwtUtil jwtUtil = new JwtUtil();
  177. PayPush push = new PayPush();
  178. String id = jwtUtil.getusid(token);
  179. if (posOrder.getState() != null) {
  180. //状态为送达,设置送达时间
  181. if (posOrder.getState() == 12) {
  182. posOrder.setSdTime(new Date());
  183. }
  184. System.out.println("修改订单状态信息:" + JSON.toJSONString(posOrder));
  185. //设置支付类型为货到付款
  186. if (posOrder.getState() == 0 && "1".equals(posOrder.getCollectPayment())) {
  187. System.out.println("进入设置paytype等于1");
  188. posOrder.setPayType("1");
  189. }
  190. //取餐时设置预计送达时间
  191. setYjsdTime(posOrder);
  192. if (posOrder.getState() == 5) {
  193. return setOrderState5(posOrder);
  194. } else if (posOrder.getState() == 2) {
  195. return setOrderState2(posOrder, id);
  196. } else if (posOrder.getState() == 3 || posOrder.getState() == 4 || posOrder.getState() == 12)
  197. {
  198. return setOrderQsState(posOrder, id, push);
  199. } else if (posOrder.getState() == 7) {
  200. return setOrderState7(posOrder);
  201. } else {
  202. boolean org = posOrderService.saveOrUpdate(posOrder);
  203. PosOrder order = posOrderService.getById(posOrder.getId());
  204. if (order.getState() == 0 && order.getCollectPayment().equals("1")) {
  205. sendHdfkMessage(order, push);
  206. }
  207. //作废退回积分
  208. if (posOrder.getState() == 10 && order.getPoints() != null && order.getPoints() > 0) {
  209. returnPoints(order.getUserId(), Long.valueOf(order.getDdId()), Long.valueOf(order.getPoints()));
  210. }
  211. if (org) {
  212. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  213. } else {
  214. return error();
  215. }
  216. }
  217. } else {
  218. return setOrderNoState(posOrder, id);
  219. }
  220. }
  221. //骑手接单、取餐、送达
  222. private AjaxResult setOrderQsState(PosOrder posOrder, String id, PayPush push) {
  223. PosOrder orst = posOrderService.getById(posOrder.getId());
  224. if (orst.getState() == 3 && posOrder.getState() == 3) {
  225. return error(MessageUtils.message("no.order.snatched"));
  226. } else {
  227. if(posOrder.getState()==3){
  228. QueryWrapper<PosOrder> wrapper = new QueryWrapper<>();
  229. wrapper.eq("qs_id", id);
  230. wrapper.in("state", 3, 4);
  231. List<PosOrder> orsts = posOrderService.list(wrapper);
  232. if (orsts.size() > 0) {
  233. return error(MessageUtils.message("no.exist.undelivered.order"));
  234. }
  235. }
  236. String userMessage= MessageUtils.message("no.message.push.delivery.personnel.receiving.order");
  237. if(posOrder.getState()==4){
  238. userMessage= MessageUtils.message("no.message.push.delivery.personnel.qspsz.order");
  239. }else if(posOrder.getState()==12){
  240. userMessage= MessageUtils.message("no.message.push.delivery.personnel.qsysd.order");
  241. }
  242. int zsou = userBillingMapper.gettypesum(Long.valueOf(id), 1L);
  243. int zcz = userBillingMapper.gettypesum(Long.valueOf(id), 2L);
  244. int xiaf = userBillingMapper.gettypesum(Long.valueOf(id), 3L);
  245. int yure = zsou - zcz - xiaf;
  246. PosMargin posMargin = posMarginService.getById(2);
  247. System.out.println("用户余额:" + yure);
  248. System.out.println("保证金:" + posMargin.getAmount());
  249. //临时代码开始
  250. if (orst.getCollectPayment().equals("1")) {
  251. System.out.println("结果:" + orst.getAmount());
  252. boolean org = posOrderService.saveOrUpdate(posOrder);
  253. if (org) {
  254. if(posOrder.getState()==3) {
  255. QueryWrapper<UserBilling> queryWrapper = new QueryWrapper<>();
  256. queryWrapper.eq("dd_id", orst.getDdId());
  257. queryWrapper.eq("type", "3");
  258. queryWrapper.eq("state", "3");
  259. UserBilling foot = userBillingService.getOne(queryWrapper);
  260. foot.setState("0");
  261. foot.setIllustrate("Rider Payment Order");
  262. foot.setBalancePay("1");
  263. foot.setPaymentId(String.valueOf(id));
  264. userBillingService.saveOrUpdate(foot);
  265. }
  266. InfoUser user = infoUserService.getById(orst.getUserId());
  267. InfoUser shu = infoUserService.getById(orst.getShId());
  268. if (!"".equals(user.getCid())) {
  269. logger.info("用户cid:" + user.getCid() + "推送");
  270. push.apppush(user.getCid(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
  271. pushEventService.PublisherEvent(user.getUserId(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
  272. }
  273. if (!"".equals(shu.getCid()) && posOrder.getState()==3) {
  274. logger.info("商家cid:" + user.getCid() + "推送");
  275. push.shpush(shu.getCid(), MessageUtils.message("no.message.push.message"), MessageUtils.message("no.message.push.new.order"), OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
  276. pushEventService.PublisherEvent(shu.getUserId(), MessageUtils.message("no.message.push.message"), MessageUtils.message("no.message.push.new.order"), OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
  277. }
  278. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  279. } else {
  280. return error();
  281. }
  282. } else {
  283. boolean org = posOrderService.saveOrUpdate(posOrder);
  284. if (org) {
  285. InfoUser user = infoUserService.getById(orst.getUserId());
  286. if (!"".equals(user.getCid())) {
  287. logger.info("用户cid:" + user.getCid() + "推送");
  288. push.apppush(user.getCid(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
  289. pushEventService.PublisherEvent(user.getUserId(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
  290. }
  291. return success(MessageUtils.message("no.modify.success"), orst.getId());
  292. } else {
  293. return error();
  294. }
  295. }
  296. }
  297. }
  298. //商家接单
  299. private AjaxResult setOrderState2(PosOrder posOrder,String id) {
  300. int zsou = userBillingMapper.gettypesum(Long.valueOf(id), 1L);
  301. int zcz = userBillingMapper.gettypesum(Long.valueOf(id), 2L);
  302. int xiaof = userBillingMapper.gettypesum(Long.valueOf(id), 3L);
  303. int yure = zsou - zcz - xiaof;
  304. PosMargin posMargin = posMarginService.getById(1);
  305. InfoUser user = infoUserService.getById(id);
  306. if (user.getUserType().equals("1")) {
  307. boolean org = posOrderService.saveOrUpdate(posOrder);
  308. if (org) {
  309. PosOrder order = posOrderService.getById(posOrder.getId());
  310. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  311. } else {
  312. return error();
  313. }
  314. } else {
  315. if (yure <= (int) Math.round(posMargin.getAmount())) {
  316. return error(MessageUtils.message("no.insufficient.user.security.deposit"));
  317. } else {
  318. boolean org = posOrderService.saveOrUpdate(posOrder);
  319. if (org) {
  320. PosOrder order = posOrderService.getById(posOrder.getId());
  321. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  322. } else {
  323. return error();
  324. }
  325. }
  326. }
  327. }
  328. //订单完成
  329. private AjaxResult setOrderState5(PosOrder posOrder){
  330. boolean org = posOrderService.saveOrUpdate(posOrder);
  331. if (org) {
  332. PosOrder order = posOrderService.getById(posOrder.getId());
  333. QueryWrapper<UserBilling> wrapper = new QueryWrapper<>();
  334. wrapper.eq("dd_id", order.getId());
  335. UserBilling billing = userBillingService.getOne(wrapper);
  336. if (billing == null) {
  337. setSanghuBilling(order);
  338. setQishouBilling(order);
  339. }
  340. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  341. } else {
  342. return error();
  343. }
  344. }
  345. //同意退款
  346. private AjaxResult setOrderState7(PosOrder posOrder) {
  347. boolean org = posOrderService.saveOrUpdate(posOrder);
  348. PosOrder order = posOrderService.getById(posOrder.getId());
  349. if (order.getPoints() != null && order.getPoints() > 0) {
  350. returnPoints(order.getUserId(), Long.valueOf(order.getDdId()), Long.valueOf(order.getPoints()));
  351. }
  352. if (org) {
  353. QueryWrapper<UserBilling> wrapper = new QueryWrapper<>();
  354. wrapper.eq("dd_id", posOrder.getId());
  355. List<UserBilling> billing = userBillingService.list(wrapper);
  356. if (billing.size() == 0) {
  357. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  358. } else {
  359. for (int i = 0; i < billing.size(); i++) {
  360. UserBilling user = new UserBilling();
  361. user.setId(billing.get(i).getId());
  362. user.setState("1");
  363. userBillingService.saveOrUpdate(user);
  364. }
  365. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  366. }
  367. } else {
  368. return error();
  369. }
  370. }
  371. //更改订单没传订单状态
  372. private AjaxResult setOrderNoState(PosOrder posOrder, String id) {
  373. PosOrder ordera = posOrderService.getById(posOrder.getId());
  374. //订单金额限制100万改为200万
  375. if (posOrder.getCollectPayment().equals("1") && ordera.getAmount() > 2000000) {
  376. return error(MessageUtils.message("no.cash_on_delivery_amount.exceed.limit_amount"));
  377. }
  378. QueryWrapper<PosOrder> query = new QueryWrapper<>();
  379. query.eq("user_id", id);
  380. query.eq("collect_payment", "1");
  381. query.notIn("state", 5, 10, 11);
  382. List<PosOrder> posOrders = posOrderService.list(query);
  383. //到付能存在2单未完成,第3单弹出提示;修改做判断的前提是当前订单不是为到付
  384. if (posOrders.size() >= 2 && posOrder.getCollectPayment().equals("1") && !"1".equals(ordera.getCollectPayment())) {
  385. return error(MessageUtils.message("no.exist.cash_on_delivery_order.incomplete"));
  386. }
  387. boolean org = posOrderService.saveOrUpdate(posOrder);
  388. if (org) {
  389. PosOrder order = posOrderService.getById(posOrder.getId());
  390. return success(MessageUtils.message("no.modify.success"), posOrder.getId());
  391. } else {
  392. return error();
  393. }
  394. }
  395. /**
  396. * 获取预计送达时间
  397. *
  398. * @param posOrder
  399. * @return
  400. */
  401. private String setYjsdTime(PosOrder posOrder) {
  402. try {
  403. if (posOrder.getState() == 4) {
  404. GetArea getArea = new GetArea();
  405. PosOrder order = posOrderService.getById(posOrder.getId());
  406. String mdlat = order.getLongitude() + "," + order.getLatitude();
  407. InfoAddress shDz = infoAddressService.getById(order.getShdzId());
  408. String shlat = shDz.getLongitude() + "," + shDz.getLatitude();
  409. double time = getArea.getMotorbikeDuration(mdlat, shlat);
  410. DateUtil dateUtil = new DateUtil();
  411. String start = dateUtil.getHourAndMinute((long) time);
  412. double endTime = time + 600; //加上10分钟
  413. String end = dateUtil.getHourAndMinute((long) endTime);
  414. posOrder.setYjsdTime(start + "-" + end);
  415. return start + "-" + end;
  416. }
  417. return "";
  418. } catch (Exception e) {
  419. logger.error("获取预计送达时间异常,id:" + posOrder.getId() + "异常信息:", e);
  420. return "";
  421. }
  422. }
  423. //修改订单
  424. @Anonymous
  425. @PostMapping("/testYjsdTime")
  426. public String testYjsdTime(@RequestBody PosOrder order) {
  427. return setYjsdTime(order);
  428. }
  429. //执行商户分成
  430. public void setSanghuBilling(@NotNull PosOrder posOrder) {
  431. long count = userBillingService.count(new LambdaQueryWrapper<UserBilling>().eq(UserBilling::getUserId, posOrder.getShId()).eq(UserBilling::getType, "0").eq(UserBilling::getDdId, posOrder.getDdId()));
  432. if (count <= 0) {
  433. UserBilling billing = new UserBilling();
  434. DecimalFormat df = new DecimalFormat("#.00");
  435. InfoUser user = infoUserService.getById(posOrder.getShId());
  436. Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
  437. fcbili=getShCommissionRate(fcbili,user.getUserId());
  438. JSONArray list = JSONArray.parseArray(posOrder.getFood());
  439. int fenc = 0;
  440. for (int i = 0; i < list.size(); i++) {
  441. JSONObject foods = list.getJSONObject(i);
  442. //20250612修改,商品金额等于价格乘以数量;未修改前金额直接为商品价格
  443. int price = foods.getInteger("price");
  444. int otherPrice = foods.getInteger("otherPrice"); //规格价格
  445. int num = foods.getInteger("number");
  446. int age = (price + otherPrice) * num; //价格=商品价格+规格价格
  447. fenc += age;
  448. }
  449. String remark = "";
  450. //商家分成总金额,减去商家优惠金额,减去商家活动金额(type=1 为平台指定商家优惠券,由平台承担)
  451. if (posOrder.getMdYhId() != null && posOrder.getMdDiscountAmount() != null) {
  452. VipUserQuanyi userQuanyi = userQuanyiService.getById(posOrder.getMdYhId());
  453. if (userQuanyi != null && "1".equals(userQuanyi.getType())) {
  454. fenc = fenc - posOrder.getMdDiscountAmount();
  455. String yhmcMessage = MessageUtils.message("no.posorder.md.yh.mc.messag");
  456. yhmcMessage = StrUtil.format(yhmcMessage, posOrder.getMdYhName());
  457. remark += yhmcMessage;
  458. String yhAmount = MessageUtils.message("no.posorder.md.yh.jiner.messag");
  459. yhAmount = StrUtil.format(yhAmount, posOrder.getMdDiscountAmount());
  460. remark += yhAmount;
  461. }
  462. }
  463. if (posOrder.getMdSalesName() != null && posOrder.getMdSalesReduction() != null) {
  464. fenc = fenc - posOrder.getMdSalesReduction();
  465. String cxNameMessage = MessageUtils.message("no.posorder.md.cx.mc.messag");
  466. cxNameMessage = StrUtil.format(cxNameMessage, posOrder.getMdSalesName());
  467. remark += cxNameMessage;
  468. String cxAmount = MessageUtils.message("no.posorder.md.cx.jiner.messag");
  469. cxAmount = StrUtil.format(cxAmount, posOrder.getMdSalesReduction());
  470. remark += cxAmount;
  471. }
  472. billing.setIllustrate(remark);
  473. Double chouc = fenc * fcbili;
  474. Double shfc = fenc - chouc;
  475. billing.setUserId(posOrder.getShId());
  476. billing.setDdId(String.valueOf(posOrder.getDdId()));
  477. billing.setType("0");
  478. billing.setAmount(Double.valueOf(df.format(shfc)));
  479. billing.setDivvy(Double.valueOf(df.format(chouc)));
  480. billing.setState("0");
  481. billing.setMdId(posOrder.getMdId());
  482. billing.setUserType("1");
  483. billing.setDivvyRate(fcbili);
  484. walletService.addBalance(billing.getUserId(), BigDecimal.valueOf(billing.getAmount()), billing);
  485. // int reg = userBillingService.insertUserBilling(billing);
  486. // if (reg == 1) {
  487. //
  488. // System.out.println("商户分成成功,订单号:" + posOrder.getDdId() + ",分成金额:" + shfc + ",抽成:" + chouc);
  489. //
  490. // } else {
  491. // System.out.println("订单:" + posOrder.getDdId() + "分成失败");
  492. // }
  493. }
  494. }
  495. /**
  496. * 获取商家分成比例
  497. * 委托给 Service 层处理
  498. *
  499. * @param rate 默认分成比例
  500. * @param shUserId 商家用户ID
  501. * @return 分成比例
  502. */
  503. public Double getShCommissionRate(Double rate, Long shUserId){
  504. return rate;
  505. // 委托给 Service 层处理
  506. // return commissionRatesService.getShCommissionRate(rate, shUserId);
  507. }
  508. //执行骑手分成
  509. public void setQishouBilling(@NotNull PosOrder posOrder) {
  510. long count = userBillingService.count(new LambdaQueryWrapper<UserBilling>().eq(UserBilling::getUserId, posOrder.getQsId()).eq(UserBilling::getType, "0").eq(UserBilling::getDdId, posOrder.getDdId()));
  511. if (count <= 0) {
  512. UserBilling billing = new UserBilling();
  513. DecimalFormat df = new DecimalFormat("#.00");
  514. InfoUser user = infoUserService.getById(posOrder.getQsId());
  515. if (user == null) {
  516. System.out.println("订单无骑手");
  517. } else {
  518. Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
  519. Double fenc = posOrder.getFreight();
  520. Double chouc = fenc * fcbili;
  521. Double shfc = fenc - chouc;
  522. List<SysDictData> taxBl = DictUtils.getDictCache("sys_qs_freight_bl");
  523. if (taxBl != null && taxBl.get(0) != null) {
  524. Double tax = shfc * Double.parseDouble(taxBl.get(0).getDictValue());
  525. billing.setTax(BigDecimal.valueOf(tax));
  526. billing.setTaxRate(taxBl.get(0).getDictValue());
  527. shfc = shfc - tax;
  528. }
  529. billing.setUserId(posOrder.getQsId());
  530. billing.setDdId(String.valueOf(posOrder.getDdId()));
  531. billing.setType("0");
  532. billing.setAmount(Double.valueOf(df.format(shfc)));
  533. billing.setDivvy(Double.valueOf(df.format(chouc)));
  534. billing.setState("0");
  535. billing.setMdId(posOrder.getMdId());
  536. billing.setUserType("2");
  537. billing.setDivvyRate(user.getCommission());
  538. //货到付款设置代收金额
  539. if ("1".equals(posOrder.getCollectPayment())) {
  540. billing.setBehalfAmount(Double.valueOf(posOrder.getAmount()));
  541. }
  542. walletService.addBalance(billing.getUserId(), BigDecimal.valueOf(billing.getAmount()), billing);
  543. // int reg = userBillingService.insertUserBilling(billing);
  544. // if (reg == 1) {
  545. // System.out.println("骑手分成成功,订单号:" + posOrder.getDdId() + ",分成金额:" + shfc + ",抽成:" + chouc);
  546. // } else {
  547. // System.out.println("订单:" + posOrder.getDdId() + "分成失败");
  548. // }
  549. }
  550. }
  551. }
  552. //后台查询详情
  553. @GetMapping("/getorderhout")
  554. public AjaxResult getorderhout(@RequestParam String id) {
  555. PosOrder orlist = posOrderService.getById(id);
  556. JSONObject org = new JSONObject();
  557. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  558. org.put("id", orlist.getId());
  559. org.put("ddId", orlist.getDdId());
  560. org.put("shanghu", infoUserService.getById(orlist.getShId()));
  561. org.put("store", posStoreService.getById(orlist.getMdId()));
  562. org.put("cretim", sdf.format(orlist.getCretim()));
  563. org.put("shdzId", orlist.getShdzId());
  564. org.put("shaddress", orlist.getShAddress() == null ? infoAddressService.getById(orlist.getShdzId()) : JSONObject.parseObject(orlist.getShAddress()));
  565. org.put("user", infoUserService.getById(orlist.getUserId()));
  566. org.put("amount", orlist.getAmount());
  567. org.put("kefuState", orlist.getKefuState());
  568. org.put("kefuContent", orlist.getKefuContent());
  569. org.put("kefuRepeat", orlist.getKefuRepeat());
  570. org.put("repeatDdId", orlist.getRepeatDdId());
  571. org.put("remarks", orlist.getRemarks());
  572. org.put("state", orlist.getState());
  573. org.put("type", orlist.getType());
  574. org.put("jvli", orlist.getJvli());
  575. org.put("freight", orlist.getFreight());
  576. org.put("delryTime", orlist.getDelryTime());
  577. org.put("longitude", orlist.getLongitude());
  578. org.put("latitude", orlist.getLatitude());
  579. org.put("qsuser", infoUserService.getById(orlist.getQsId()));
  580. org.put("payUrl", orlist.getPayUrl());
  581. QueryWrapper<RiderPosition> query = new QueryWrapper<>();
  582. query.eq("rider_id", orlist.getQsId());
  583. org.put("RiderPosition", orlist.getQsId() == null ? null : riderPositionService.getOne(query));
  584. org.put("diningStatus", orlist.getDiningStatus());
  585. org.put("collectPayment", orlist.getCollectPayment());
  586. org.put("food", JSONArray.parseArray(orlist.getFood()));
  587. // org.put("activity",salesPromotionService.getById(orlist.getActivity()));
  588. org.put("activity", orlist.getActivity());
  589. org.put("mdActivity", orlist.getMdActivity());
  590. org.put("salesReduction", orlist.getSalesReduction());
  591. org.put("mdSalesReduction", orlist.getMdSalesReduction());
  592. org.put("salesName", orlist.getSalesName());
  593. org.put("mdSalesName", orlist.getMdSalesName());
  594. org.put("mdDiscountAmount", orlist.getMdDiscountAmount());
  595. org.put("discountAmount", orlist.getDiscountAmount());
  596. org.put("mdYhId", orlist.getMdYhId());
  597. org.put("mdYhName", orlist.getMdYhName());
  598. org.put("yhId", orlist.getYhId());
  599. org.put("yhName", orlist.getYhName());
  600. org.put("points", orlist.getPoints());
  601. org.put("pointsReduction", orlist.getPointsReduction());
  602. org.put("sdTime", orlist.getSdTime());
  603. org.put("payType", orlist.getPayType());
  604. return success(org);
  605. }
  606. /**
  607. * 通过订单号查询订单详情
  608. *
  609. * @param ddid
  610. * @return
  611. */
  612. //查询订单详情
  613. @Anonymous
  614. @Auth
  615. @GetMapping("/getorderxq")
  616. public AjaxResult getorderxq(@RequestParam String ddid) {
  617. QueryWrapper<PosOrder> queryWrapper = new QueryWrapper<>();
  618. queryWrapper.eq("dd_id", ddid);
  619. PosOrder orlist = posOrderService.getOne(queryWrapper);
  620. JSONObject org = new JSONObject();
  621. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  622. org.put("id", orlist.getId());
  623. org.put("ddId", orlist.getDdId());
  624. org.put("shanghu", infoUserService.getById(orlist.getShId()));
  625. org.put("store", posStoreService.getById(orlist.getMdId()));
  626. org.put("cretim", sdf.format(orlist.getCretim()));
  627. org.put("shdzId", orlist.getShdzId());
  628. org.put("shaddress", orlist.getShAddress() == null ? infoAddressService.getById(orlist.getShdzId()) : JSONObject.parseObject(orlist.getShAddress()));
  629. org.put("user", infoUserService.getById(orlist.getUserId()));
  630. org.put("amount", orlist.getAmount());
  631. org.put("kefuState", orlist.getKefuState());
  632. org.put("kefuContent", orlist.getKefuContent());
  633. org.put("kefuRepeat", orlist.getKefuRepeat());
  634. org.put("repeatDdId", orlist.getRepeatDdId());
  635. org.put("remarks", orlist.getRemarks());
  636. org.put("state", orlist.getState());
  637. org.put("type", orlist.getType());
  638. org.put("jvli", orlist.getJvli());
  639. org.put("freight", orlist.getFreight());
  640. org.put("delryTime", orlist.getDelryTime());
  641. org.put("longitude", orlist.getLongitude());
  642. org.put("latitude", orlist.getLatitude());
  643. org.put("qsId", orlist.getQsId());
  644. org.put("sqImg", orlist.getQsImg());
  645. org.put("discountAmount", orlist.getDiscountAmount());
  646. InfoUser qsUser = infoUserService.getById(orlist.getQsId());
  647. setQsStar(qsUser);
  648. org.put("qsuser", orlist.getQsId() == null ? null : qsUser);
  649. org.put("payUrl", orlist.getPayUrl());
  650. QueryWrapper<RiderPosition> query = new QueryWrapper<>();
  651. query.eq("rider_id", orlist.getQsId());
  652. org.put("RiderPosition", orlist.getQsId() == null ? null : riderPositionService.getOne(query));
  653. org.put("diningStatus", orlist.getDiningStatus());
  654. org.put("collectPayment", orlist.getCollectPayment());
  655. org.put("food", JSONArray.parseArray(orlist.getFood()));
  656. // org.put("activity",salesPromotionService.getById(orlist.getActivity()));
  657. org.put("activity", orlist.getActivity());
  658. org.put("mdActivity", orlist.getMdActivity());
  659. org.put("salesReduction", orlist.getSalesReduction());
  660. org.put("mdSalesReduction", orlist.getMdSalesReduction());
  661. org.put("salesName", orlist.getSalesName());
  662. org.put("mdSalesName", orlist.getMdSalesName());
  663. org.put("mdDiscountAmount", orlist.getMdDiscountAmount());
  664. org.put("discountAmount", orlist.getDiscountAmount());
  665. org.put("mdYhId", orlist.getMdYhId());
  666. org.put("mdYhName", orlist.getMdYhName());
  667. org.put("yhId", orlist.getYhId());
  668. org.put("yhName", orlist.getYhName());
  669. org.put("points", orlist.getPoints());
  670. org.put("pointsReduction", orlist.getPointsReduction());
  671. org.put("sdTime", orlist.getSdTime());
  672. org.put("payType", orlist.getPayType());
  673. Long count = posOrderRatingService.getBaseMapper().selectCount(new QueryWrapper<PosOrderRating>().eq("dd_id", ddid));
  674. //是否已经评论
  675. org.put("isCommented", count > 0);
  676. return success(org);
  677. }
  678. /**
  679. * 设置骑手星级
  680. *
  681. * @param infoUser
  682. */
  683. private void setQsStar(InfoUser infoUser) {
  684. if (infoUser != null) {
  685. QueryWrapper<PosOrderRating> wrapper = new QueryWrapper<>();
  686. wrapper.eq("qs_id", infoUser.getUserId()).isNotNull("qs_stars").isNotNull("qs_stars").select("ROUND(AVG(qs_stars), 1) as qs_stars");
  687. List<Map<String, Object>> map = posOrderRatingService.getBaseMapper().selectMaps(wrapper);
  688. if (!map.isEmpty() && map.get(0) != null) {
  689. Object rating = map.get(0).get("qs_stars");
  690. // 关键:显式检查null值
  691. if (rating != null) {
  692. infoUser.setStar(Double.parseDouble(rating.toString()));
  693. }
  694. } else {
  695. infoUser.setStar(4.5);
  696. }
  697. }
  698. }
  699. //查询所有的订单
  700. @Anonymous
  701. @GetMapping("/getqishouorderlist")
  702. public AjaxResult getqishouorderlist(@RequestParam Integer page, @RequestParam BigDecimal longitude, @RequestParam BigDecimal latitude, @RequestParam Integer juli, @RequestParam(defaultValue = "") String state) {
  703. JSONArray arr = new JSONArray();
  704. List<PosOrder> orlist;
  705. if (!"".equals(state)) {
  706. if (state.equals("z02")) {
  707. orlist = posOrderMapper.getz02(longitude, latitude, (page - 1) * 20, juli);
  708. } else if (state.equals("z234")) {
  709. orlist = posOrderMapper.getz234(longitude, latitude, (page - 1) * 20, juli, 2, 4);
  710. } else if (state.equals("z23")) {
  711. orlist = posOrderMapper.getz234(longitude, latitude, (page - 1) * 20, juli, 2, 3);
  712. } else if (state.equals("z34")) {
  713. orlist = posOrderMapper.getz234(longitude, latitude, (page - 1) * 20, juli, 3, 4);
  714. } else if (state.equals("z6789")) {
  715. orlist = posOrderMapper.getz234(longitude, latitude, (page - 1) * 20, juli, 6, 9);
  716. } else {
  717. orlist = posOrderMapper.getstate(longitude, latitude, (page - 1) * 20, juli, state);
  718. }
  719. } else {
  720. orlist = posOrderMapper.getqisjvli(longitude, latitude, (page - 1) * 20, juli);
  721. }
  722. for (int i = 0; i < orlist.size(); i++) {
  723. JSONObject org = new JSONObject();
  724. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  725. org.put("id", orlist.get(i).getId());
  726. org.put("ddId", orlist.get(i).getDdId());
  727. org.put("shanghu", infoUserService.getById(orlist.get(i).getShId()));
  728. org.put("store", posStoreService.getById(orlist.get(i).getMdId()));
  729. org.put("cretim", sdf.format(orlist.get(i).getCretim()));
  730. org.put("shdzId", orlist.get(i).getShdzId());
  731. org.put("shaddress", orlist.get(i).getShAddress() == null ? infoAddressService.getById(orlist.get(i).getShdzId()) : JSONObject.parseObject(orlist.get(i).getShAddress()));
  732. org.put("user", infoUserService.getById(orlist.get(i).getUserId()));
  733. org.put("amount", orlist.get(i).getAmount());
  734. org.put("kefuState", orlist.get(i).getKefuState());
  735. org.put("kefuContent", orlist.get(i).getKefuContent());
  736. org.put("kefuRepeat", orlist.get(i).getKefuRepeat());
  737. org.put("repeatDdId", orlist.get(i).getRepeatDdId());
  738. org.put("remarks", orlist.get(i).getRemarks());
  739. org.put("state", orlist.get(i).getState());
  740. org.put("type", orlist.get(i).getType());
  741. org.put("jvli", orlist.get(i).getJvli());
  742. DecimalFormat jl = new DecimalFormat("#.0");
  743. org.put("qsjvli", jl.format(orlist.get(i).getJuli()));
  744. org.put("freight", orlist.get(i).getFreight());
  745. org.put("delryTime", orlist.get(i).getDelryTime());
  746. org.put("qsId", orlist.get(i).getQsId());
  747. org.put("payUrl", orlist.get(i).getPayUrl());
  748. org.put("diningStatus", orlist.get(i).getDiningStatus());
  749. org.put("food", JSONArray.parseArray(orlist.get(i).getFood()));
  750. org.put("collectPayment", orlist.get(i).getCollectPayment());
  751. // org.put("activity",salesPromotionService.getById(orlist.get(i).getActivity()));
  752. org.put("activity", orlist.get(i).getActivity());
  753. org.put("mdActivity", orlist.get(i).getMdActivity());
  754. org.put("salesReduction", orlist.get(i).getSalesReduction());
  755. org.put("mdSalesReduction", orlist.get(i).getMdSalesReduction());
  756. org.put("salesName", orlist.get(i).getSalesName());
  757. org.put("mdSalesName", orlist.get(i).getMdSalesName());
  758. org.put("mdDiscountAmount", orlist.get(i).getMdDiscountAmount());
  759. org.put("discountAmount", orlist.get(i).getDiscountAmount());
  760. org.put("mdYhId", orlist.get(i).getMdYhId());
  761. org.put("mdYhName", orlist.get(i).getMdYhName());
  762. org.put("yhId", orlist.get(i).getYhId());
  763. org.put("yhName", orlist.get(i).getYhName());
  764. org.put("points", orlist.get(i).getPoints());
  765. org.put("pointsReduction", orlist.get(i).getPointsReduction());
  766. org.put("sdTime", orlist.get(i).getSdTime());
  767. org.put("payType", orlist.get(i).getPayType());
  768. arr.add(org);
  769. }
  770. return success(arr);
  771. }
  772. //查询骑手的订单
  773. @Anonymous
  774. @Auth
  775. @GetMapping("/getqsorderlist")
  776. public AjaxResult getqsorderlist(@RequestHeader String token, @RequestParam Integer page, @RequestParam Integer size, @RequestParam(defaultValue = "") String state) {
  777. logger.info("骑手token:" + token);
  778. JwtUtil jwtUtil = new JwtUtil();
  779. String id = jwtUtil.getusid(token);
  780. IPage<PosOrder> palist = new Page<>(page, size);
  781. QueryWrapper<PosOrder> queryWrapper = new QueryWrapper<>();
  782. queryWrapper.select().orderByDesc("cretim");
  783. queryWrapper.eq("qs_id", id);
  784. if (!"".equals(state)) {
  785. if (state.equals("z234")) {
  786. queryWrapper.in("state", 2, 3, 4);
  787. } else if (state.equals("z23")) {
  788. queryWrapper.in("state", 2, 3);
  789. } else if (state.equals("z34")) {
  790. queryWrapper.in("state", 3, 4);
  791. } else if (state.equals("z6789")) {
  792. queryWrapper.in("state", 6, 7, 8, 9);
  793. } else if (state.equals("z678911")) {
  794. queryWrapper.in("state", 6, 7, 8, 9, 11);
  795. } else {
  796. queryWrapper.eq("state", state);
  797. }
  798. }
  799. IPage<PosOrder> list = posOrderService.page(palist, queryWrapper);
  800. List<PosOrder> orlist = list.getRecords();
  801. JSONArray arr = new JSONArray();
  802. for (int i = 0; i < orlist.size(); i++) {
  803. JSONObject org = new JSONObject();
  804. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  805. org.put("id", orlist.get(i).getId());
  806. org.put("ddId", orlist.get(i).getDdId());
  807. org.put("shanghu", infoUserService.getById(orlist.get(i).getShId()));
  808. org.put("store", posStoreService.getById(orlist.get(i).getMdId()));
  809. org.put("cretim", sdf.format(orlist.get(i).getCretim()));
  810. org.put("shdzId", orlist.get(i).getShdzId());
  811. org.put("shaddress", orlist.get(i).getShAddress() == null ? infoAddressService.getById(orlist.get(i).getShdzId()) : JSONObject.parseObject(orlist.get(i).getShAddress()));
  812. org.put("user", infoUserService.getById(orlist.get(i).getUserId()));
  813. org.put("qishou", infoUserService.getById(orlist.get(i).getQsId()));
  814. org.put("amount", orlist.get(i).getAmount());
  815. org.put("kefuState", orlist.get(i).getKefuState());
  816. org.put("kefuContent", orlist.get(i).getKefuContent());
  817. org.put("kefuRepeat", orlist.get(i).getKefuRepeat());
  818. org.put("repeatDdId", orlist.get(i).getRepeatDdId());
  819. org.put("remarks", orlist.get(i).getRemarks());
  820. org.put("state", orlist.get(i).getState());
  821. org.put("type", orlist.get(i).getType());
  822. org.put("jvli", orlist.get(i).getJvli());
  823. org.put("freight", orlist.get(i).getFreight());
  824. org.put("delryTime", orlist.get(i).getDelryTime());
  825. org.put("diningStatus", orlist.get(i).getDiningStatus());
  826. org.put("food", JSONArray.parseArray(orlist.get(i).getFood()));
  827. org.put("collectPayment", orlist.get(i).getCollectPayment());
  828. // org.put("activity",salesPromotionService.getById(orlist.get(i).getActivity()));
  829. org.put("sqImg", orlist.get(i).getQsImg());
  830. // org.put("discountAmount",orlist.get(i).getDiscountAmount());
  831. org.put("activity", orlist.get(i).getActivity());
  832. org.put("mdActivity", orlist.get(i).getMdActivity());
  833. org.put("salesReduction", orlist.get(i).getSalesReduction());
  834. org.put("mdSalesReduction", orlist.get(i).getMdSalesReduction());
  835. org.put("salesName", orlist.get(i).getSalesName());
  836. org.put("mdSalesName", orlist.get(i).getMdSalesName());
  837. org.put("mdDiscountAmount", orlist.get(i).getMdDiscountAmount());
  838. org.put("discountAmount", orlist.get(i).getDiscountAmount());
  839. org.put("mdYhId", orlist.get(i).getMdYhId());
  840. org.put("mdYhName", orlist.get(i).getMdYhName());
  841. org.put("yhId", orlist.get(i).getYhId());
  842. org.put("yhName", orlist.get(i).getYhName());
  843. org.put("points", orlist.get(i).getPoints());
  844. org.put("pointsReduction", orlist.get(i).getPointsReduction());
  845. org.put("sdTime", orlist.get(i).getSdTime());
  846. org.put("payType", orlist.get(i).getPayType());
  847. arr.add(org);
  848. }
  849. return success(arr);
  850. }
  851. //查询商家的订单
  852. @Anonymous
  853. @Auth
  854. @GetMapping("/getstoreorderlist")
  855. public AjaxResult getstoreorderlist(@RequestHeader String token, @RequestParam Integer page, @RequestParam Integer size, @RequestParam String mdId, @RequestParam(defaultValue = "") String state, @RequestParam(defaultValue = "") String diningStatus) {
  856. JwtUtil jwtUtil = new JwtUtil();
  857. String id = jwtUtil.getusid(token);
  858. IPage<PosOrder> palist = new Page<>(page, size);
  859. QueryWrapper<PosOrder> queryWrapper = new QueryWrapper<>();
  860. queryWrapper.select().orderByDesc("cretim");
  861. queryWrapper.eq("sh_id", id);
  862. System.out.println("商户id:" + id);
  863. queryWrapper.eq("md_id", mdId);
  864. if (!"".equals(state)) {
  865. if (state.equals("z01")) {
  866. queryWrapper.eq("state", 0).and(posOrderQueryWrapper -> posOrderQueryWrapper.eq("collect_payment", "1")).and(posOrderQueryWrapper -> posOrderQueryWrapper.eq("type", 1)).or().eq("state", 1).and(posOrderQueryWrapper -> posOrderQueryWrapper.eq("sh_id", id)).and(posOrderQueryWrapper -> posOrderQueryWrapper.eq("md_id", mdId));
  867. } else if (state.equals("z234")) {
  868. queryWrapper.in("state", 2, 3, 4);
  869. } else if (state.equals("z23")) {
  870. queryWrapper.in("state", 2, 3);
  871. } else if (state.equals("z34")) {
  872. queryWrapper.in("state", 3, 4);
  873. } else if (state.equals("z678911")) {
  874. queryWrapper.in("state", 6, 7, 8, 9, 11);
  875. } else {
  876. queryWrapper.eq("state", state);
  877. }
  878. }
  879. if (!"".equals(diningStatus)) {
  880. queryWrapper.eq("dining_status", diningStatus);
  881. }
  882. IPage<PosOrder> list = posOrderService.page(palist, queryWrapper);
  883. List<PosOrder> orlist = list.getRecords();
  884. JSONArray arr = new JSONArray();
  885. for (int i = 0; i < orlist.size(); i++) {
  886. JSONObject org = new JSONObject();
  887. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  888. org.put("id", orlist.get(i).getId());
  889. org.put("ddId", orlist.get(i).getDdId());
  890. org.put("shanghu", infoUserService.getById(orlist.get(i).getShId()));
  891. org.put("store", posStoreService.getById(orlist.get(i).getMdId()));
  892. org.put("cretim", sdf.format(orlist.get(i).getCretim()));
  893. org.put("shdzId", orlist.get(i).getShdzId());
  894. org.put("shaddress", orlist.get(i).getShAddress() == null ? infoAddressService.getById(orlist.get(i).getShdzId()) : JSONObject.parseObject(orlist.get(i).getShAddress()));
  895. org.put("user", infoUserService.getById(orlist.get(i).getUserId()));
  896. org.put("amount", orlist.get(i).getAmount());
  897. org.put("kefuState", orlist.get(i).getKefuState());
  898. org.put("kefuContent", orlist.get(i).getKefuContent());
  899. org.put("kefuRepeat", orlist.get(i).getKefuRepeat());
  900. org.put("repeatDdId", orlist.get(i).getRepeatDdId());
  901. org.put("remarks", orlist.get(i).getRemarks());
  902. org.put("state", orlist.get(i).getState());
  903. org.put("type", orlist.get(i).getType());
  904. org.put("jvli", orlist.get(i).getJvli());
  905. org.put("freight", orlist.get(i).getFreight());
  906. org.put("delryTime", orlist.get(i).getDelryTime());
  907. org.put("diningStatus", orlist.get(i).getDiningStatus());
  908. org.put("collectPayment", orlist.get(i).getCollectPayment());
  909. org.put("discountAmount", orlist.get(i).getDiscountAmount());
  910. org.put("food", JSONArray.parseArray(orlist.get(i).getFood()));
  911. org.put("activity", orlist.get(i).getActivity());
  912. org.put("mdActivity", orlist.get(i).getMdActivity());
  913. org.put("salesReduction", orlist.get(i).getSalesReduction());
  914. org.put("mdSalesReduction", orlist.get(i).getMdSalesReduction());
  915. org.put("salesName", orlist.get(i).getSalesName());
  916. org.put("mdSalesName", orlist.get(i).getMdSalesName());
  917. org.put("mdDiscountAmount", orlist.get(i).getMdDiscountAmount());
  918. org.put("discountAmount", orlist.get(i).getDiscountAmount());
  919. org.put("mdYhId", orlist.get(i).getMdYhId());
  920. org.put("mdYhName", orlist.get(i).getMdYhName());
  921. org.put("yhId", orlist.get(i).getYhId());
  922. org.put("yhName", orlist.get(i).getYhName());
  923. org.put("points", orlist.get(i).getPoints());
  924. org.put("pointsReduction", orlist.get(i).getPointsReduction());
  925. org.put("sdTime", orlist.get(i).getSdTime());
  926. org.put("payType", orlist.get(i).getPayType());
  927. arr.add(org);
  928. }
  929. return success(arr);
  930. }
  931. //查询用户的订单
  932. @Anonymous
  933. @Auth
  934. @GetMapping("/getorderlist")
  935. public AjaxResult getorderlist(@RequestHeader String token, @RequestParam Integer page, @RequestParam Integer size, @RequestParam(defaultValue = "") String state) {
  936. JwtUtil jwtUtil = new JwtUtil();
  937. String id = jwtUtil.getusid(token);
  938. IPage<PosOrder> palist = new Page<>(page, size);
  939. QueryWrapper<PosOrder> queryWrapper = new QueryWrapper<>();
  940. queryWrapper.select().orderByDesc("cretim");
  941. queryWrapper.eq("user_id", id);
  942. if (!"".equals(state)) {
  943. if (state.equals("z23412")) {
  944. queryWrapper.in("state", 2, 3, 4, 12);
  945. } else if (state.equals("z23")) {
  946. queryWrapper.in("state", 2, 3);
  947. } else if (state.equals("z34")) {
  948. queryWrapper.in("state", 3, 4);
  949. } else if (state.equals("z678911")) {
  950. queryWrapper.in("state", 6, 7, 8, 9, 11);
  951. } else {
  952. queryWrapper.eq("state", state);
  953. }
  954. }
  955. // 添加排除条件:state=0且collect_payment=0的数据
  956. queryWrapper.apply("NOT (state = 0 AND collect_payment = 0)");
  957. IPage<PosOrder> list = posOrderService.page(palist, queryWrapper);
  958. List<PosOrder> orlist = list.getRecords();
  959. List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect(Collectors.toList());
  960. List<OrderParent> orderParents =new ArrayList<>();
  961. if(!parentDdIds.isEmpty()){
  962. orderParents= orderParentService.list(new LambdaQueryWrapper<>(OrderParent.class).in(OrderParent::getDdId, parentDdIds));
  963. }
  964. JSONArray arr = new JSONArray();
  965. for (int i = 0; i < orlist.size(); i++) {
  966. JSONObject org = new JSONObject();
  967. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  968. org.put("id", orlist.get(i).getId());
  969. org.put("ddId", orlist.get(i).getDdId().toString());
  970. org.put("shanghu", infoUserService.getById(orlist.get(i).getShId()));
  971. org.put("store", posStoreService.getById(orlist.get(i).getMdId()));
  972. org.put("cretim", sdf.format(orlist.get(i).getCretim()));
  973. org.put("shdzId", orlist.get(i).getShdzId());
  974. org.put("shaddress", orlist.get(i).getShAddress() == null ? infoAddressService.getById(orlist.get(i).getShdzId()) : JSONObject.parseObject(orlist.get(i).getShAddress()));
  975. org.put("user", infoUserService.getById(orlist.get(i).getUserId()));
  976. org.put("amount", orlist.get(i).getAmount());
  977. org.put("kefuState", orlist.get(i).getKefuState());
  978. org.put("kefuContent", orlist.get(i).getKefuContent());
  979. org.put("kefuRepeat", orlist.get(i).getKefuRepeat());
  980. org.put("repeatDdId", orlist.get(i).getRepeatDdId());
  981. org.put("remarks", orlist.get(i).getRemarks());
  982. org.put("state", orlist.get(i).getState());
  983. org.put("type", orlist.get(i).getType());
  984. org.put("jvli", orlist.get(i).getJvli());
  985. org.put("freight", orlist.get(i).getFreight());
  986. org.put("delryTime", orlist.get(i).getDelryTime());
  987. org.put("payUrl", orlist.get(i).getPayUrl());
  988. org.put("collectPayment", orlist.get(i).getCollectPayment());
  989. org.put("food", JSONArray.parseArray(orlist.get(i).getFood()));
  990. // org.put("activity",salesPromotionService.getById(orlist.get(i).getActivity()));
  991. org.put("activity", orlist.get(i).getActivity());
  992. org.put("mdActivity", orlist.get(i).getMdActivity());
  993. org.put("salesReduction", orlist.get(i).getSalesReduction());
  994. org.put("mdSalesReduction", orlist.get(i).getMdSalesReduction());
  995. org.put("salesName", orlist.get(i).getSalesName());
  996. org.put("mdSalesName", orlist.get(i).getMdSalesName());
  997. org.put("mdDiscountAmount", orlist.get(i).getMdDiscountAmount());
  998. org.put("discountAmount", orlist.get(i).getDiscountAmount());
  999. org.put("mdYhId", orlist.get(i).getMdYhId());
  1000. org.put("mdYhName", orlist.get(i).getMdYhName());
  1001. org.put("yhId", orlist.get(i).getYhId());
  1002. org.put("yhName", orlist.get(i).getYhName());
  1003. org.put("points", orlist.get(i).getPoints());
  1004. org.put("pointsReduction", orlist.get(i).getPointsReduction());
  1005. org.put("sdTime", orlist.get(i).getSdTime());
  1006. org.put("payType", orlist.get(i).getPayType());
  1007. int finalI = i;
  1008. org.put("parentRemarks","");
  1009. if(StringUtils.isNotEmpty(orlist.get(i).getParentDdId())){
  1010. orderParents.stream().filter(item->item.getDdId().equals(orlist.get(finalI).getParentDdId())).findFirst().ifPresent(a-> org.put("parentRemarks",a.getRemarks()));
  1011. }
  1012. arr.add(org);
  1013. }
  1014. return success(arr);
  1015. }
  1016. // @Anonymous
  1017. // @GetMapping("/sssaaaa")
  1018. // public AjaxResult sssaaaa(@RequestParam String aa,@RequestParam String bb){
  1019. // DateUtil dateUtil = new DateUtil();
  1020. // Boolean sbsj = dateUtil.isLegalTime(aa,bb);
  1021. // return success(sbsj);
  1022. // }
  1023. //添加新订单
  1024. @SneakyThrows
  1025. @Anonymous
  1026. @Auth
  1027. @RepeatSubmit(interval = 1000, message = "请求过于频繁")
  1028. @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
  1029. @PostMapping("/addorder")
  1030. public AjaxResult addorder(@RequestHeader String token, @RequestBody OrderDTO orderDTO) {
  1031. long methodStart = System.currentTimeMillis(); // 记录方法开始时间
  1032. ObjectMapper mapper = new ObjectMapper();
  1033. mapper.enable(SerializationFeature.INDENT_OUTPUT);
  1034. Integer xiadanjiaoyan = orderDTO.getXiadanjiaoyan();
  1035. if (xiadanjiaoyan == null || !xiadanjiaoyan.equals(2)) {
  1036. return error(MessageUtils.message("no.xiadanyz.message"));
  1037. }
  1038. System.out.println("========== 接收到的orderDTO ==========");
  1039. System.out.println(mapper.writeValueAsString(orderDTO));
  1040. JwtUtil jwtUtil = new JwtUtil();
  1041. PayPush push = new PayPush();
  1042. DateUtil dateUtil = new DateUtil();
  1043. String id = jwtUtil.getusid(token);
  1044. QueryWrapper<OperatingHours> wrapper = new QueryWrapper<>();
  1045. wrapper.eq("md_id", orderDTO.getMdId());
  1046. List<OperatingHours> hourslist = operatingHoursService.list(wrapper);
  1047. PosStore store = posStoreService.getById(orderDTO.getMdId());
  1048. JSONObject usdizhi = new JSONObject();
  1049. if (orderDTO.getType() != null && orderDTO.getType().equals(0L)) {
  1050. InfoAddress usadd = infoAddressService.getById(orderDTO.getShdzId());
  1051. if (usadd == null) {
  1052. return error(MessageUtils.message("no.address.not.exist"));
  1053. } else {
  1054. usdizhi.put("name", usadd.getName());
  1055. usdizhi.put("phone", usadd.getPhone());
  1056. usdizhi.put("address", usadd.getAddress());
  1057. usdizhi.put("country", usadd.getCountry());
  1058. usdizhi.put("province", usadd.getProvince());
  1059. usdizhi.put("city", usadd.getCity());
  1060. usdizhi.put("area", usadd.getArea());
  1061. usdizhi.put("longitude", String.valueOf(usadd.getLongitude()));
  1062. usdizhi.put("latitude", String.valueOf(usadd.getLatitude()));
  1063. }
  1064. }
  1065. if (hourslist.size() == 0) {
  1066. return error(MessageUtils.message("no.mendian.not.set.business.hours"));
  1067. }
  1068. if (store.getState() == 1) {
  1069. return error(MessageUtils.message("no.mendian.is.closed"));
  1070. }
  1071. Boolean dayang = false;
  1072. for (int i = 0; i < hourslist.size(); i++) {
  1073. Boolean sbsj = dateUtil.isLegalTime(hourslist.get(i).getStartTime(), hourslist.get(i).getEndTime());
  1074. if (sbsj == true) {
  1075. dayang = true;
  1076. }
  1077. }
  1078. if (dayang == false) {
  1079. return error(MessageUtils.message("no.mendian.is.closed"));
  1080. }
  1081. //订单金额限制100万改为200万
  1082. if (orderDTO.getCollectPayment().equals("1") && orderDTO.getAmount() > 2000000) {
  1083. return error(MessageUtils.message("no.cash_on_delivery_amount.exceed.limit_amount"));
  1084. }
  1085. QueryWrapper<PosOrder> query = new QueryWrapper<>();
  1086. query.eq("user_id", id);
  1087. query.eq("collect_payment", "1");
  1088. query.notIn("state", 5, 10, 11);
  1089. List<PosOrder> posOrders = posOrderService.list(query);
  1090. System.out.println("到付信息:user_id=" + id + " ,到付数量:" + posOrders.size());
  1091. //到付能存在2单未完成,第3单弹出提示
  1092. if (posOrders.size() >= 2 && orderDTO.getCollectPayment().equals("1")) {
  1093. return error(MessageUtils.message("no.exist.cash_on_delivery_order.incomplete"));
  1094. }
  1095. JSONArray jsonArray = orderDTO.getFoodlist();
  1096. Map<Long,Long> map = new HashMap<>();
  1097. for (int i = 0; i < jsonArray.size(); i++) {
  1098. Long foodid = jsonArray.getJSONObject(i).getLong("id");
  1099. PosFood food = posFoodService.getById(foodid);
  1100. if (food == null) {
  1101. return error(jsonArray.getJSONObject(i).getString("name") + MessageUtils.message("no.goods.not.exist"));
  1102. } else {
  1103. if (food.getStackingUp().equals("1")) {
  1104. return error(food.getName() + MessageUtils.message("no.goods.is.off.shelf"));
  1105. }
  1106. }
  1107. Long num = jsonArray.getJSONObject(i).getLong("number");
  1108. map.put(foodid,num);
  1109. }
  1110. VipUserQuanyi yh = null;
  1111. VipUserQuanyi mdYh = null;
  1112. if (ObjectUtil.isNotNull(orderDTO.getYhId()) && ObjectUtil.notEqual(orderDTO.getYhId(), 0L)) {
  1113. LambdaQueryWrapper<VipUserQuanyi> yhQuery = new LambdaQueryWrapper<>();
  1114. yhQuery.eq(VipUserQuanyi::getId, orderDTO.getYhId());
  1115. yh = userQuanyiService.getOne(yhQuery);
  1116. if (yh == null) {
  1117. throw new ServiceException("no.userquanyi.not.exist");
  1118. }
  1119. if (yh.getState().equals("1")) {
  1120. throw new ServiceException("userquanyi.isUsed");
  1121. }
  1122. }
  1123. if (ObjectUtil.isNotNull(orderDTO.getMdYhId()) && ObjectUtil.notEqual(orderDTO.getMdYhId(), 0L)) {
  1124. LambdaQueryWrapper<VipUserQuanyi> mdYhquery = new LambdaQueryWrapper<>();
  1125. mdYhquery.eq(VipUserQuanyi::getId, orderDTO.getMdYhId());
  1126. mdYh = userQuanyiService.getOne(mdYhquery);
  1127. if (mdYh == null) {
  1128. throw new ServiceException("no.userquanyi.not.exist");
  1129. }
  1130. if (mdYh.getState().equals("1")) {
  1131. throw new ServiceException("userquanyi.isUsed");
  1132. }
  1133. }
  1134. SalesPromotion activity = null;
  1135. SalesPromotion mdActivity = null;
  1136. if (ObjectUtil.isNotNull(orderDTO.getActivity()) && ObjectUtil.notEqual(orderDTO.getActivity(), 0L)) {
  1137. LambdaQueryWrapper<SalesPromotion> saleQuery = new LambdaQueryWrapper<>();
  1138. saleQuery.eq(SalesPromotion::getId, orderDTO.getActivity());
  1139. activity = salesPromotionService.getOne(saleQuery);
  1140. if (activity == null) {
  1141. throw new ServiceException("no.activity.not.exist");
  1142. }
  1143. // if (yh.getState().equals("1")) {
  1144. // throw new ServiceException("userquanyi.isUsed");
  1145. // }
  1146. }
  1147. if (ObjectUtil.isNotNull(orderDTO.getMdActivity()) && ObjectUtil.notEqual(orderDTO.getMdActivity(), 0L)) {
  1148. LambdaQueryWrapper<SalesPromotion> saleQuery = new LambdaQueryWrapper<>();
  1149. saleQuery.eq(SalesPromotion::getId, orderDTO.getMdActivity());
  1150. mdActivity = salesPromotionService.getOne(saleQuery);
  1151. if (mdActivity == null) {
  1152. throw new ServiceException("no.activity.not.exist");
  1153. }
  1154. }
  1155. PosOrder posOrder = new PosOrder();
  1156. AjaxResult posOrderResult = redeePoints(orderDTO, Long.valueOf(id));
  1157. if (!posOrderResult.get("code").equals(200)) {
  1158. return posOrderResult;
  1159. } else {
  1160. posOrder.setPoints(orderDTO.getPoints());
  1161. posOrder.setPointsReduction(orderDTO.getPointsReduction());
  1162. }
  1163. posOrder.setDdId(orderDTO.getDdId());
  1164. posOrder.setShId(orderDTO.getShId());
  1165. posOrder.setMdId(orderDTO.getMdId());
  1166. posOrder.setShdzId(orderDTO.getShdzId());
  1167. posOrder.setShAddress(JSON.toJSONString(usdizhi));
  1168. posOrder.setUserId(Long.valueOf(id));
  1169. posOrder.setAmount(orderDTO.getAmount());
  1170. posOrder.setRemarks(orderDTO.getRemarks());
  1171. posOrder.setType(orderDTO.getType());
  1172. posOrder.setDelryTime(orderDTO.getDelryTime());
  1173. posOrder.setFood(jsonArray.toString());
  1174. posOrder.setState(0L);
  1175. posOrder.setJvli(orderDTO.getJvli());
  1176. posOrder.setFreight(orderDTO.getFreight());
  1177. posOrder.setLongitude(orderDTO.getLongitude());
  1178. posOrder.setLatitude(orderDTO.getLatitude());
  1179. posOrder.setDiningStatus(orderDTO.getDiningStatus());
  1180. posOrder.setQsId(orderDTO.getQsId());
  1181. posOrder.setJuli(orderDTO.getJuli());
  1182. posOrder.setPayUrl(orderDTO.getPayUrl());
  1183. posOrder.setCollectPayment(orderDTO.getCollectPayment());
  1184. // posOrder.setCretim(dateUtil.getDatetim(orderDTO.getCretim()));
  1185. //创建时间改成后端生成
  1186. posOrder.setCretim(new Date());
  1187. if (yh != null) {
  1188. posOrder.setYhName(yh.getName());
  1189. posOrder.setYhId(orderDTO.getYhId());
  1190. posOrder.setDiscountAmount(orderDTO.getDiscountAmount());
  1191. }
  1192. if (mdYh != null) {
  1193. posOrder.setMdYhId(orderDTO.getMdYhId());
  1194. posOrder.setMdYhName(mdYh.getName());
  1195. posOrder.setMdDiscountAmount(orderDTO.getMdDiscountAmount());
  1196. }
  1197. if (mdActivity != null) {
  1198. posOrder.setMdActivity(orderDTO.getMdActivity());
  1199. posOrder.setMdSalesName(mdActivity.getSalesName());
  1200. posOrder.setMdSalesReduction(orderDTO.getMdSalesReduction());
  1201. }
  1202. if (activity != null) {
  1203. posOrder.setActivity(orderDTO.getActivity());
  1204. posOrder.setSalesName(activity.getSalesName());
  1205. posOrder.setSalesReduction(orderDTO.getSalesReduction());
  1206. }
  1207. //设置支付类型为货到付款
  1208. if ("1".equals(posOrder.getCollectPayment())) {
  1209. posOrder.setPayType("1");
  1210. }
  1211. Boolean org = posOrderService.saveOrUpdate(posOrder);
  1212. foodStatistics(map);
  1213. if (org) {
  1214. QueryWrapper<UserBilling> queryWrapper = new QueryWrapper<>();
  1215. queryWrapper.eq("user_id", id);
  1216. queryWrapper.eq("dd_id", posOrder.getDdId());
  1217. UserBilling billing = userBillingService.getOne(queryWrapper);
  1218. if (billing == null) {
  1219. UserBilling usb = new UserBilling();
  1220. usb.setUserId(Long.valueOf(id));
  1221. usb.setDdId(String.valueOf(posOrder.getDdId()));
  1222. usb.setMdId(posOrder.getMdId());
  1223. usb.setState("3");
  1224. usb.setType("3");
  1225. userBillingService.saveOrUpdate(usb);
  1226. }
  1227. QueryWrapper<UserFootprint> Wrapper = new QueryWrapper<>();
  1228. Wrapper.eq("user_id", id);
  1229. Wrapper.eq("md_id", posOrder.getMdId());
  1230. UserFootprint foot = userFootprintService.getOne(Wrapper);
  1231. DateUtil dateString = new DateUtil();
  1232. if (foot == null) {
  1233. UserFootprint usf = new UserFootprint();
  1234. usf.setUserId(Long.valueOf(id));
  1235. usf.setMdId(posOrder.getMdId());
  1236. usf.setCretim(dateString.GetDate());
  1237. userFootprintService.saveOrUpdate(usf);
  1238. } else {
  1239. foot.setCretim(dateString.GetDate());
  1240. userFootprintService.saveOrUpdate(foot);
  1241. }
  1242. QueryWrapper<PosOrder> querywra = new QueryWrapper<>();
  1243. querywra.eq("dd_id", posOrder.getDdId());
  1244. PosOrder order = posOrderService.getOne(querywra);
  1245. //货到付款、类型外卖,推送给骑手有新订单了
  1246. if (order.getCollectPayment().equals("1") && order.getType() == 0) {
  1247. sendHdfkMessage(order, push);
  1248. }
  1249. //存在使用优惠券的话,核销优惠券
  1250. redeemCoupons(yh, mdYh, order.getDdId());
  1251. System.out.println("========== 输出的order ==========");
  1252. System.out.println(mapper.writeValueAsString(order));
  1253. long methodEnd = System.currentTimeMillis(); // 方法结束时间
  1254. System.out.println("addorder 方法总执行耗时: " + (methodEnd - methodStart) + " ms");
  1255. return success(MessageUtils.message("no.order.submit.success"), order);
  1256. } else {
  1257. long methodEnd = System.currentTimeMillis(); // 方法结束时间
  1258. System.out.println("addorder 方法总执行耗时: " + (methodEnd - methodStart) + " ms");
  1259. return error();
  1260. }
  1261. }
  1262. //统计美食销售量
  1263. private void foodStatistics(Map<Long,Long> map) {
  1264. for (Map.Entry<Long, Long> entry : map.entrySet()) {
  1265. Long key = entry.getKey();
  1266. Long value = entry.getValue();
  1267. // 使用数据库原子UPSERT,避免并发下的竞态问题
  1268. foodStatisticsService.increaseNumber(key, value);
  1269. }
  1270. }
  1271. /**
  1272. * 货到付款发送推送
  1273. *
  1274. * @param order
  1275. * @param push
  1276. */
  1277. private void sendHdfkMessage(PosOrder order, PayPush push) {
  1278. InfoUser sh = infoUserService.getById(order.getShId());
  1279. push.shpush(sh.getCid(), MessageUtils.message("no.message.push.message"), MessageUtils.message("no.message.push.new.order"), OrderPushBodyDto.getJson(String.valueOf(order.getDdId()), String.valueOf(order.getState()), 0));
  1280. pushEventService.PublisherEvent(sh.getUserId(), MessageUtils.message("no.message.push.message"), MessageUtils.message("no.message.push.new.order"), OrderPushBodyDto.getJson(String.valueOf(order.getDdId()), String.valueOf(order.getState()), 0));
  1281. long sendQsPushStart = System.currentTimeMillis(); // sendQsPush 开始时间
  1282. if (order.getType() == 0) {
  1283. sendQsPush(order, push);
  1284. }
  1285. long sendQsPushEnd = System.currentTimeMillis(); // sendQsPush 结束时间
  1286. System.out.println("sendQsPush 执行耗时: " + (sendQsPushEnd - sendQsPushStart) + " ms");
  1287. }
  1288. /**
  1289. * 推送可接单骑手
  1290. *
  1291. * @param order
  1292. * @param push
  1293. */
  1294. protected void sendQsPush(PosOrder order, PayPush push) {
  1295. payController.sendAcceptRiderPush(order, push, riderPositionMapper, OrderPushBodyDto.getJson(String.valueOf(order.getDdId()), String.valueOf(order.getState()), 0));
  1296. }
  1297. //核销积分
  1298. private AjaxResult redeePoints(OrderDTO orderDTO, Long userId) {
  1299. if (ObjectUtil.isNotNull(orderDTO.getPoints()) && ObjectUtil.notEqual(orderDTO.getPoints(), 0) && ObjectUtil.isNotNull(orderDTO.getPointsReduction()) && ObjectUtil.notEqual(orderDTO.getPointsReduction(), 0)) {
  1300. SysPointControl control = pointControlService.getById(1L);
  1301. if (!control.getOrderUseEnable().equals(1L)) {
  1302. throw new ServiceException(MessageUtils.message("no.points.use.enable"));
  1303. }
  1304. LambdaQueryWrapper<UserWallet> walletQuery = new LambdaQueryWrapper<>();
  1305. walletQuery.eq(UserWallet::getUserId, userId);
  1306. UserWallet userWallet = userWalletService.getOne(walletQuery);
  1307. if (ObjectUtil.isNotNull(userWallet)) {
  1308. if (userWallet.getPointsWallet().compareTo(Long.valueOf(orderDTO.getPoints())) >= 0) {
  1309. walletQuery.eq(UserWallet::getVersion, userWallet.getVersion());
  1310. userWallet.setPointsWallet(userWallet.getPointsWallet() - orderDTO.getPoints());
  1311. userWallet.setVersion(userWallet.getVersion() + 1);
  1312. boolean update = userWalletService.update(userWallet, walletQuery);
  1313. createPointTransaction(userId, Long.valueOf(orderDTO.getPoints()), userWallet.getPointsWallet(), orderDTO.getDdId().toString(), "1");
  1314. if (!update) {
  1315. throw new ServiceException(MessageUtils.message("no.points.update.fail"));
  1316. }
  1317. } else {
  1318. throw new ServiceException(MessageUtils.message("no.points.insufficient"));
  1319. }
  1320. } else {
  1321. throw new ServiceException(MessageUtils.message("no.points.not.exist"));
  1322. }
  1323. }
  1324. return success();
  1325. }
  1326. /**
  1327. * 创建积分流水
  1328. */
  1329. private void createPointTransaction(Long userid, Long pointsChange, Long currentPoints, String ddId, String type) {
  1330. PointsTransaction pointsTransaction = new PointsTransaction();
  1331. pointsTransaction.setUserId(userid);
  1332. if (type.equals("1")) {
  1333. pointsTransaction.setPointsChange("-" + pointsChange);
  1334. pointsTransaction.setType("1");
  1335. }
  1336. if (type.equals("2")) {
  1337. pointsTransaction.setPointsChange("+" + pointsChange);
  1338. pointsTransaction.setType("2");
  1339. }
  1340. pointsTransaction.setCurrentPoints(currentPoints.toString());
  1341. pointsTransaction.setDdId(ddId);
  1342. pointsTransaction.setCreateTime(new Date());
  1343. pointsTransactionService.save(pointsTransaction);
  1344. }
  1345. /**
  1346. * 核销优惠券
  1347. *
  1348. * @param orderId
  1349. */
  1350. private void redeemCoupons(VipUserQuanyi yh, VipUserQuanyi mdYh, Long orderId) {
  1351. if (ObjectUtil.isNotNull(yh)) {
  1352. yh.setState("1");
  1353. yh.setOrderId(String.valueOf(orderId));
  1354. yh.setUpdateTime(new Date());
  1355. userQuanyiService.saveOrUpdate(yh);
  1356. }
  1357. if (ObjectUtil.isNotNull(mdYh)) {
  1358. mdYh.setState("1");
  1359. mdYh.setOrderId(String.valueOf(orderId));
  1360. mdYh.setUpdateTime(new Date());
  1361. userQuanyiService.saveOrUpdate(mdYh);
  1362. }
  1363. }
  1364. /**
  1365. * 核销优惠券
  1366. *
  1367. * @param orderId
  1368. */
  1369. private void redeemCoupons(VipUserQuanyi yh, VipUserQuanyi mdYh, String orderId) {
  1370. if (ObjectUtil.isNotNull(yh)) {
  1371. yh.setState("1");
  1372. yh.setOrderId(orderId);
  1373. yh.setUpdateTime(new Date());
  1374. userQuanyiService.saveOrUpdate(yh);
  1375. }
  1376. if (ObjectUtil.isNotNull(mdYh)) {
  1377. mdYh.setState("1");
  1378. mdYh.setOrderId(orderId);
  1379. mdYh.setUpdateTime(new Date());
  1380. userQuanyiService.saveOrUpdate(mdYh);
  1381. }
  1382. }
  1383. /**
  1384. * 查询posorder列表
  1385. */
  1386. @PreAuthorize("@ss.hasPermi('system:order:list')")
  1387. @GetMapping("/list")
  1388. public TableDataInfo list(PosOrder posOrder) {
  1389. startPage();
  1390. String[] dr = posOrder.getDateRange();
  1391. if (dr != null && dr.length == 2) {
  1392. posOrder.setCretimStart(dr[0]);
  1393. posOrder.setCretimEnd(dr[1]);
  1394. }
  1395. List<PosOrder> list = posOrderService.selectPosOrderList(posOrder);
  1396. if (list != null && list.size() > 0) {
  1397. for (PosOrder od : list) {
  1398. JSONArray foodArr = JSONArray.parseArray(od.getFood());
  1399. long priceAll = 0L;
  1400. for (int i = 0; i < foodArr.size(); i++) {
  1401. JSONObject obj = foodArr.getJSONObject(i);
  1402. BigDecimal price = obj.getBigDecimal("price");
  1403. if (price == null) continue;
  1404. Integer priceDb = price.intValue();
  1405. BigDecimal otherprice = obj.getBigDecimal("otherPrice");
  1406. if (otherprice != null && otherprice.doubleValue() > 0) {
  1407. priceDb += otherprice.intValue();
  1408. }
  1409. Long num = obj.getLong("number");
  1410. if (num == null) continue;
  1411. priceAll += (priceDb * num.longValue());
  1412. }
  1413. od.setPriceAll(priceAll + "");
  1414. Long atv = od.getActivity();
  1415. if (atv != null && atv.longValue() > 0) {
  1416. SalesPromotion salesPromotion = salesPromotionService.getById(atv);
  1417. if (salesPromotion != null) {
  1418. od.setSalesName(salesPromotion.getSalesName());
  1419. // od.setSalesReduction(""+salesPromotion.getSalesReduction());
  1420. }
  1421. }
  1422. }
  1423. }
  1424. return getDataTable(list);
  1425. }
  1426. /**
  1427. * 查询sh posorder列表
  1428. */
  1429. @PreAuthorize("@ss.hasPermi('system:order:shlist1')")
  1430. @GetMapping("/shlist1")
  1431. public TableDataInfo shlist1(PosOrder posOrder) {
  1432. startPage();
  1433. String[] dr = posOrder.getDateRange();
  1434. if (dr != null && dr.length == 2) {
  1435. posOrder.setCretimStart(dr[0]);
  1436. posOrder.setCretimEnd(dr[1]);
  1437. }
  1438. List<PosOrder> list = posOrderService.selectPosOrderShList(posOrder);
  1439. if (list != null && list.size() > 0) {
  1440. for (PosOrder od : list) {
  1441. //查询用户留言
  1442. PosAppeal posAppeal = new PosAppeal();
  1443. posAppeal.setDdId(od.getDdId());
  1444. posAppeal.setUserType("0");
  1445. List<PosAppeal> aplist = posAppealService.selectPosAppealList(posAppeal);
  1446. int s = 0;
  1447. if (aplist != null) s = aplist.size();
  1448. od.setAppealCount(s + "");
  1449. }
  1450. }
  1451. return getDataTable(list);
  1452. }
  1453. /**
  1454. * 查询sh posorder列表
  1455. */
  1456. @PreAuthorize("@ss.hasPermi('system:order:shlist2')")
  1457. @GetMapping("/shlist2")
  1458. public TableDataInfo shlist2(PosOrder posOrder) {
  1459. startPage();
  1460. String[] dr = posOrder.getDateRange();
  1461. if (dr != null && dr.length == 2) {
  1462. posOrder.setCretimStart(dr[0]);
  1463. posOrder.setCretimEnd(dr[1]);
  1464. }
  1465. List<PosOrder> list = posOrderService.selectPosOrderShList(posOrder);
  1466. if (list != null && list.size() > 0) {
  1467. for (PosOrder od : list) {
  1468. //查询用户留言
  1469. PosAppeal posAppeal = new PosAppeal();
  1470. posAppeal.setDdId(od.getDdId());
  1471. posAppeal.setUserType("1");
  1472. List<PosAppeal> aplist = posAppealService.selectPosAppealList(posAppeal);
  1473. int s = 0;
  1474. if (aplist != null) s = aplist.size();
  1475. od.setAppealCount(s + "");
  1476. }
  1477. }
  1478. return getDataTable(list);
  1479. }
  1480. /**
  1481. * 查询sh posorder列表
  1482. */
  1483. @PreAuthorize("@ss.hasPermi('system:order:shlist3')")
  1484. @GetMapping("/shlist3")
  1485. public TableDataInfo shlist3(PosOrder posOrder) {
  1486. startPage();
  1487. String[] dr = posOrder.getDateRange();
  1488. if (dr != null && dr.length == 2) {
  1489. posOrder.setCretimStart(dr[0]);
  1490. posOrder.setCretimEnd(dr[1]);
  1491. }
  1492. List<PosOrder> list = posOrderService.selectPosOrderShList(posOrder);
  1493. if (list != null && list.size() > 0) {
  1494. for (PosOrder od : list) {
  1495. //查询用户留言
  1496. PosAppeal posAppeal = new PosAppeal();
  1497. posAppeal.setDdId(od.getDdId());
  1498. posAppeal.setUserType("2");
  1499. List<PosAppeal> aplist = posAppealService.selectPosAppealList(posAppeal);
  1500. int s = 0;
  1501. if (aplist != null) s = aplist.size();
  1502. od.setAppealCount(s + "");
  1503. }
  1504. }
  1505. return getDataTable(list);
  1506. }
  1507. /**
  1508. * 导出posorder列表
  1509. */
  1510. @PreAuthorize("@ss.hasPermi('system:order:export')")
  1511. @Log(title = "posorder", businessType = BusinessType.EXPORT)
  1512. @PostMapping("/export")
  1513. public void export(HttpServletResponse response, PosOrder posOrder) {
  1514. List<PosOrder> list = posOrderService.selectPosOrderList(posOrder);
  1515. if (list != null && list.size() > 0) {
  1516. for (PosOrder od : list) {
  1517. JSONArray foodArr = JSONArray.parseArray(od.getFood());
  1518. long priceAll = 0L;
  1519. for (int i = 0; i < foodArr.size(); i++) {
  1520. JSONObject obj = foodArr.getJSONObject(i);
  1521. BigDecimal price = obj.getBigDecimal("price");
  1522. if (price == null) continue;
  1523. Integer priceDb = price.intValue();
  1524. //商品规格价格
  1525. BigDecimal otherprice = obj.getBigDecimal("otherPrice");
  1526. if (otherprice != null && otherprice.doubleValue() > 0) {
  1527. priceDb += otherprice.intValue();
  1528. }
  1529. Long num = obj.getLong("number");
  1530. if (num == null) continue;
  1531. priceAll += (priceDb * num.longValue());
  1532. }
  1533. od.setPriceAll(priceAll + "");
  1534. Long atv = od.getActivity();
  1535. if (atv != null && atv.longValue() > 0) {
  1536. SalesPromotion salesPromotion = salesPromotionService.getById(atv);
  1537. if (salesPromotion != null) {
  1538. od.setSalesName(salesPromotion.getSalesName());
  1539. // od.setSalesReduction(""+salesPromotion.getSalesReduction());
  1540. }
  1541. }
  1542. }
  1543. }
  1544. ExcelUtil<PosOrder> util = new ExcelUtil<PosOrder>(PosOrder.class);
  1545. util.exportExcel(response, list, MessageUtils.message("no.export.excel.posorder"));
  1546. }
  1547. /**
  1548. * 获取posorder详细信息
  1549. */
  1550. @PreAuthorize("@ss.hasPermi('system:order:query')")
  1551. @GetMapping(value = "/{id}")
  1552. public AjaxResult getInfo(@PathVariable("id") Long id) {
  1553. return success(posOrderService.selectPosOrderById(id));
  1554. }
  1555. /**
  1556. * 新增posorder
  1557. */
  1558. @PreAuthorize("@ss.hasPermi('system:order:add')")
  1559. @Log(title = "posorder", businessType = BusinessType.INSERT)
  1560. @PostMapping
  1561. public AjaxResult add(@RequestBody PosOrder posOrder) {
  1562. return toAjax(posOrderService.insertPosOrder(posOrder));
  1563. }
  1564. /**
  1565. * 修改posorder
  1566. */
  1567. @Transactional(rollbackFor = Exception.class)
  1568. @PreAuthorize("@ss.hasPermi('system:order:edit')")
  1569. @Log(title = "posorder", businessType = BusinessType.UPDATE)
  1570. @PutMapping
  1571. public AjaxResult edit(@RequestBody PosOrder posOrder) {
  1572. //送达时间
  1573. if (posOrder.getState() == 12) {
  1574. posOrder.setSdTime(new Date());
  1575. }
  1576. if (posOrder.getState() == 7) {
  1577. QueryWrapper<UserBilling> wrapper = new QueryWrapper<>();
  1578. wrapper.eq("dd_id", posOrder.getId());
  1579. List<UserBilling> billing = userBillingService.list(wrapper);
  1580. for (int i = 0; i < billing.size(); i++) {
  1581. UserBilling user = new UserBilling();
  1582. user.setId(billing.get(i).getId());
  1583. user.setState("1");
  1584. userBillingService.saveOrUpdate(user);
  1585. }
  1586. //退款、作废退回积分
  1587. if ((posOrder.getState() == 7 || posOrder.getState() == 11) && posOrder.getPoints() != null && posOrder.getPoints() > 0) {
  1588. returnPoints(posOrder.getUserId(), Long.valueOf(posOrder.getDdId()), Long.valueOf(posOrder.getPoints()));
  1589. }
  1590. return toAjax(posOrderService.updatePosOrder(posOrder));
  1591. } else {
  1592. if (posOrder.getKefuState().intValue() == 1) {
  1593. posOrder.setState(5L);
  1594. }
  1595. return toAjax(posOrderService.updatePosOrder(posOrder));
  1596. }
  1597. }
  1598. /**
  1599. * 订单取消、退款成功返回积分
  1600. *
  1601. * @param userId
  1602. * @param ddId
  1603. * @param points
  1604. */
  1605. public void returnPoints(Long userId, Long ddId, Long points) {
  1606. LambdaQueryWrapper<UserWallet> walletQuery = new LambdaQueryWrapper<>();
  1607. walletQuery.eq(UserWallet::getUserId, userId);
  1608. UserWallet userWallet = userWalletService.getOne(walletQuery);
  1609. PointsTransaction transaction = pointsTransactionService.getOne(new LambdaQueryWrapper<PointsTransaction>().eq(PointsTransaction::getDdId, ddId.toString()).eq(PointsTransaction::getType, "2"));
  1610. //该订单不存在退回的积分记录
  1611. if (ObjectUtil.isNotNull(userWallet) && transaction == null) {
  1612. walletQuery.eq(UserWallet::getVersion, userWallet.getVersion());
  1613. userWallet.setPointsWallet(userWallet.getPointsWallet() + points);
  1614. userWallet.setVersion(userWallet.getVersion() + 1);
  1615. boolean update = userWalletService.update(userWallet, walletQuery);
  1616. createPointTransaction(userId, Long.valueOf(points), userWallet.getPointsWallet(), ddId.toString(), "2");
  1617. if (!update) {
  1618. throw new ServiceException(MessageUtils.message("no.points.update.fail"));
  1619. }
  1620. } else {
  1621. throw new ServiceException(MessageUtils.message("no.points.insufficient"));
  1622. }
  1623. }
  1624. /**
  1625. * 删除posorder
  1626. */
  1627. @PreAuthorize("@ss.hasPermi('system:order:remove')")
  1628. @Log(title = "posorder", businessType = BusinessType.DELETE)
  1629. @DeleteMapping("/{ids}")
  1630. public AjaxResult remove(@PathVariable Long[] ids) {
  1631. return toAjax(posOrderService.deletePosOrderByIds(ids));
  1632. }
  1633. /**
  1634. * 测试推送消息
  1635. *
  1636. * @param cid
  1637. * @return
  1638. */
  1639. @Anonymous
  1640. @RequestMapping(value = "/testPushMessage", method = {RequestMethod.GET})
  1641. public AjaxResult testPushMessage(String cid, String title, String content, String body) {
  1642. PayPush push = new PayPush();
  1643. push.qspush(cid, title, content, body);
  1644. return AjaxResult.success();
  1645. }
  1646. /**
  1647. * 获取配送中的订单位置信息
  1648. */
  1649. @Anonymous
  1650. @Auth
  1651. @GetMapping("/getPsOrdersPosition")
  1652. public AjaxResult getPsOrdersPosition(@RequestHeader String token) {
  1653. JwtUtil jwtUtil = new JwtUtil();
  1654. String id = jwtUtil.getusid(token);
  1655. List<OrderPositionInfo> result = new ArrayList<>();
  1656. QueryWrapper<PosOrder> wrapper = new QueryWrapper<>();
  1657. wrapper.eq("user_id", id).apply("(pay_type!=1 and (state = 1 or state = 2 or state = 3 or state = 4) or (pay_type=1 and (state = 0 or state = 1 or state = 2 or state = 3 or state = 4)))").orderByDesc("cretim");
  1658. List<PosOrder> list = posOrderService.list(wrapper);
  1659. if (!list.isEmpty()) {
  1660. List<Long> qsIds = list.stream().map(PosOrder::getQsId).collect(Collectors.toList());
  1661. List<InfoUser> users = new ArrayList<>();
  1662. if (!qsIds.isEmpty()) {
  1663. LambdaQueryWrapper<InfoUser> userWrapper = new LambdaQueryWrapper<>();
  1664. userWrapper.in(InfoUser::getUserId, qsIds);
  1665. users = infoUserService.list(userWrapper);
  1666. }
  1667. List<Long> mdIds = list.stream().map(PosOrder::getMdId).collect(Collectors.toList());
  1668. LambdaQueryWrapper<PosStore> mdWrapper = new LambdaQueryWrapper<PosStore>().in(PosStore::getId, mdIds);
  1669. List<PosStore> stores = posStoreService.list(mdWrapper);
  1670. List<RiderPosition> riderPositions = new ArrayList<>();
  1671. if (!qsIds.isEmpty()) {
  1672. riderPositions = riderPositionService.list(new LambdaQueryWrapper<RiderPosition>().in(RiderPosition::getRiderId, qsIds));
  1673. }
  1674. for (PosOrder posOrder : list) {
  1675. OrderPositionInfo orderPositionInfo = new OrderPositionInfo();
  1676. orderPositionInfo.setDdId(posOrder.getDdId());
  1677. orderPositionInfo.setOrderState(posOrder.getState());
  1678. orderPositionInfo.setDelryTime(posOrder.getDelryTime());
  1679. orderPositionInfo.setYjsdTime(posOrder.getYjsdTime());
  1680. orderPositionInfo.setDiningStatus(posOrder.getDiningStatus());
  1681. orderPositionInfo.setPayType(posOrder.getPayType());
  1682. if (posOrder.getQsId() != null) {
  1683. QsDto qsDto = new QsDto();
  1684. users.stream().filter(infoUser -> infoUser.getUserId().equals(posOrder.getQsId())).findFirst().ifPresent(user -> {
  1685. qsDto.setUserName(user.getUserName());
  1686. qsDto.setNickName(user.getNickName());
  1687. });
  1688. qsDto.setDelryTime(posOrder.getDelryTime());
  1689. orderPositionInfo.setQsInfo(qsDto);
  1690. PositionDto qsPosition = new PositionDto();
  1691. riderPositions.stream().filter(riderPosition -> riderPosition.getRiderId().equals(posOrder.getQsId())).findFirst().ifPresent(rPosition -> {
  1692. qsPosition.setLat(rPosition.getLatitude().toString());
  1693. qsPosition.setLng(rPosition.getLongitude().toString());
  1694. });
  1695. orderPositionInfo.setQsPosition(qsPosition);
  1696. }
  1697. PositionDto mdPosition = new PositionDto();
  1698. stores.stream().filter(posStore -> posStore.getId().equals(Integer.valueOf(posOrder.getMdId().toString()))).findFirst().ifPresent(p -> {
  1699. mdPosition.setLat(p.getLatitude().toString());
  1700. mdPosition.setLng(p.getLongitude().toString());
  1701. });
  1702. orderPositionInfo.setMdPosition(mdPosition);
  1703. Map map = JSON.parseObject(posOrder.getShAddress(), Map.class);
  1704. PositionDto userPosition = new PositionDto();
  1705. userPosition.setLat(map.get("latitude").toString());
  1706. userPosition.setLng(map.get("longitude").toString());
  1707. orderPositionInfo.setUserPosition(userPosition);
  1708. result.add(orderPositionInfo);
  1709. }
  1710. }
  1711. return AjaxResult.success(result);
  1712. }
  1713. }