|
@@ -8,6 +8,7 @@ import com.github.wxpay.sdk.WXPay;
|
|
|
import com.github.wxpay.sdk.WXPayConstants;
|
|
import com.github.wxpay.sdk.WXPayConstants;
|
|
|
import com.github.wxpay.sdk.WXPayUtil;
|
|
import com.github.wxpay.sdk.WXPayUtil;
|
|
|
import com.sqx.common.constant.RedisKey;
|
|
import com.sqx.common.constant.RedisKey;
|
|
|
|
|
+import com.sqx.common.exception.SqxException;
|
|
|
import com.sqx.common.utils.RedisUtils;
|
|
import com.sqx.common.utils.RedisUtils;
|
|
|
import com.sqx.common.utils.Result;
|
|
import com.sqx.common.utils.Result;
|
|
|
import com.sqx.modules.app.bo.UpdateMoneyBO;
|
|
import com.sqx.modules.app.bo.UpdateMoneyBO;
|
|
@@ -51,9 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author fang
|
|
* @author fang
|
|
@@ -107,7 +106,28 @@ public class WxServiceImpl implements WxService {
|
|
|
@Override
|
|
@Override
|
|
|
public Result balanceOrder(Long userId, PayOrderDTO payOrderDTO) {
|
|
public Result balanceOrder(Long userId, PayOrderDTO payOrderDTO) {
|
|
|
TbOrder tbOrder = appOrderService.prepareOrder(userId, payOrderDTO);
|
|
TbOrder tbOrder = appOrderService.prepareOrder(userId, payOrderDTO);
|
|
|
-
|
|
|
|
|
|
|
+ // 查找该用户在这家店有几个订单
|
|
|
|
|
+ Long shopId = tbOrder.getShopId();
|
|
|
|
|
+
|
|
|
|
|
+ // 查询用户在当天该店铺内状态为 7、6、3、4 的订单数量
|
|
|
|
|
+ String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
|
|
+ String startTime = currentDate + " 00:00:00";
|
|
|
|
|
+ String endTime = currentDate + " 23:59:59";
|
|
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
|
|
+ statusList.add(7); // 商家待接单
|
|
|
|
|
+ statusList.add(6); // 制作中
|
|
|
|
|
+ statusList.add(3); // 待取餐/派送中
|
|
|
|
|
+ statusList.add(4); // 已完成
|
|
|
|
|
+
|
|
|
|
|
+ int orderCount = appOrderDao.countByUserIdAndShopIdAndStatusListAndTimeRange(
|
|
|
|
|
+ userId, shopId, startTime, endTime, statusList);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("getTransactionsParam==>[userId:{}, shopId:{}],当天状态为7、6、3、4的订单数量:{}",
|
|
|
|
|
+ userId, shopId, orderCount);
|
|
|
|
|
+
|
|
|
|
|
+ if (orderCount>=10) {
|
|
|
|
|
+ throw new SqxException("该商户当天的订单量已超过当前限额!");
|
|
|
|
|
+ }
|
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.INSERT_ORDER_LOCK, tbOrder.getOrderId(), tbOrder.getShopId()));
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.INSERT_ORDER_LOCK, tbOrder.getOrderId(), tbOrder.getShopId()));
|
|
|
lock.lock();
|
|
lock.lock();
|
|
|
try{
|
|
try{
|