xdd пре 1 месец
родитељ
комит
3c392fb97c

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStoreOrderService.java

@@ -209,4 +209,6 @@ public interface IFsStoreOrderService
     R otherPayment(FsStoreOrderOtherPayParam param);
 
     R otherPaymentRemain(FsStoreOrderOtherPayParam param);
+
+    R getStoreOrderByOrderIdTz(Long orderId, String payCode);
 }

+ 92 - 14
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -1483,7 +1483,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
     //类型1支付回调 类型2货到付款
     public String payConfirm(Integer type,Long orderId,String payCode,String tradeNo,String bankTransactionId,String bankSerialNo) {
         //支付订单
@@ -1503,10 +1503,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 storePaymentMap.setBankTransactionId(bankTransactionId);
                 paymentService.updateFsStorePayment(storePaymentMap);
                 order=fsStoreOrderMapper.selectFsStoreOrderById(storePayment.getOrderId());
-//                if(order!=null&&!order.getStatus().equals(OrderInfoEnum.STATUS_0.getValue())){
-//                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-//                    return "";
-//                }
+
                 if(order!=null&&!order.getPaid().equals(0)){
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     return "";
@@ -1537,15 +1534,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             //增加状态
             orderStatusService.create(order.getId(), OrderLogEnum.PAY_ORDER_SUCCESS.getValue(),
                     OrderLogEnum.PAY_ORDER_SUCCESS.getDesc());
-//        FsUser user=userService.selectFsUserById(order.getUserId());
-//        //增加流水
-//        String payTypeMsg = PayTypeEnum.WEIXIN.getDesc();
-//        billService.addBill(user.getUserId(),
-//                BillDetailEnum.CATEGORY_1.getValue(),
-//                0,
-//                BillDetailEnum.TYPE_1.getDesc(),
-//                order.getPayPrice().doubleValue(), user.getNowMoney().doubleValue(),
-//                payTypeMsg + order.getPayPrice() + "元购买商品",order.getId().toString());
+
             FsStoreOrder storeOrder = new FsStoreOrder();
             storeOrder.setId(order.getId());
             storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue());
@@ -3104,4 +3093,93 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         return R.error("无支付类型");
     }
 
+    @Override
+    public R getStoreOrderByOrderIdTz(Long orderId, String payCode) {
+        // 根据订单查询payment
+        if(ObjectUtil.isNull(orderId)&&ObjectUtil.isNull(payCode)){
+            return R.error("参数错误");
+        }
+
+        List<FsStorePayment> fsStorePayments;
+        if(ObjectUtil.isNotNull(orderId)){
+            fsStorePayments = fsStorePaymentMapper.selectFsStorePaymentByOrder(orderId);
+        } else{
+            fsStorePayments = fsStorePaymentMapper.selectFsStorePaymentByPayCode(payCode);
+        }
+        // 如果已经有支付成功的记录
+        if(CollectionUtils.isNotEmpty(fsStorePayments)){
+            for (FsStorePayment fsStorePayment : fsStorePayments) {
+                // 如果状态为已支付或者已经退款
+                if(ObjectUtil.equal(fsStorePayment.getStatus(),1) || ObjectUtil.equal(fsStorePayment.getStatus(), -1)){
+                    return R.ok().put("orderId", orderId)
+                            .put("payCode", payCode)
+                            .put("status", fsStorePayment.getStatus());
+                }
+            }
+        }
+        // 如果没找到,查看付款信息是否有未支付的 且 类型为tzbank 且 trade_no 不为空的数据
+        // 调用台州银行接口查询订单信息
+        List<FsStorePayment> fsStorePayments1;
+        if(ObjectUtil.isNotNull(orderId)){
+            fsStorePayments1 = fsStorePaymentMapper.selectFsStorePaymentTzUnpayByOrder(orderId);
+        } else {
+            fsStorePayments1 = fsStorePaymentMapper.selectFsStorePaymentTzUnpayByPayCode(payCode);
+        }
+
+        if(CollectionUtils.isNotEmpty(fsStorePayments1)){
+            FsStorePayment fsStorePayment = fsStorePayments1.get(0);
+
+            RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
+
+            QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
+
+            queryOrderRestDTO.setOrderFlowNo(fsStorePayment.getTradeNo());
+            TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
+
+            queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
+
+            requestDTO.setReqBody(queryOrderRestDTO);
+            requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(fsStorePayment.getPayCode()));
+
+            TzReqResultDTO<QueryOrderInfoDTO> resultDTO = null;
+            try {
+                resultDTO = tzBankService.payQueryOrder(requestDTO);
+                String retCode = resultDTO.getRetCode();
+                // 如果查询支付成功
+                if(retCode.equals("00000000")){
+                    QueryOrderInfoDTO body = resultDTO.getBody();
+                    String status = body.getStatus();
+                    if("90".equals(status)){
+                        // 如果查询支付成功 更新订单状态
+                        orderService.payConfirm(1,orderId,fsStorePayment.getPayCode(),
+                                fsStorePayment.getTradeNo(),body.getChlTrxId(),fsStorePayment.getTradeNo());
+                        return R.ok().put("orderId", orderId)
+                                .put("payCode", payCode)
+                                .put("status", 1);
+                    } else if("70".equals(status)) {
+                        return R.ok().put("orderId", orderId)
+                                .put("payCode", payCode)
+                                .put("status", -1);
+                    }
+
+                }
+            } catch (Exception e) {
+                logger.error("台州银行支付回调查询失败:",e);
+            }
+
+        }
+        FsStoreOrder order=orderService.selectFsStoreOrderById(orderId);
+
+        if(ObjectUtil.isNotNull(order)){
+            return R.ok().put("orderId",orderId)
+                    .put("payCode", payCode)
+                    .put("status", order.getStatus());
+        } else {
+            // 如果没有订单信息可能是从微信收款而来
+            return R.ok().put("orderId", orderId)
+                    .put("payCode", payCode)
+                    .put("status", 0);
+        }
+    }
+
 }

+ 0 - 47
fs-user-app/src/main/java/com/fs/app/controller/PayController.java

@@ -45,40 +45,17 @@ public class PayController {
 
     protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
 
-    @Autowired
-    private RedisCache redisCache;
     @Autowired
     private IFsStoreOrderService orderService;
     @Autowired
-    private IFsStoreOrderStatusService orderStatusService;
-    @Autowired
-    private IFsUserBillService billService;
-    @Autowired
-    private IFsUserService userService;
-    @Autowired
-    private ApplicationEventPublisher publisher;
-
-    @Autowired
-    private FSSysConfig sysConfig;
-    @Autowired
     IErpOrderService erpOrderService;
 
-    @Autowired
-    private IFsStoreOrderItemService storeOrderItemService;
-
     @Autowired
     private IFsStorePaymentService storePaymentService;
-    @Autowired
-    private IFsExpressService expressService;
-
-    @Autowired
-    private ICompanyService companyService;
 
     @Autowired
     PayService ybPayService;
 
-    @Autowired
-    private ICompanyUserService companyUserService;
 
     @ApiOperation("易宝第三方支付回调")
     @PostMapping(value="/ybPayNotify")
@@ -186,28 +163,4 @@ public class PayController {
         return "success";
     }
 
-
-//    @Transactional
-//    public String paymentOp(String payCode,String tradeNo,String bankTransactionId,String bankSerialNo) {
-//
-//        //更新订单状态
-//        FsStorePayment storePayment=storePaymentService.selectFsStorePaymentByCode(payCode);
-//        if(!storePayment.getStatus().equals(0)){
-//            return "";
-//        }
-//        storePayment.setStatus(1);
-//        storePayment.setPayTime(new Date());
-//        storePayment.setTradeNo(tradeNo);
-//        storePayment.setBankSerialNo(bankSerialNo);
-//        storePayment.setBankTransactionId(bankTransactionId);
-//        storePaymentService.updateFsStorePayment(storePayment);
-//        //增加佣金
-//        if(storePayment.getCompanyId()!=null&&storePayment.getCompanyId()>0){
-//            companyService.addCompanyPaymentMoney(storePayment);
-//        }
-//        return "success";
-//
-//    }
-
-
 }

+ 1 - 70
fs-user-app/src/main/java/com/fs/app/controller/ProductController.java

@@ -38,8 +38,6 @@ public class ProductController extends  AppBaseController {
     @Autowired
     private IFsStoreProductService productService;
     @Autowired
-    private IFsStoreProductGroupService productGroupService;
-    @Autowired
     private IFsStoreProductCategoryService categoryService;
     @Autowired
     private IFsStoreProductAttrService attrService;
@@ -49,8 +47,6 @@ public class ProductController extends  AppBaseController {
     @Autowired
     private IFsStoreCartService cartService;
     @Autowired
-    private IFsStoreOrderService orderService;
-    @Autowired
     private IFsStoreProductRelationService productRelationService;
     @Autowired
     IErpGoodsService goodsService;
@@ -104,72 +100,7 @@ public class ProductController extends  AppBaseController {
         }
         List<FsStoreProductAttr> productAttr=attrService.selectFsStoreProductAttrByProductId(product.getProductId());
         List<FsStoreProductAttrValue> productValues=attrValueService.selectFsStoreProductAttrValueByProductId(product.getProductId());
-//        for(FsStoreProductAttrValue value:productValues){
-//            if(StringUtils.isEmpty(value.getGroupBarCode())){
-//                //单品
-//                ErpGoodsStockQueryRequert request=new ErpGoodsStockQueryRequert();
-//                request.setBarcode(value.getBarCode());
-//               // ErpGoodsStockQueryResponse response=goodsService.getGoodsStock(request);
-////                if(response.getStocks()!=null){
-////                    Integer stocks=0;
-////                    for(ErpGoodsStock stock:response.getStocks()){
-////                        Double goodsStock=Double.parseDouble(stock.getSalable_qty());
-////                        stocks+=goodsStock.intValue();
-////                    }
-////                    if(stocks<=0){
-////                        value.setStock(0);
-////                        attrValueService.updateFsStoreProductAttrValue(value);
-////                        productService.updateStock(productId);
-////                    }
-////                    else{
-////                        //更新库存
-////                        value.setStock(stocks);
-////                        attrValueService.updateFsStoreProductAttrValue(value);
-////                        productService.updateStock(productId);
-////                    }
-////
-////                }
-//            }
-//            else{
-//                //组合码
-//                FsStoreProductGroup group=productGroupService.selectFsStoreProductGroupByBarCode(value.getGroupBarCode());
-//                if(group!=null){
-//                    Integer totalStock=0;
-//                    JSONArray jsonArray= JSONUtil.parseArray(group.getProducts());
-//                    List<StoreProductGroupDTO> productGroupDTOS=JSONUtil.toList(jsonArray, StoreProductGroupDTO.class);
-//                    if(productGroupDTOS!=null){
-//                        for(StoreProductGroupDTO dto:productGroupDTOS){
-//                            FsStoreProductAttrValue attrValue=attrValueService.selectFsStoreProductAttrValueById(dto.getId());
-//                            ErpGoodsStockQueryRequert request=new ErpGoodsStockQueryRequert();
-//                            request.setBarcode(attrValue.getBarCode());
-//                            ErpGoodsStockQueryResponse response=goodsService.getGoodsStock(request);
-//                            if(response.getStocks()!=null){
-//                                Integer stocks=0;
-//                                for(ErpGoodsStock stock:response.getStocks()){
-//                                    Double goodsStock=Double.parseDouble(stock.getSalable_qty());
-//                                    stocks+=goodsStock.intValue();
-//                                }
-//                                if(stocks<=0){
-//                                    attrValue.setStock(0);
-//                                    attrValueService.updateFsStoreProductAttrValue(attrValue);
-//                                }
-//                                else{
-//                                    //更新库存
-//                                    attrValue.setStock(stocks);
-//                                    attrValueService.updateFsStoreProductAttrValue(attrValue);
-//                                }
-//                                totalStock+=stocks;
-//                            }
-//                        }
-//                    }
-//                    value.setStock(totalStock);
-//                    attrValueService.updateFsStoreProductAttrValue(value);
-//                    productService.updateStock(productId);
-//
-//                }
-//
-//            }
-//        }
+
         //获取用户的TOKEN写入足迹
         String userId=getUserId();
         if(userId!=null){

+ 10 - 112
fs-user-app/src/main/java/com/fs/app/controller/StoreOrderController.java

@@ -78,8 +78,6 @@ public class StoreOrderController extends  AppBaseController {
 
     Logger logger= LoggerFactory.getLogger(getClass());
 
-    @Autowired
-    private WxPayService wxPayService;
     @Autowired
     private IFsStoreOrderService orderService;
     @Autowired
@@ -95,12 +93,6 @@ public class StoreOrderController extends  AppBaseController {
     @Autowired
     private IFsPrescribeService prescribeService;
     @Autowired
-    private IPayService payService;
-    @Autowired
-    private FSSysConfig sysConfig;
-    @Autowired
-    private IErpOrderService erpOrderService;
-    @Autowired
     private ISysConfigService configService;
     @Autowired
     private IFsStoreAfterSalesService afterSalesService;
@@ -110,8 +102,6 @@ public class StoreOrderController extends  AppBaseController {
     PayService ybPayService;
     @Autowired
     TzBankService tzBankService;
-    @Autowired
-    private WxMaProperties properties;
 
 
     @Login
@@ -215,106 +205,23 @@ public class StoreOrderController extends  AppBaseController {
     @ApiOperation("获取订单-轮询获取信息")
     @GetMapping("/getStoreOrderByOrderIdTz")
     public R getStoreOrderByIdRemote(@RequestParam(value = "orderId",required = false) Long orderId,
-                                     @RequestParam(value = "payCode",required = false) String payCode, HttpServletRequest request){
-        // 根据订单查询payment
-        if(ObjectUtil.isNull(orderId)&&ObjectUtil.isNull(payCode)){
-            return R.error("参数错误");
-        }
-
-        List<FsStorePayment> fsStorePayments;
-        if(ObjectUtil.isNotNull(orderId)){
-            fsStorePayments = fsStorePaymentMapper.selectFsStorePaymentByOrder(orderId);
-        } else{
-            fsStorePayments = fsStorePaymentMapper.selectFsStorePaymentByPayCode(payCode);
-        }
-        // 如果已经有支付成功的记录
-        if(CollectionUtils.isNotEmpty(fsStorePayments)){
-            for (FsStorePayment fsStorePayment : fsStorePayments) {
-                // 如果状态为已支付或者已经退款
-                if(ObjectUtil.equal(fsStorePayment.getStatus(),1) || ObjectUtil.equal(fsStorePayment.getStatus(), -1)){
-                    return R.ok().put("orderId", orderId)
-                            .put("payCode", payCode)
-                            .put("status", fsStorePayment.getStatus());
-                }
-            }
-        }
-        // 如果没找到,查看付款信息是否有未支付的 且 类型为tzbank 且 trade_no 不为空的数据
-        // 调用台州银行接口查询订单信息
-        List<FsStorePayment> fsStorePayments1;
-        if(ObjectUtil.isNotNull(orderId)){
-            fsStorePayments1 = fsStorePaymentMapper.selectFsStorePaymentTzUnpayByOrder(orderId);
-        } else {
-            fsStorePayments1 = fsStorePaymentMapper.selectFsStorePaymentTzUnpayByPayCode(payCode);
-        }
-
-        if(CollectionUtils.isNotEmpty(fsStorePayments1)){
-            FsStorePayment fsStorePayment = fsStorePayments1.get(0);
-
-            RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
-
-            QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
-
-            queryOrderRestDTO.setOrderFlowNo(fsStorePayment.getTradeNo());
-            TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
-
-            queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
-
-            requestDTO.setReqBody(queryOrderRestDTO);
-            requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(fsStorePayment.getPayCode()));
-
-            TzReqResultDTO<QueryOrderInfoDTO> resultDTO = null;
-            try {
-                resultDTO = tzBankService.payQueryOrder(requestDTO);
-                String retCode = resultDTO.getRetCode();
-                // 如果查询支付成功
-                if(retCode.equals("00000000")){
-                    QueryOrderInfoDTO body = resultDTO.getBody();
-                    String status = body.getStatus();
-                    if("90".equals(status)){
-                        // 如果查询支付成功 更新订单状态
-                        orderService.payConfirm(1,orderId,fsStorePayment.getPayCode(),
-                                fsStorePayment.getTradeNo(),body.getChlTrxId(),fsStorePayment.getTradeNo());
-                        return R.ok().put("orderId", orderId)
-                                .put("payCode", payCode)
-                                .put("status", 1);
-                    } else if("70".equals(status)) {
-                        return R.ok().put("orderId", orderId)
-                                .put("payCode", payCode)
-                                .put("status", -1);
-                    }
-
-                }
-            } catch (Exception e) {
-                logger.error("台州银行支付回调查询失败:",e);
-            }
-
-        }
-        FsStoreOrder order=orderService.selectFsStoreOrderById(orderId);
-
-        if(ObjectUtil.isNotNull(order)){
-            return R.ok().put("orderId",orderId)
-                    .put("payCode", payCode)
-                    .put("status", order.getStatus());
-        } else {
-            // 如果没有订单信息可能是从微信收款而来
-            return R.ok().put("orderId", orderId)
-                    .put("payCode", payCode)
-                    .put("status", 0);
-        }
+                                     @RequestParam(value = "payCode",required = false) String payCode){
 
+        logger.info("获取订单-轮询获取信息, 订单ID: {}, payCode: {}", orderId,payCode);
+        return orderService.getStoreOrderByOrderIdTz(orderId,payCode);
     }
 
 
     @Login
     @ApiOperation("确认订单")
     @PostMapping("/confirm")
-    public R confirm(@Validated @RequestBody FsStoreConfirmOrderParam param, HttpServletRequest request){
+    public R confirm(@Validated @RequestBody FsStoreConfirmOrderParam param){
         return orderService.confirmOrder(Long.parseLong(getUserId()),param);
     }
     @Login
     @ApiOperation("计算订单金额")
     @PostMapping("/computed")
-    public R computed(@Validated @RequestBody FsStoreOrderComputedParam param, HttpServletRequest request){
+    public R computed(@Validated @RequestBody FsStoreOrderComputedParam param){
         FsStoreOrderComputeDTO dto=orderService.computedOrder(Long.parseLong(getUserId()),param);
         return R.ok().put("data",dto);
     }
@@ -322,7 +229,7 @@ public class StoreOrderController extends  AppBaseController {
     @Login
     @ApiOperation("创建订单")
     @PostMapping("/create")
-    public R create(@Validated @RequestBody FsStoreOrderCreateParam param, HttpServletRequest request){
+    public R create(@Validated @RequestBody FsStoreOrderCreateParam param){
         return orderService.createOrder(Long.parseLong(getUserId()),param);
     }
 
@@ -330,8 +237,7 @@ public class StoreOrderController extends  AppBaseController {
     @ApiOperation("支付")
     @PostMapping("/pay")
     @RepeatSubmit
-    //@Synchronized
-    public R pay(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param)
+    public R pay(@Validated @RequestBody FsStoreOrderPayParam param)
     {
         logger.info("开始处理支付请求, 订单号: {}, 支付类型: {}", param.getOrderId(), param.getPayType());
         R result = null;
@@ -355,7 +261,7 @@ public class StoreOrderController extends  AppBaseController {
     @ApiOperation("修改支付类型")
     @PostMapping("/editPayType")
     @Transactional
-    public R editPayType(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
+    public R editPayType(@Validated @RequestBody FsStoreOrderPayParam param) {
         FsStoreOrder order=orderService.selectFsStoreOrderById(param.getOrderId());
         if(order==null){
             return R.error("订单不存在");
@@ -363,14 +269,6 @@ public class StoreOrderController extends  AppBaseController {
         if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
             return R.error("订单状态不正确");
         }
-//        String userAddress = order.getUserAddress();
-//        String noAdd="南通市,镇江市,淮安市,江阴市,金华市,驻马店市,民权县";
-//        String[] split = noAdd.split(",");
-//        for (String s : split) {
-//            if (userAddress.contains(s)){
-//                return R.error("此地区暂不支持配送");
-//            }
-//        }
 
         String orderId=redisCache.getCacheObject("isPaying:"+order.getId());
         if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getId().toString())){
@@ -460,7 +358,7 @@ public class StoreOrderController extends  AppBaseController {
     @ApiOperation("支付尾款")
     @PostMapping("/payRemain")
     @Transactional
-    public R payRemain(HttpServletRequest request, @Validated @RequestBody FsStoreOrderPayParam param) {
+    public R payRemain(@Validated @RequestBody FsStoreOrderPayParam param) {
         FsStoreOrder order=orderService.selectFsStoreOrderById(param.getOrderId());
         if(order==null){
             return R.error("订单不存在");
@@ -661,7 +559,7 @@ public class StoreOrderController extends  AppBaseController {
     @Login
     @ApiOperation("获取订单总数")
     @GetMapping("/getOrderCount")
-    public R getOrderCount( HttpServletRequest request){
+    public R getOrderCount(){
         Integer count0=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),0);
         Integer count1=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),1);
         Integer count2=orderService.selectFsStoreOrderCount(Long.parseLong(getUserId()),2);