|
@@ -16,6 +16,7 @@ import com.ruoyi.app.order.dto.OrderPushBodyDto;
|
|
|
import com.ruoyi.app.order.dto.PositionDto;
|
|
import com.ruoyi.app.order.dto.PositionDto;
|
|
|
import com.ruoyi.app.order.dto.QsDto;
|
|
import com.ruoyi.app.order.dto.QsDto;
|
|
|
import com.ruoyi.app.pay.PayController;
|
|
import com.ruoyi.app.pay.PayController;
|
|
|
|
|
+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;
|
|
@@ -46,18 +47,25 @@ import com.ruoyi.system.utils.GetArea;
|
|
|
import com.ruoyi.system.utils.JwtUtil;
|
|
import com.ruoyi.system.utils.JwtUtil;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
+import org.redisson.api.RLock;
|
|
|
|
|
+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.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
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.TransactionSynchronizationManager;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -122,6 +130,10 @@ public class PosOrderController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PosFoodMapper posFoodMapper;
|
|
private PosFoodMapper posFoodMapper;
|
|
|
|
|
|
|
|
|
|
+ private RedissonClient redissonClient;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private UserService userService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//查询用户足迹
|
|
//查询用户足迹
|
|
|
@Anonymous
|
|
@Anonymous
|
|
@@ -146,7 +158,7 @@ public class PosOrderController extends BaseController {
|
|
|
if (!storeIds.isEmpty()) {
|
|
if (!storeIds.isEmpty()) {
|
|
|
// 将Integer类型的门店ID转换为Long类型用于查询(因为mdid是Long类型)
|
|
// 将Integer类型的门店ID转换为Long类型用于查询(因为mdid是Long类型)
|
|
|
List<Long> storeIdsLong = storeIds.stream()
|
|
List<Long> storeIdsLong = storeIds.stream()
|
|
|
- .map(x->x)
|
|
|
|
|
|
|
+ .map(x -> x)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
// 使用MyBatis Plus的Mapper方法,在数据库查询时就限制每个门店只返回6条商品
|
|
// 使用MyBatis Plus的Mapper方法,在数据库查询时就限制每个门店只返回6条商品
|
|
@@ -160,8 +172,8 @@ public class PosOrderController extends BaseController {
|
|
|
// 转换为StoreOutput并设置每个门店的商品列表(每个门店最多6条)
|
|
// 转换为StoreOutput并设置每个门店的商品列表(每个门店最多6条)
|
|
|
List<StoreOutput> storeOutputList = new ArrayList<>();
|
|
List<StoreOutput> storeOutputList = new ArrayList<>();
|
|
|
for (UserFootprint collect : footprints) {
|
|
for (UserFootprint collect : footprints) {
|
|
|
- PosStore store=posStoreService.getById(collect.getMdId());
|
|
|
|
|
- if(store!=null){
|
|
|
|
|
|
|
+ PosStore store = posStoreService.getById(collect.getMdId());
|
|
|
|
|
+ if (store != null) {
|
|
|
StoreOutput storeOutput = new StoreOutput();
|
|
StoreOutput storeOutput = new StoreOutput();
|
|
|
// 复制PosStore的所有属性
|
|
// 复制PosStore的所有属性
|
|
|
BeanUtils.copyProperties(store, storeOutput);
|
|
BeanUtils.copyProperties(store, storeOutput);
|
|
@@ -178,7 +190,6 @@ public class PosOrderController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//修改订单
|
|
//修改订单
|
|
|
@Anonymous
|
|
@Anonymous
|
|
|
@Auth
|
|
@Auth
|
|
@@ -205,8 +216,7 @@ public class PosOrderController extends BaseController {
|
|
|
return setOrderState5(posOrder);
|
|
return setOrderState5(posOrder);
|
|
|
} else if (posOrder.getState() == 2) {
|
|
} else if (posOrder.getState() == 2) {
|
|
|
return setOrderState2(posOrder, id);
|
|
return setOrderState2(posOrder, id);
|
|
|
- } else if (posOrder.getState() == 3 || posOrder.getState() == 4 || posOrder.getState() == 12)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (posOrder.getState() == 3 || posOrder.getState() == 4 || posOrder.getState() == 12) {
|
|
|
return setOrderQsState(posOrder, id, push);
|
|
return setOrderQsState(posOrder, id, push);
|
|
|
} else if (posOrder.getState() == 7) {
|
|
} else if (posOrder.getState() == 7) {
|
|
|
return setOrderState7(posOrder);
|
|
return setOrderState7(posOrder);
|
|
@@ -233,88 +243,116 @@ public class PosOrderController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//骑手接单、取餐、送达
|
|
//骑手接单、取餐、送达
|
|
|
- private AjaxResult setOrderQsState(PosOrder posOrder, String id, PayPush push) {
|
|
|
|
|
- PosOrder orst = posOrderService.getById(posOrder.getId());
|
|
|
|
|
- if (orst.getState() == 3 && posOrder.getState() == 3) {
|
|
|
|
|
- return error(MessageUtils.message("no.order.snatched"));
|
|
|
|
|
- } else {
|
|
|
|
|
- if(posOrder.getState()==3){
|
|
|
|
|
- QueryWrapper<PosOrder> wrapper = new QueryWrapper<>();
|
|
|
|
|
- wrapper.eq("qs_id", id);
|
|
|
|
|
- wrapper.in("state", 3, 4);
|
|
|
|
|
- List<PosOrder> orsts = posOrderService.list(wrapper);
|
|
|
|
|
- if (orsts.size() > 0) {
|
|
|
|
|
- return error(MessageUtils.message("no.exist.undelivered.order"));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- String userMessage= MessageUtils.message("no.message.push.delivery.personnel.receiving.order");
|
|
|
|
|
- if(posOrder.getState()==4){
|
|
|
|
|
- userMessage= MessageUtils.message("no.message.push.delivery.personnel.qspsz.order");
|
|
|
|
|
- }else if(posOrder.getState()==12){
|
|
|
|
|
- userMessage= MessageUtils.message("no.message.push.delivery.personnel.qsysd.order");
|
|
|
|
|
- }
|
|
|
|
|
- int zsou = userBillingMapper.gettypesum(Long.valueOf(id), 1L);
|
|
|
|
|
- int zcz = userBillingMapper.gettypesum(Long.valueOf(id), 2L);
|
|
|
|
|
- int xiaf = userBillingMapper.gettypesum(Long.valueOf(id), 3L);
|
|
|
|
|
- int yure = zsou - zcz - xiaf;
|
|
|
|
|
- PosMargin posMargin = posMarginService.getById(2);
|
|
|
|
|
- System.out.println("用户余额:" + yure);
|
|
|
|
|
- System.out.println("保证金:" + posMargin.getAmount());
|
|
|
|
|
- //临时代码开始
|
|
|
|
|
- if (orst.getCollectPayment().equals("1")) {
|
|
|
|
|
- System.out.println("结果:" + orst.getAmount());
|
|
|
|
|
- boolean org = posOrderService.saveOrUpdate(posOrder);
|
|
|
|
|
- if (org) {
|
|
|
|
|
- if(posOrder.getState()==3) {
|
|
|
|
|
- QueryWrapper<UserBilling> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
- queryWrapper.eq("dd_id", orst.getDdId());
|
|
|
|
|
- queryWrapper.eq("type", "3");
|
|
|
|
|
- queryWrapper.eq("state", "3");
|
|
|
|
|
- UserBilling foot = userBillingService.getOne(queryWrapper);
|
|
|
|
|
- if (foot != null) {
|
|
|
|
|
- foot.setState("0");
|
|
|
|
|
- foot.setIllustrate("Rider Payment Order");
|
|
|
|
|
- foot.setBalancePay("1");
|
|
|
|
|
- foot.setPaymentId(String.valueOf(id));
|
|
|
|
|
- userBillingService.saveOrUpdate(foot);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ private AjaxResult setOrderQsState(PosOrder posOrder, String qsId, PayPush push) {
|
|
|
|
|
+ String lockKey = "order:qs:lock:" + posOrder.getId();
|
|
|
|
|
+ RLock lock = redissonClient.getLock(lockKey);
|
|
|
|
|
+ try {
|
|
|
|
|
+ var local = LocaleContextHolder.getLocale();
|
|
|
|
|
+ logger.info("骑手接单local信息:" + local.getLanguage());
|
|
|
|
|
+ logger.info(JSON.toJSONString(local));
|
|
|
|
|
+ // 尝试获取锁
|
|
|
|
|
+ if (lock.tryLock(20L, 10L, TimeUnit.SECONDS)) {
|
|
|
|
|
+ boolean releaseInfinally = true;
|
|
|
|
|
+ try {
|
|
|
|
|
+ userService.checkUserStatus(Long.valueOf(qsId));
|
|
|
|
|
+ PosOrder orst = posOrderService.getById(posOrder.getId());
|
|
|
|
|
+ if (orst.getState() == 3 && posOrder.getState() == 3) {
|
|
|
|
|
+ throw new ServiceException(MessageUtils.message("no.order.snatched"));
|
|
|
}
|
|
}
|
|
|
- InfoUser user = infoUserService.getById(orst.getUserId());
|
|
|
|
|
- InfoUser shu = infoUserService.getById(orst.getShId());
|
|
|
|
|
- if (!"".equals(user.getCid())) {
|
|
|
|
|
- logger.info("用户cid:" + user.getCid() + "推送");
|
|
|
|
|
- push.apppush(user.getCid(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
|
|
|
|
|
- pushEventService.PublisherEvent(user.getUserId(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
|
|
|
|
|
|
|
+ if (posOrder.getState() == 3) {
|
|
|
|
|
+ QueryWrapper<PosOrder> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ wrapper.eq("qs_id", qsId);
|
|
|
|
|
+ wrapper.in("state", 3, 4);
|
|
|
|
|
+ List<PosOrder> orsts = posOrderService.list(wrapper);
|
|
|
|
|
+ if (orsts.size() > 0) {
|
|
|
|
|
+ throw new ServiceException(MessageUtils.message("no.exist.undelivered.order"));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (!"".equals(shu.getCid()) && posOrder.getState()==3) {
|
|
|
|
|
- logger.info("商家cid:" + user.getCid() + "推送");
|
|
|
|
|
- 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())));
|
|
|
|
|
- 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())));
|
|
|
|
|
|
|
+ String userMessage = MessageUtils.message("no.message.push.delivery.personnel.receiving.order");
|
|
|
|
|
+ if (posOrder.getState() == 4) {
|
|
|
|
|
+ userMessage = MessageUtils.message("no.message.push.delivery.personnel.qspsz.order");
|
|
|
|
|
+ } else if (posOrder.getState() == 12) {
|
|
|
|
|
+ userMessage = MessageUtils.message("no.message.push.delivery.personnel.qsysd.order");
|
|
|
}
|
|
}
|
|
|
- return success(MessageUtils.message("no.modify.success"), posOrder.getId());
|
|
|
|
|
- } else {
|
|
|
|
|
- return error();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- } else {
|
|
|
|
|
- boolean org = posOrderService.saveOrUpdate(posOrder);
|
|
|
|
|
- if (org) {
|
|
|
|
|
- InfoUser user = infoUserService.getById(orst.getUserId());
|
|
|
|
|
- if (!"".equals(user.getCid())) {
|
|
|
|
|
- logger.info("用户cid:" + user.getCid() + "推送");
|
|
|
|
|
- push.apppush(user.getCid(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
|
|
|
|
|
- pushEventService.PublisherEvent(user.getUserId(), MessageUtils.message("no.message.push.message"), userMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
|
|
|
|
|
|
|
+ boolean org = posOrderService.saveOrUpdate(posOrder);
|
|
|
|
|
+ if (org) {
|
|
|
|
|
+ //到付订单,设置用户账单为完成
|
|
|
|
|
+ if (posOrder.getState() == 3 && "1".equals(orst.getCollectPayment())) {
|
|
|
|
|
+ updateUserBill(Long.valueOf(orst.getDdId()), orst.getUserId(), orst.getQsId());
|
|
|
|
|
+ }
|
|
|
|
|
+ InfoUser user = infoUserService.getById(orst.getUserId());
|
|
|
|
|
+ InfoUser shu = infoUserService.getById(orst.getShId());
|
|
|
|
|
+ String finalUserMessage = userMessage;
|
|
|
|
|
+ releaseInfinally = false;
|
|
|
|
|
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void afterCommit() {
|
|
|
|
|
+ if (lock.isHeldByCurrentThread()) {
|
|
|
|
|
+ lock.unlock();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!"".equals(user.getCid())) {
|
|
|
|
|
+ logger.info("用户cid:" + user.getCid() + "推送");
|
|
|
|
|
+ push.apppush(user.getCid(), MessageUtils.message("no.message.push.message"), finalUserMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
|
|
|
|
|
+ pushEventService.PublisherEvent(user.getUserId(), MessageUtils.message("no.message.push.message"), finalUserMessage, OrderPushBodyDto.getJson(String.valueOf(orst.getDdId()), String.valueOf(posOrder.getState())));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!"".equals(shu.getCid()) && posOrder.getState() == 3) {
|
|
|
|
|
+ logger.info("商家cid:" + user.getCid() + "推送");
|
|
|
|
|
+ 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())));
|
|
|
|
|
+ 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())));
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ // 注意:此时事务已提交,失败不会回滚主事务
|
|
|
|
|
+ logger.error("setOrderQsState, orderId={}", orst.getDdId(), ex);
|
|
|
|
|
+ // 可在此触发重试/告警/记录Outbox补偿等
|
|
|
|
|
+ throw new ServiceException("no.action.fail");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return success(MessageUtils.message("no.modify.success"), posOrder.getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return error();
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ if (releaseInfinally && lock.isHeldByCurrentThread()) {
|
|
|
|
|
+ lock.unlock();
|
|
|
}
|
|
}
|
|
|
- return success(MessageUtils.message("no.modify.success"), orst.getId());
|
|
|
|
|
- } else {
|
|
|
|
|
- return error();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new ServiceException(MessageUtils.message("no.system.busy.try.again"));
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
|
+ throw new ServiceException(MessageUtils.message("no.operation.interrupted.try.again"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新用户用户账单
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param ddId
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param qsId
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateUserBill(Long ddId, Long userId, Long qsId) {
|
|
|
|
|
+ QueryWrapper<UserBilling> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("dd_id", ddId);
|
|
|
|
|
+ queryWrapper.eq("user_id", userId);
|
|
|
|
|
+ queryWrapper.eq("type", "3");
|
|
|
|
|
+ UserBilling userBill = userBillingService.getOne(queryWrapper);
|
|
|
|
|
+ if (userBill != null) {
|
|
|
|
|
+ userBill.setState("0");
|
|
|
|
|
+ userBill.setIllustrate("Rider Payment Order");
|
|
|
|
|
+ userBill.setBalancePay("1");
|
|
|
|
|
+ userBill.setPaymentId(String.valueOf(qsId));
|
|
|
|
|
+ userBillingService.saveOrUpdate(userBill);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
//商家接单
|
|
//商家接单
|
|
|
- private AjaxResult setOrderState2(PosOrder posOrder,String id) {
|
|
|
|
|
|
|
+ private AjaxResult setOrderState2(PosOrder posOrder, String id) {
|
|
|
int zsou = userBillingMapper.gettypesum(Long.valueOf(id), 1L);
|
|
int zsou = userBillingMapper.gettypesum(Long.valueOf(id), 1L);
|
|
|
int zcz = userBillingMapper.gettypesum(Long.valueOf(id), 2L);
|
|
int zcz = userBillingMapper.gettypesum(Long.valueOf(id), 2L);
|
|
|
int xiaof = userBillingMapper.gettypesum(Long.valueOf(id), 3L);
|
|
int xiaof = userBillingMapper.gettypesum(Long.valueOf(id), 3L);
|
|
@@ -343,8 +381,9 @@ public class PosOrderController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//订单完成
|
|
//订单完成
|
|
|
- private AjaxResult setOrderState5(PosOrder posOrder){
|
|
|
|
|
|
|
+ private AjaxResult setOrderState5(PosOrder posOrder) {
|
|
|
boolean org = posOrderService.saveOrUpdate(posOrder);
|
|
boolean org = posOrderService.saveOrUpdate(posOrder);
|
|
|
if (org) {
|
|
if (org) {
|
|
|
PosOrder order = posOrderService.getById(posOrder.getId());
|
|
PosOrder order = posOrderService.getById(posOrder.getId());
|
|
@@ -462,7 +501,7 @@ public class PosOrderController extends BaseController {
|
|
|
DecimalFormat df = new DecimalFormat("#.00");
|
|
DecimalFormat df = new DecimalFormat("#.00");
|
|
|
InfoUser user = infoUserService.getById(posOrder.getShId());
|
|
InfoUser user = infoUserService.getById(posOrder.getShId());
|
|
|
Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
Double fcbili = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
|
- fcbili=getShCommissionRate(fcbili,user.getUserId());
|
|
|
|
|
|
|
+ fcbili = getShCommissionRate(fcbili, user.getUserId());
|
|
|
JSONArray list = JSONArray.parseArray(posOrder.getFood());
|
|
JSONArray list = JSONArray.parseArray(posOrder.getFood());
|
|
|
int fenc = 0;
|
|
int fenc = 0;
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
@@ -526,11 +565,11 @@ public class PosOrderController extends BaseController {
|
|
|
* 获取商家分成比例
|
|
* 获取商家分成比例
|
|
|
* 委托给 Service 层处理
|
|
* 委托给 Service 层处理
|
|
|
*
|
|
*
|
|
|
- * @param rate 默认分成比例
|
|
|
|
|
|
|
+ * @param rate 默认分成比例
|
|
|
* @param shUserId 商家用户ID
|
|
* @param shUserId 商家用户ID
|
|
|
* @return 分成比例
|
|
* @return 分成比例
|
|
|
*/
|
|
*/
|
|
|
- public Double getShCommissionRate(Double rate, Long shUserId){
|
|
|
|
|
|
|
+ public Double getShCommissionRate(Double rate, Long shUserId) {
|
|
|
return rate;
|
|
return rate;
|
|
|
// 委托给 Service 层处理
|
|
// 委托给 Service 层处理
|
|
|
// return commissionRatesService.getShCommissionRate(rate, shUserId);
|
|
// return commissionRatesService.getShCommissionRate(rate, shUserId);
|
|
@@ -1003,10 +1042,10 @@ public class PosOrderController extends BaseController {
|
|
|
queryWrapper.apply("NOT (state = 0 AND collect_payment = 0)");
|
|
queryWrapper.apply("NOT (state = 0 AND collect_payment = 0)");
|
|
|
IPage<PosOrder> list = posOrderService.page(palist, queryWrapper);
|
|
IPage<PosOrder> list = posOrderService.page(palist, queryWrapper);
|
|
|
List<PosOrder> orlist = list.getRecords();
|
|
List<PosOrder> orlist = list.getRecords();
|
|
|
-List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect(Collectors.toList());
|
|
|
|
|
- List<OrderParent> orderParents =new ArrayList<>();
|
|
|
|
|
- if(!parentDdIds.isEmpty()){
|
|
|
|
|
- orderParents= orderParentService.list(new LambdaQueryWrapper<>(OrderParent.class).in(OrderParent::getDdId, parentDdIds));
|
|
|
|
|
|
|
+ List<String> parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect(Collectors.toList());
|
|
|
|
|
+ List<OrderParent> orderParents = new ArrayList<>();
|
|
|
|
|
+ if (!parentDdIds.isEmpty()) {
|
|
|
|
|
+ orderParents = orderParentService.list(new LambdaQueryWrapper<>(OrderParent.class).in(OrderParent::getDdId, parentDdIds));
|
|
|
}
|
|
}
|
|
|
JSONArray arr = new JSONArray();
|
|
JSONArray arr = new JSONArray();
|
|
|
for (int i = 0; i < orlist.size(); i++) {
|
|
for (int i = 0; i < orlist.size(); i++) {
|
|
@@ -1052,9 +1091,9 @@ List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect
|
|
|
org.put("sdTime", orlist.get(i).getSdTime());
|
|
org.put("sdTime", orlist.get(i).getSdTime());
|
|
|
org.put("payType", orlist.get(i).getPayType());
|
|
org.put("payType", orlist.get(i).getPayType());
|
|
|
int finalI = i;
|
|
int finalI = i;
|
|
|
- org.put("parentRemarks","");
|
|
|
|
|
- if(StringUtils.isNotEmpty(orlist.get(i).getParentDdId())){
|
|
|
|
|
- orderParents.stream().filter(item->item.getDdId().equals(orlist.get(finalI).getParentDdId())).findFirst().ifPresent(a-> org.put("parentRemarks",a.getRemarks()));
|
|
|
|
|
|
|
+ org.put("parentRemarks", "");
|
|
|
|
|
+ if (StringUtils.isNotEmpty(orlist.get(i).getParentDdId())) {
|
|
|
|
|
+ orderParents.stream().filter(item -> item.getDdId().equals(orlist.get(finalI).getParentDdId())).findFirst().ifPresent(a -> org.put("parentRemarks", a.getRemarks()));
|
|
|
}
|
|
}
|
|
|
arr.add(org);
|
|
arr.add(org);
|
|
|
}
|
|
}
|
|
@@ -1143,7 +1182,7 @@ List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect
|
|
|
return error(MessageUtils.message("no.exist.cash_on_delivery_order.incomplete"));
|
|
return error(MessageUtils.message("no.exist.cash_on_delivery_order.incomplete"));
|
|
|
}
|
|
}
|
|
|
JSONArray jsonArray = orderDTO.getFoodlist();
|
|
JSONArray jsonArray = orderDTO.getFoodlist();
|
|
|
- Map<Long,Long> map = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Long, Long> map = new HashMap<>();
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
Long foodid = jsonArray.getJSONObject(i).getLong("id");
|
|
Long foodid = jsonArray.getJSONObject(i).getLong("id");
|
|
|
PosFood food = posFoodService.getById(foodid);
|
|
PosFood food = posFoodService.getById(foodid);
|
|
@@ -1155,7 +1194,7 @@ List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
Long num = jsonArray.getJSONObject(i).getLong("number");
|
|
Long num = jsonArray.getJSONObject(i).getLong("number");
|
|
|
- map.put(foodid,num);
|
|
|
|
|
|
|
+ map.put(foodid, num);
|
|
|
}
|
|
}
|
|
|
VipUserQuanyi yh = null;
|
|
VipUserQuanyi yh = null;
|
|
|
VipUserQuanyi mdYh = null;
|
|
VipUserQuanyi mdYh = null;
|
|
@@ -1317,8 +1356,9 @@ List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect
|
|
|
return error();
|
|
return error();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//统计美食销售量
|
|
//统计美食销售量
|
|
|
- private void foodStatistics(Map<Long,Long> map) {
|
|
|
|
|
|
|
+ private void foodStatistics(Map<Long, Long> map) {
|
|
|
for (Map.Entry<Long, Long> entry : map.entrySet()) {
|
|
for (Map.Entry<Long, Long> entry : map.entrySet()) {
|
|
|
Long key = entry.getKey();
|
|
Long key = entry.getKey();
|
|
|
Long value = entry.getValue();
|
|
Long value = entry.getValue();
|
|
@@ -1384,6 +1424,7 @@ List<String > parentDdIds = orlist.stream().map(PosOrder::getParentDdId).collect
|
|
|
}
|
|
}
|
|
|
return success();
|
|
return success();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 创建积分流水
|
|
* 创建积分流水
|
|
|
*/
|
|
*/
|