|
@@ -19,18 +19,26 @@ import com.fs.his.vo.FsStoreOrderListUVO;
|
|
|
import com.fs.ybPay.service.IPayService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.hc.openapi.tool.util.StringUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiResponse;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.redisson.api.RLock;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
|
@Api("商城接口")
|
|
|
@RestController
|
|
|
@RequestMapping(value="/app/storeOrder")
|
|
@@ -58,6 +66,10 @@ public class StoreOrderController extends AppBaseController {
|
|
|
private IFsCouponService couponService;
|
|
|
@Autowired
|
|
|
private IFsStoreOrderBillLogService orderBillLogService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedissonClient redissonClient;
|
|
|
+
|
|
|
@Login
|
|
|
@ApiOperation("获取我的订单列表")
|
|
|
@GetMapping("/getMyStoreOrderList")
|
|
@@ -147,6 +159,52 @@ public class StoreOrderController extends AppBaseController {
|
|
|
return orderService.payOrder(param);
|
|
|
}
|
|
|
|
|
|
+ @Login
|
|
|
+ @PostMapping("/modifyStoreOrderPrice")
|
|
|
+ public R modifyStoreOrderPrice(ModifyStoreOrderPriceParam param){
|
|
|
+ log.info("销售修改订单价格 {}", param);
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(param.getOrderId())){
|
|
|
+ throw new IllegalArgumentException("订单号不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(param.getNote())){
|
|
|
+ throw new IllegalArgumentException("修改原因不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtil.isEmpty(param.getPrice())) {
|
|
|
+ throw new IllegalArgumentException("订单修改价格不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(param.getPrice().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ throw new IllegalArgumentException("订单修改价格不能为负数");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String lockKey = "order_price_lock:" + param.getOrderId();
|
|
|
+ RLock lock = redissonClient.getLock(lockKey);
|
|
|
+
|
|
|
+ boolean locked = false;
|
|
|
+ try {
|
|
|
+ // 尝试获取锁,最多等待3秒,锁过期时间10秒
|
|
|
+ locked = lock.tryLock(3, 10, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ if (locked) {
|
|
|
+ FsStoreOrder fsStoreOrder = orderService.modifyStoreOrderPrice(param);
|
|
|
+ return R.ok().put("data",fsStoreOrder);
|
|
|
+ } else {
|
|
|
+ log.warn("获取订单价格修改锁失败,订单ID: {}", param.getOrderId());
|
|
|
+ return R.error("订单正在被其他操作修改,请稍后再试");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("修改订单价格异常,订单ID: {}", param.getOrderId(), e);
|
|
|
+ return R.error("修改订单价格失败: " + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ if (locked && lock.isHeldByCurrentThread()) {
|
|
|
+ lock.unlock();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|