|
@@ -1,8 +1,11 @@
|
|
|
package com.fs.app.controller;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.fs.app.annotation.Login;
|
|
|
|
|
|
+import com.fs.his.config.StoreConfig;
|
|
|
+import com.fs.his.mapper.FsStorePaymentMapper;
|
|
|
import com.fs.his.param.BillListParam;
|
|
|
import com.fs.app.param.FsStoreOrderExpressParam;
|
|
|
import com.fs.app.param.FsStoreOrderFinishParam;
|
|
@@ -16,6 +19,9 @@ import com.fs.his.param.*;
|
|
|
import com.fs.his.service.*;
|
|
|
import com.fs.his.vo.FsStoreOrderItemListUVO;
|
|
|
import com.fs.his.vo.FsStoreOrderListUVO;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
+import com.fs.ybPay.domain.OrderResult;
|
|
|
+import com.fs.ybPay.dto.OrderQueryDTO;
|
|
|
import com.fs.ybPay.service.IPayService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -28,6 +34,8 @@ 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.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -44,8 +52,6 @@ import java.util.concurrent.TimeUnit;
|
|
|
@RequestMapping(value="/app/storeOrder")
|
|
|
public class StoreOrderController extends AppBaseController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private IFsExpressService expressService;
|
|
|
@Autowired
|
|
|
IPayService payService;
|
|
|
@Autowired
|
|
@@ -54,22 +60,15 @@ public class StoreOrderController extends AppBaseController {
|
|
|
@Autowired
|
|
|
private IFsStoreOrderItemService orderItemService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IFsStorePaymentService storePaymentService;
|
|
|
- @Autowired
|
|
|
- private IFsUserService userService;
|
|
|
- @Autowired
|
|
|
- private IFsUserAddressService userAddressService;
|
|
|
- @Autowired
|
|
|
- private IFsUserCouponService userCouponService;
|
|
|
- @Autowired
|
|
|
- private IFsCouponService couponService;
|
|
|
@Autowired
|
|
|
private IFsStoreOrderBillLogService orderBillLogService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedissonClient redissonClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+
|
|
|
@Login
|
|
|
@ApiOperation("获取我的订单列表")
|
|
|
@GetMapping("/getMyStoreOrderList")
|
|
@@ -91,31 +90,8 @@ public class StoreOrderController extends AppBaseController {
|
|
|
List<FsStoreOrderItemListUVO> list=orderItemService.selectFsStoreOrderItemListUVOByOrderId(orderId);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(order.getCreateTime());
|
|
|
-// String json=configService.selectConfigByKey("his.store");
|
|
|
-// StoreConfig config=JSONUtil.toBean(json,StoreConfig.class);
|
|
|
-// calendar.add(Calendar.MINUTE,config.getUnPayTime());
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String payLimitTime = format.format(calendar.getTime() );
|
|
|
- //处理是否可以申请售后
|
|
|
- Integer isAfterSales=0;
|
|
|
-// if(order.getStatus().equals(FsStoreOrderStatusEnum.STATUS_4.getValue())) {
|
|
|
-// //已完成订单
|
|
|
-// isAfterSales=1;
|
|
|
-// if (order.getFinishTime() != null) {
|
|
|
-//// if (config.getStoreAfterSalesDay() != null && config.getStoreAfterSalesDay() > 0) {
|
|
|
-//// //判断完成时间是否超过指定时间
|
|
|
-//// Calendar calendarAfterSales = new GregorianCalendar();
|
|
|
-//// calendarAfterSales.setTime(order.getFinishTime());
|
|
|
-//// calendarAfterSales.add(calendarAfterSales.DATE, config.getStoreAfterSalesDay()); //把日期往后增加一天,整数 往后推,负数往前移动
|
|
|
-//// if (calendarAfterSales.getTime().getTime() < new Date().getTime()) {
|
|
|
-//// isAfterSales = 0;
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else if(order.getStatus()==2||order.getStatus()==3){
|
|
|
-// isAfterSales=1;
|
|
|
-// }
|
|
|
return R.ok().put("order",order).put("items",list).put("payLimitTime",payLimitTime);
|
|
|
}
|
|
|
|
|
@@ -124,18 +100,13 @@ public class StoreOrderController extends AppBaseController {
|
|
|
@GetMapping("/getStoreOrderById")
|
|
|
public R getStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
|
|
|
FsStoreOrder order=orderService.selectFsStoreOrderByOrderId(orderId);
|
|
|
-// if(!order.getUserId().equals(Long.parseLong(getUserId()))){
|
|
|
-// return R.error("非法操作");
|
|
|
-// }
|
|
|
+
|
|
|
order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
|
|
|
order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
|
|
|
List<FsStoreOrderItemListUVO> list=orderItemService.selectFsStoreOrderItemListUVOByOrderId(orderId);
|
|
|
|
|
|
-// String json=configService.selectConfigByKey("his.store");
|
|
|
-// StoreConfig config=JSONUtil.toBean(json,StoreConfig.class);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(order.getCreateTime());
|
|
|
-// calendar.add(Calendar.MINUTE,config.getUnPayTime());
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String payLimitTime = format.format(calendar.getTime() );
|
|
|
return R.ok().put("order",order).put("payLimitTime",payLimitTime).put("items",list);
|
|
@@ -207,6 +178,50 @@ public class StoreOrderController extends AppBaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Login
|
|
|
+ @ApiOperation("修改支付类型")
|
|
|
+ @PostMapping("/editPayType")
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
+ public R editPayType(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
|
|
|
+ FsStoreOrder order=orderService.selectFsStoreOrderByOrderId(param.getOrderId());
|
|
|
+ if(order==null){
|
|
|
+ return R.error("订单不存在");
|
|
|
+ }
|
|
|
+ if(order.getStatus()!= 1){
|
|
|
+ return R.error("订单状态必须为待付款才可以修改支付类型");
|
|
|
+ }
|
|
|
+ String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
|
|
|
+ return R.error("正在支付中...");
|
|
|
+ }
|
|
|
+
|
|
|
+ String config=configService.selectConfigByKey("store.config");
|
|
|
+ StoreConfig storeConfig= JSONUtil.toBean(config,StoreConfig.class);
|
|
|
+ // 普通这种
|
|
|
+ if(param.getPayType().equals(1)){
|
|
|
+ order.setPayType(1);
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
+ order.setPayDelivery(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ // 部分付款
|
|
|
+ else if(param.getPayType().equals(2)){
|
|
|
+ order.setPayType(2);
|
|
|
+ BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
+ }
|
|
|
+ //货到付款
|
|
|
+ else if(param.getPayType().equals(3)){
|
|
|
+ order.setPayType(3);
|
|
|
+ order.setPayDelivery(order.getPayPrice() );
|
|
|
+ order.setPayMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ orderService.updateFsStoreOrder(order);
|
|
|
+ return R.ok().put("order",order);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Login
|
|
|
@ApiOperation("支付")
|
|
@@ -275,18 +290,12 @@ public class StoreOrderController extends AppBaseController {
|
|
|
@GetMapping("/getCompanyUserStoreOrderById")
|
|
|
public R getCompanyUserStoreOrderById(@RequestParam("orderId") Long orderId, HttpServletRequest request){
|
|
|
FsStoreOrder order=orderService.selectFsStoreOrderByOrderId(orderId);
|
|
|
-// if(!order.getCompanyUserId().equals(getCompanyUserId())){
|
|
|
-// return R.error("非法操作");
|
|
|
-// }
|
|
|
order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
|
|
|
order.setUserAddress(ParseUtils.parseIdCard(order.getUserAddress()));
|
|
|
List<FsStoreOrderItemListUVO> list=orderItemService.selectFsStoreOrderItemListUVOByOrderId(orderId);
|
|
|
|
|
|
-// String json=configService.selectConfigByKey("his.store");
|
|
|
-// StoreConfig config=JSONUtil.toBean(json,StoreConfig.class);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(order.getCreateTime());
|
|
|
-// calendar.add(Calendar.MINUTE,config.getUnPayTime());
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String payLimitTime = format.format(calendar.getTime() );
|
|
|
return R.ok().put("order",order).put("payLimitTime",payLimitTime).put("items",list);
|