|
@@ -8,8 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
-import com.fasterxml.jackson.databind.SerializationFeature;
|
|
|
|
|
import com.ruoyi.app.order.dto.OrderPositionInfo;
|
|
import com.ruoyi.app.order.dto.OrderPositionInfo;
|
|
|
import com.ruoyi.app.order.dto.OrderPushBodyDto;
|
|
import com.ruoyi.app.order.dto.OrderPushBodyDto;
|
|
|
import com.ruoyi.app.order.dto.PositionDto;
|
|
import com.ruoyi.app.order.dto.PositionDto;
|
|
@@ -25,7 +23,6 @@ import com.ruoyi.app.service.UserService;
|
|
|
import com.ruoyi.app.service.WalletService;
|
|
import com.ruoyi.app.service.WalletService;
|
|
|
import com.ruoyi.app.user.dto.StoreOutput;
|
|
import com.ruoyi.app.user.dto.StoreOutput;
|
|
|
import com.ruoyi.app.utils.DateUtil;
|
|
import com.ruoyi.app.utils.DateUtil;
|
|
|
-import com.ruoyi.app.utils.OperatingUtil;
|
|
|
|
|
import com.ruoyi.app.utils.PayPush;
|
|
import com.ruoyi.app.utils.PayPush;
|
|
|
import com.ruoyi.app.utils.event.PushEventService;
|
|
import com.ruoyi.app.utils.event.PushEventService;
|
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
@@ -41,7 +38,6 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.framework.manager.AsyncManager;
|
|
import com.ruoyi.framework.manager.AsyncManager;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.system.domain.*;
|
|
import com.ruoyi.system.domain.*;
|
|
|
-import com.ruoyi.system.domain.vo.OrderDTO;
|
|
|
|
|
import com.ruoyi.system.domain.vo.PosOrderInvoiceVo;
|
|
import com.ruoyi.system.domain.vo.PosOrderInvoiceVo;
|
|
|
import com.ruoyi.system.mapper.PosFoodMapper;
|
|
import com.ruoyi.system.mapper.PosFoodMapper;
|
|
|
import com.ruoyi.system.mapper.PosOrderMapper;
|
|
import com.ruoyi.system.mapper.PosOrderMapper;
|
|
@@ -58,14 +54,12 @@ import com.ruoyi.system.utils.OrderLogHelper;
|
|
|
import com.ruoyi.app.push.UserNotificationScene;
|
|
import com.ruoyi.app.push.UserNotificationScene;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
-import lombok.SneakyThrows;
|
|
|
|
|
import org.redisson.api.RLock;
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.transaction.annotation.Isolation;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.TransactionSynchronization;
|
|
import org.springframework.transaction.support.TransactionSynchronization;
|
|
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
@@ -91,7 +85,7 @@ import java.util.stream.Stream;
|
|
|
* <p>本类仍在用的:列表/详情查询(/getorderlist、/getstoreorderlist、/getqsorderlist、/getorderxq 等)、
|
|
* <p>本类仍在用的:列表/详情查询(/getorderlist、/getstoreorderlist、/getqsorderlist、/getorderxq 等)、
|
|
|
* 平台管理操作(/{id}/status、/{id}/line-refund、/{id}/offline-payment/confirm、/{id}/offline-refund/confirm 等
|
|
* 平台管理操作(/{id}/status、/{id}/line-refund、/{id}/offline-payment/confirm、/{id}/offline-refund/confirm 等
|
|
|
* Spring Security 权限接口)、平台改状态 /setorderuzt;
|
|
* Spring Security 权限接口)、平台改状态 /setorderuzt;
|
|
|
- * add/edit 及 /addorder 均已废弃(商家端下单走 PosOrderShOprateController /createOrder),仅保留备查,勿增量修改。
|
|
|
|
|
|
|
+ * add/edit 已废弃并仅保留备查;/addorder 已移除,商家端下单走 PosOrderShOprateController /createOrder。
|
|
|
*
|
|
*
|
|
|
* @author ruoyi
|
|
* @author ruoyi
|
|
|
* @date 2023-05-23
|
|
* @date 2023-05-23
|
|
@@ -108,11 +102,6 @@ public class PosOrderController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IPosStoreService posStoreService;
|
|
private IPosStoreService posStoreService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private StallQualificationGateService stallQualificationGateService;
|
|
|
|
|
- /** 支付方式闸门(031):商家建单与用户下单共用同一判定入口。 */
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private com.ruoyi.system.service.PaymentMethodGateService paymentMethodGateService;
|
|
|
|
|
- @Autowired
|
|
|
|
|
private IInfoAddressService infoAddressService;
|
|
private IInfoAddressService infoAddressService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserFootprintService userFootprintService;
|
|
private IUserFootprintService userFootprintService;
|
|
@@ -130,15 +119,9 @@ public class PosOrderController extends BaseController {
|
|
|
private ISalesPromotionService salesPromotionService;
|
|
private ISalesPromotionService salesPromotionService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IPosAppealService posAppealService;
|
|
private IPosAppealService posAppealService;
|
|
|
- @Autowired //商品
|
|
|
|
|
- private IPosFoodService posFoodService;
|
|
|
|
|
- @Autowired //经营时间
|
|
|
|
|
- private IOperatingHoursService operatingHoursService;
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IVipUserQuanyiService userQuanyiService;
|
|
private IVipUserQuanyiService userQuanyiService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private ISysPointControlService pointControlService;
|
|
|
|
|
- @Autowired
|
|
|
|
|
private IUserWalletService userWalletService;
|
|
private IUserWalletService userWalletService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IPointsTransactionService pointsTransactionService;
|
|
private IPointsTransactionService pointsTransactionService;
|
|
@@ -154,8 +137,6 @@ public class PosOrderController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IPosOrderRatingService posOrderRatingService;
|
|
private IPosOrderRatingService posOrderRatingService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private IFoodStatisticsService foodStatisticsService;
|
|
|
|
|
- @Autowired
|
|
|
|
|
private IOrderParentService orderParentService;
|
|
private IOrderParentService orderParentService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WalletService walletService;
|
|
private WalletService walletService;
|
|
@@ -1100,278 +1081,7 @@ public class PosOrderController extends BaseController {
|
|
|
// Boolean sbsj = dateUtil.isLegalTime(aa,bb);
|
|
// Boolean sbsj = dateUtil.isLegalTime(aa,bb);
|
|
|
// return success(sbsj);
|
|
// return success(sbsj);
|
|
|
// }
|
|
// }
|
|
|
- //已废弃(2026-09-29 标注):商家端下单走 PosOrderShOprateController /createOrder;
|
|
|
|
|
- //本入口为旧代客外送下单流程(货到付款),保留备查勿增量修改(内含 031 支付闸门调用点,随入口一并废弃)
|
|
|
|
|
- @Deprecated
|
|
|
|
|
- @SneakyThrows
|
|
|
|
|
- @Anonymous
|
|
|
|
|
- @Auth
|
|
|
|
|
- @RepeatSubmit(interval = 1000, message = "请求过于频繁")
|
|
|
|
|
- @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
|
|
|
|
|
- @PostMapping("/addorder")
|
|
|
|
|
- public AjaxResult addorder(@RequestHeader String token, @RequestBody OrderDTO orderDTO) {
|
|
|
|
|
- long methodStart = System.currentTimeMillis(); // 记录方法开始时间
|
|
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
- mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
|
|
|
|
- Integer xiadanjiaoyan = orderDTO.getXiadanjiaoyan();
|
|
|
|
|
- if (xiadanjiaoyan == null || !xiadanjiaoyan.equals(2)) {
|
|
|
|
|
- return error(MessageUtils.message("no.xiadanyz.message"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- System.out.println("========== 接收到的orderDTO ==========");
|
|
|
|
|
- System.out.println(mapper.writeValueAsString(orderDTO));
|
|
|
|
|
- JwtUtil jwtUtil = new JwtUtil();
|
|
|
|
|
- DateUtil dateUtil = new DateUtil();
|
|
|
|
|
- String id = jwtUtil.getusid(token);
|
|
|
|
|
- QueryWrapper<OperatingHours> wrapper = new QueryWrapper<>();
|
|
|
|
|
- wrapper.eq("md_id", orderDTO.getMdId());
|
|
|
|
|
- List<OperatingHours> hourslist = operatingHoursService.list(wrapper);
|
|
|
|
|
- PosStore store = posStoreService.getById(orderDTO.getMdId());
|
|
|
|
|
- // 旧路由仍可调用,最小门禁防止从这里绕过摊位材料审核。
|
|
|
|
|
- stallQualificationGateService.requireApproved(store);
|
|
|
|
|
-
|
|
|
|
|
- JSONObject usdizhi = new JSONObject();
|
|
|
|
|
- if (orderDTO.getType() != null && orderDTO.getType().equals(0L)) {
|
|
|
|
|
- InfoAddress usadd = infoAddressService.getById(orderDTO.getShdzId());
|
|
|
|
|
- if (usadd == null) {
|
|
|
|
|
- return error(MessageUtils.message("no.address.not.exist"));
|
|
|
|
|
- } else {
|
|
|
|
|
- usdizhi.put("name", usadd.getName());
|
|
|
|
|
- usdizhi.put("phone", usadd.getPhone());
|
|
|
|
|
- usdizhi.put("address", usadd.getAddress());
|
|
|
|
|
- usdizhi.put("country", usadd.getCountry());
|
|
|
|
|
- usdizhi.put("province", usadd.getProvince());
|
|
|
|
|
- usdizhi.put("city", usadd.getCity());
|
|
|
|
|
- usdizhi.put("area", usadd.getArea());
|
|
|
|
|
- usdizhi.put("longitude", String.valueOf(usadd.getLongitude()));
|
|
|
|
|
- usdizhi.put("latitude", String.valueOf(usadd.getLatitude()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (hourslist.size() == 0) {
|
|
|
|
|
- return error(MessageUtils.message("no.mendian.not.set.business.hours"));
|
|
|
|
|
- }
|
|
|
|
|
- if (store.getState() == 1) {
|
|
|
|
|
- return error(MessageUtils.message("no.mendian.is.closed"));
|
|
|
|
|
- }
|
|
|
|
|
- //是否在上班时间内(按星期几和是否营业过滤)
|
|
|
|
|
- boolean isOperating = OperatingUtil.storeIsOperatingOfDay(hourslist);
|
|
|
|
|
- if (!isOperating) {
|
|
|
|
|
- return error(MessageUtils.message("no.mendian.is.closed"));
|
|
|
|
|
- }
|
|
|
|
|
- //订单金额限制100万改为200万
|
|
|
|
|
- if (orderDTO.getCollectPayment().equals("1") && orderDTO.getAmount() > 2000000) {
|
|
|
|
|
- return error(MessageUtils.message("no.cash_on_delivery_amount.exceed.limit_amount"));
|
|
|
|
|
- }
|
|
|
|
|
- QueryWrapper<PosOrder> query = new QueryWrapper<>();
|
|
|
|
|
- query.eq("user_id", id);
|
|
|
|
|
- query.eq("collect_payment", "1");
|
|
|
|
|
- query.notIn("state", 5, 10, 11);
|
|
|
|
|
- List<PosOrder> posOrders = posOrderService.list(query);
|
|
|
|
|
- System.out.println("到付信息:user_id=" + id + " ,到付数量:" + posOrders.size());
|
|
|
|
|
- //到付能存在2单未完成,第3单弹出提示
|
|
|
|
|
- if (posOrders.size() >= 2 && orderDTO.getCollectPayment().equals("1")) {
|
|
|
|
|
- return error(MessageUtils.message("no.exist.cash_on_delivery_order.incomplete"));
|
|
|
|
|
- }
|
|
|
|
|
- JSONArray jsonArray = orderDTO.getFoodlist();
|
|
|
|
|
- Map<Long, Long> map = new HashMap<>();
|
|
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
- Long foodid = jsonArray.getJSONObject(i).getLong("id");
|
|
|
|
|
- PosFood food = posFoodService.getById(foodid);
|
|
|
|
|
- if (food == null) {
|
|
|
|
|
- return error(jsonArray.getJSONObject(i).getString("name") + MessageUtils.message("no.goods.not.exist"));
|
|
|
|
|
- } else {
|
|
|
|
|
- if (food.getStackingUp().equals("1")) {
|
|
|
|
|
- return error(food.getName() + MessageUtils.message("no.goods.is.off.shelf"));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- Long num = jsonArray.getJSONObject(i).getLong("number");
|
|
|
|
|
- map.put(foodid, num);
|
|
|
|
|
- }
|
|
|
|
|
- VipUserQuanyi yh = null;
|
|
|
|
|
- VipUserQuanyi mdYh = null;
|
|
|
|
|
- if (ObjectUtil.isNotNull(orderDTO.getYhId()) && ObjectUtil.notEqual(orderDTO.getYhId(), 0L)) {
|
|
|
|
|
- LambdaQueryWrapper<VipUserQuanyi> yhQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
- yhQuery.eq(VipUserQuanyi::getId, orderDTO.getYhId());
|
|
|
|
|
- yh = userQuanyiService.getOne(yhQuery);
|
|
|
|
|
- if (yh == null) {
|
|
|
|
|
- throw new ServiceException("no.userquanyi.not.exist");
|
|
|
|
|
- }
|
|
|
|
|
- if (yh.getState().equals("1")) {
|
|
|
|
|
- throw new ServiceException("userquanyi.isUsed");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (ObjectUtil.isNotNull(orderDTO.getMdYhId()) && ObjectUtil.notEqual(orderDTO.getMdYhId(), 0L)) {
|
|
|
|
|
- LambdaQueryWrapper<VipUserQuanyi> mdYhquery = new LambdaQueryWrapper<>();
|
|
|
|
|
- mdYhquery.eq(VipUserQuanyi::getId, orderDTO.getMdYhId());
|
|
|
|
|
- mdYh = userQuanyiService.getOne(mdYhquery);
|
|
|
|
|
- if (mdYh == null) {
|
|
|
|
|
- throw new ServiceException("no.userquanyi.not.exist");
|
|
|
|
|
- }
|
|
|
|
|
- if (mdYh.getState().equals("1")) {
|
|
|
|
|
- throw new ServiceException("userquanyi.isUsed");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- SalesPromotion activity = null;
|
|
|
|
|
- SalesPromotion mdActivity = null;
|
|
|
|
|
- if (ObjectUtil.isNotNull(orderDTO.getActivity()) && ObjectUtil.notEqual(orderDTO.getActivity(), 0L)) {
|
|
|
|
|
- LambdaQueryWrapper<SalesPromotion> saleQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
- saleQuery.eq(SalesPromotion::getId, orderDTO.getActivity());
|
|
|
|
|
- activity = salesPromotionService.getOne(saleQuery);
|
|
|
|
|
- if (activity == null) {
|
|
|
|
|
- throw new ServiceException("no.activity.not.exist");
|
|
|
|
|
- }
|
|
|
|
|
-// if (yh.getState().equals("1")) {
|
|
|
|
|
-// throw new ServiceException("userquanyi.isUsed");
|
|
|
|
|
-// }
|
|
|
|
|
- }
|
|
|
|
|
- if (ObjectUtil.isNotNull(orderDTO.getMdActivity()) && ObjectUtil.notEqual(orderDTO.getMdActivity(), 0L)) {
|
|
|
|
|
- LambdaQueryWrapper<SalesPromotion> saleQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
- saleQuery.eq(SalesPromotion::getId, orderDTO.getMdActivity());
|
|
|
|
|
- mdActivity = salesPromotionService.getOne(saleQuery);
|
|
|
|
|
-
|
|
|
|
|
- if (mdActivity == null) {
|
|
|
|
|
- throw new ServiceException("no.activity.not.exist");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- PosOrder posOrder = new PosOrder();
|
|
|
|
|
- AjaxResult posOrderResult = redeePoints(orderDTO, Long.valueOf(id));
|
|
|
|
|
- if (!posOrderResult.get("code").equals(200)) {
|
|
|
|
|
- return posOrderResult;
|
|
|
|
|
- } else {
|
|
|
|
|
- posOrder.setPoints(orderDTO.getPoints());
|
|
|
|
|
- posOrder.setPointsReduction(orderDTO.getPointsReduction());
|
|
|
|
|
- }
|
|
|
|
|
- posOrder.setDdId(orderDTO.getDdId());
|
|
|
|
|
- posOrder.setShId(orderDTO.getShId());
|
|
|
|
|
- posOrder.setMdId(orderDTO.getMdId());
|
|
|
|
|
- posOrder.setShdzId(orderDTO.getShdzId());
|
|
|
|
|
- posOrder.setShAddress(JSON.toJSONString(usdizhi));
|
|
|
|
|
- posOrder.setUserId(Long.valueOf(id));
|
|
|
|
|
- posOrder.setAmount(orderDTO.getAmount());
|
|
|
|
|
- posOrder.setRemarks(orderDTO.getRemarks());
|
|
|
|
|
- posOrder.setType(orderDTO.getType());
|
|
|
|
|
- posOrder.setDelryTime(orderDTO.getDelryTime());
|
|
|
|
|
- posOrder.setFood(jsonArray.toString());
|
|
|
|
|
- posOrder.setState(0L);
|
|
|
|
|
-
|
|
|
|
|
- posOrder.setJvli(orderDTO.getJvli());
|
|
|
|
|
- posOrder.setFreight(orderDTO.getFreight());
|
|
|
|
|
- posOrder.setLongitude(orderDTO.getLongitude());
|
|
|
|
|
- posOrder.setLatitude(orderDTO.getLatitude());
|
|
|
|
|
- posOrder.setDiningStatus(orderDTO.getDiningStatus());
|
|
|
|
|
- posOrder.setQsId(orderDTO.getQsId());
|
|
|
|
|
- posOrder.setJuli(orderDTO.getJuli());
|
|
|
|
|
- posOrder.setPayUrl(orderDTO.getPayUrl());
|
|
|
|
|
- posOrder.setCollectPayment(orderDTO.getCollectPayment());
|
|
|
|
|
- posOrder.setAfterSaleStatus(0L);
|
|
|
|
|
- posOrder.setDeliveryStatus(Long.valueOf(0L).equals(orderDTO.getType()) ? 0L : null);
|
|
|
|
|
- posOrder.setPayStatus(Long.valueOf(0L).equals(orderDTO.getType())
|
|
|
|
|
- && "1".equals(orderDTO.getCollectPayment()) ? 1L : 0L);
|
|
|
|
|
-
|
|
|
|
|
- // posOrder.setCretim(dateUtil.getDatetim(orderDTO.getCretim()));
|
|
|
|
|
- //创建时间改成后端生成
|
|
|
|
|
- posOrder.setCretim(new Date());
|
|
|
|
|
-
|
|
|
|
|
- if (yh != null) {
|
|
|
|
|
- posOrder.setYhName(yh.getName());
|
|
|
|
|
- posOrder.setYhId(orderDTO.getYhId());
|
|
|
|
|
- posOrder.setDiscountAmount(orderDTO.getDiscountAmount());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (mdYh != null) {
|
|
|
|
|
- posOrder.setMdYhId(orderDTO.getMdYhId());
|
|
|
|
|
- posOrder.setMdYhName(mdYh.getName());
|
|
|
|
|
- posOrder.setMdDiscountAmount(orderDTO.getMdDiscountAmount());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (mdActivity != null) {
|
|
|
|
|
- posOrder.setMdActivity(orderDTO.getMdActivity());
|
|
|
|
|
- posOrder.setMdSalesName(mdActivity.getSalesName());
|
|
|
|
|
- posOrder.setMdSalesReduction(orderDTO.getMdSalesReduction());
|
|
|
|
|
- }
|
|
|
|
|
- if (activity != null) {
|
|
|
|
|
- posOrder.setActivity(orderDTO.getActivity());
|
|
|
|
|
- posOrder.setSalesName(activity.getSalesName());
|
|
|
|
|
- posOrder.setSalesReduction(orderDTO.getSalesReduction());
|
|
|
|
|
- }
|
|
|
|
|
- //设置支付类型为货到付款
|
|
|
|
|
- if ("1".equals(posOrder.getCollectPayment())) {
|
|
|
|
|
- // 031 闸门对称校验:平台关闭到付时商家建单同样被拒,与用户下单同口径(spec FR-004)。
|
|
|
|
|
- com.ruoyi.system.domain.PosStore payStore = posStoreService.getById(posOrder.getMdId());
|
|
|
|
|
- if (payStore != null) {
|
|
|
|
|
- paymentMethodGateService.assertUsable("1",
|
|
|
|
|
- com.ruoyi.system.service.PaymentMethodGateService.GateScope.MERCHANT,
|
|
|
|
|
- payStore.getId().longValue(), payStore.getUserId());
|
|
|
|
|
- }
|
|
|
|
|
- posOrder.setPayType("1");
|
|
|
|
|
- }
|
|
|
|
|
- Boolean org = posOrderService.saveOrUpdate(posOrder);
|
|
|
|
|
- foodStatistics(map);
|
|
|
|
|
- if (org) {
|
|
|
|
|
- QueryWrapper<UserBilling> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
- queryWrapper.eq("user_id", id);
|
|
|
|
|
- queryWrapper.eq("dd_id", posOrder.getDdId());
|
|
|
|
|
- UserBilling billing = userBillingService.getOne(queryWrapper);
|
|
|
|
|
- if (billing == null) {
|
|
|
|
|
- UserBilling usb = new UserBilling();
|
|
|
|
|
- usb.setUserId(Long.valueOf(id));
|
|
|
|
|
- usb.setDdId(String.valueOf(posOrder.getDdId()));
|
|
|
|
|
- usb.setMdId(posOrder.getMdId());
|
|
|
|
|
- usb.setState("3");
|
|
|
|
|
- usb.setType("3");
|
|
|
|
|
- userBillingService.saveOrUpdate(usb);
|
|
|
|
|
- }
|
|
|
|
|
- QueryWrapper<UserFootprint> Wrapper = new QueryWrapper<>();
|
|
|
|
|
- Wrapper.eq("user_id", id);
|
|
|
|
|
- Wrapper.eq("md_id", posOrder.getMdId());
|
|
|
|
|
- UserFootprint foot = userFootprintService.getOne(Wrapper);
|
|
|
|
|
- DateUtil dateString = new DateUtil();
|
|
|
|
|
- if (foot == null) {
|
|
|
|
|
- UserFootprint usf = new UserFootprint();
|
|
|
|
|
- usf.setUserId(Long.valueOf(id));
|
|
|
|
|
- usf.setMdId(posOrder.getMdId());
|
|
|
|
|
- usf.setCretim(dateString.GetDate());
|
|
|
|
|
- userFootprintService.saveOrUpdate(usf);
|
|
|
|
|
- } else {
|
|
|
|
|
- foot.setCretim(dateString.GetDate());
|
|
|
|
|
- userFootprintService.saveOrUpdate(foot);
|
|
|
|
|
- }
|
|
|
|
|
- QueryWrapper<PosOrder> querywra = new QueryWrapper<>();
|
|
|
|
|
- querywra.eq("dd_id", posOrder.getDdId());
|
|
|
|
|
- PosOrder order = posOrderService.getOne(querywra);
|
|
|
|
|
- //货到付款、类型外卖,推送给骑手有新订单了
|
|
|
|
|
- if (order.getCollectPayment().equals("1") && order.getType() == 0) {
|
|
|
|
|
- sendHdfkMessage(order);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //存在使用优惠券的话,核销优惠券
|
|
|
|
|
- redeemCoupons(yh, mdYh, order.getDdId());
|
|
|
|
|
- System.out.println("========== 输出的order ==========");
|
|
|
|
|
- System.out.println(mapper.writeValueAsString(order));
|
|
|
|
|
- long methodEnd = System.currentTimeMillis(); // 方法结束时间
|
|
|
|
|
- System.out.println("addorder 方法总执行耗时: " + (methodEnd - methodStart) + " ms");
|
|
|
|
|
- return success(MessageUtils.message("no.order.submit.success"), order);
|
|
|
|
|
- } else {
|
|
|
|
|
- long methodEnd = System.currentTimeMillis(); // 方法结束时间
|
|
|
|
|
- System.out.println("addorder 方法总执行耗时: " + (methodEnd - methodStart) + " ms");
|
|
|
|
|
- return error();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //统计美食销售量
|
|
|
|
|
- private void foodStatistics(Map<Long, Long> map) {
|
|
|
|
|
- for (Map.Entry<Long, Long> entry : map.entrySet()) {
|
|
|
|
|
- Long key = entry.getKey();
|
|
|
|
|
- Long value = entry.getValue();
|
|
|
|
|
- // 使用数据库原子UPSERT,避免并发下的竞态问题
|
|
|
|
|
- foodStatisticsService.increaseNumber(key, value);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 旧 /addorder 创建入口已移除;商家代客下单统一使用 /system/orderShOprate/createOrder。
|
|
|
/**
|
|
/**
|
|
|
* 货到付款发送推送
|
|
* 货到付款发送推送
|
|
|
*
|
|
*
|
|
@@ -1381,37 +1091,6 @@ public class PosOrderController extends BaseController {
|
|
|
deliveryOrderNotificationService.notifyOrderAvailable(order);
|
|
deliveryOrderNotificationService.notifyOrderAvailable(order);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //核销积分
|
|
|
|
|
- private AjaxResult redeePoints(OrderDTO orderDTO, Long userId) {
|
|
|
|
|
- if (ObjectUtil.isNotNull(orderDTO.getPoints()) && ObjectUtil.notEqual(orderDTO.getPoints(), 0) && ObjectUtil.isNotNull(orderDTO.getPointsReduction()) && ObjectUtil.notEqual(orderDTO.getPointsReduction(), 0)) {
|
|
|
|
|
- SysPointControl control = pointControlService.getById(1L);
|
|
|
|
|
- if (!control.getOrderUseEnable().equals(1L)) {
|
|
|
|
|
- throw new ServiceException(MessageUtils.message("no.points.use.enable"));
|
|
|
|
|
- }
|
|
|
|
|
- LambdaQueryWrapper<UserWallet> walletQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
- walletQuery.eq(UserWallet::getUserId, userId);
|
|
|
|
|
- walletQuery.isNull(UserWallet::getStoreId);
|
|
|
|
|
- UserWallet userWallet = userWalletService.getOne(walletQuery);
|
|
|
|
|
- if (ObjectUtil.isNotNull(userWallet)) {
|
|
|
|
|
- if (userWallet.getPointsWallet().compareTo(Long.valueOf(orderDTO.getPoints())) >= 0) {
|
|
|
|
|
- walletQuery.eq(UserWallet::getVersion, userWallet.getVersion());
|
|
|
|
|
- userWallet.setPointsWallet(userWallet.getPointsWallet() - orderDTO.getPoints());
|
|
|
|
|
- userWallet.setVersion(userWallet.getVersion() + 1);
|
|
|
|
|
- boolean update = userWalletService.update(userWallet, walletQuery);
|
|
|
|
|
- createPointTransaction(userId, Long.valueOf(orderDTO.getPoints()), userWallet.getPointsWallet(), orderDTO.getDdId().toString(), "1");
|
|
|
|
|
- if (!update) {
|
|
|
|
|
- throw new ServiceException(MessageUtils.message("no.points.update.fail"));
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new ServiceException(MessageUtils.message("no.points.insufficient"));
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new ServiceException(MessageUtils.message("no.points.not.exist"));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return success();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建积分流水
|
|
* 创建积分流水
|
|
|
*/
|
|
*/
|
|
@@ -1454,26 +1133,6 @@ public class PosOrderController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 核销优惠券
|
|
|
|
|
- *
|
|
|
|
|
- * @param orderId
|
|
|
|
|
- */
|
|
|
|
|
- private void redeemCoupons(VipUserQuanyi yh, VipUserQuanyi mdYh, String orderId) {
|
|
|
|
|
- if (ObjectUtil.isNotNull(yh)) {
|
|
|
|
|
- yh.setState("1");
|
|
|
|
|
- yh.setOrderId(orderId);
|
|
|
|
|
- yh.setUpdateTime(new Date());
|
|
|
|
|
- userQuanyiService.saveOrUpdate(yh);
|
|
|
|
|
- }
|
|
|
|
|
- if (ObjectUtil.isNotNull(mdYh)) {
|
|
|
|
|
- mdYh.setState("1");
|
|
|
|
|
- mdYh.setOrderId(orderId);
|
|
|
|
|
- mdYh.setUpdateTime(new Date());
|
|
|
|
|
- userQuanyiService.saveOrUpdate(mdYh);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询posorder列表
|
|
* 查询posorder列表
|
|
|
*/
|
|
*/
|