Browse Source

代码调整

baolei 6 months ago
parent
commit
b27e175db0

+ 71 - 71
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/controller/OrderApiController.java

@@ -69,76 +69,76 @@ public class OrderApiController extends BaseApiController {
     public OrderDetailResponse detail(OrderDetailRequest request){
         return orderServiceI.get(getUserContext(), request);
     }
-
-    /**
-     * 支付返回接口(未定)
-     */
-    // 微信支付支付通知接口
-    @PostMapping("/wxpay/callback")
-    public void callback(HttpServletRequest request, HttpServletResponse response) {
-        Date nowDate = DateUtils.getNowDate();
-
-        try {
-            String notifyData = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8);
-            WxPayOrderNotifyV3Result rV3Result = wxPayService.parseOrderNotifyV3Result(notifyData, null);
-            WxPayOrderNotifyV3Result.DecryptNotifyResult result = rV3Result.getResult();
-            String outTradeNo = result.getOutTradeNo();
-
-            // 通过outTradeNo查找paymentInfo
-            PaymentInfo paymentInfo = orderServiceI.selectPaymentInfoByOutTradeNo(outTradeNo);
-
-            // 通过outTradeNo更新订单状态
-            Order order = orderService.selectOrderByOrderId(paymentInfo.getOrderId());
-
-            if (EOrderStatus.PAYED.getVal().equals(order.getOrderStatus())) {
-                // 如果状态已修改,则返回
-                return;
-            }
-
-            paymentInfo.setSuccessTime(nowDate);
-            paymentInfo.setTransactionId(result.getTransactionId());
-            paymentInfo.setTradeType(result.getTradeType());
-            paymentInfo.setTradeState(result.getTradeState());
-            paymentInfo.setTradeStateDesc(result.getTradeStateDesc());
-            paymentInfo.setBankType(result.getBankType());
-            paymentInfo.setSuccessTime(DateUtils.parseDate(result.getSuccessTime()));
-
-            paymentInfo.setUpdateUser("WXPAY");
-            paymentInfo.setUpdateTime(nowDate);
-
-            paymentInfoService.updatePaymentInfo(paymentInfo);
-
-            if (ETradeState.SUCCESS.getVal().equals(result.getTradeState())) {
-                // 支付成功
-                //锁数据 for update
-                order = orderServiceI.lockOrderByPrescId(order.getOrderId());
-
-                order.setPayTime(nowDate);
-                order.setOrderStatus(EOrderStatus.PAYED.getVal());
-                order.setUpdateTime(nowDate);
-                order.setUpdateUser("WXPAY");
-                orderService.updateOrder(order);
-
-            }
-
-        } catch (Exception e) {
-            log.error(e.getMessage());
-            try {
-                buildFailResult(response);
-            } catch (Exception e1) {
-                log.error(e1.getMessage());
-            }
-        }
-    }
-
-    private void buildFailResult(HttpServletResponse response) throws Exception {
-        response.setStatus(400);
-        response.getWriter().write(objectMapper.writeValueAsString(new HashMap<String, String>() {
-            {
-                put("code", "FAIL");
-                put("message", "失败");
-            }
-        }));
-    }
+//
+//    /**
+//     * 支付返回接口(未定)
+//     */
+//    // 微信支付支付通知接口
+//    @PostMapping("/wxpay/callback")
+//    public void callback(HttpServletRequest request, HttpServletResponse response) {
+//        Date nowDate = DateUtils.getNowDate();
+//
+//        try {
+//            String notifyData = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8);
+//            WxPayOrderNotifyV3Result rV3Result = wxPayService.parseOrderNotifyV3Result(notifyData, null);
+//            WxPayOrderNotifyV3Result.DecryptNotifyResult result = rV3Result.getResult();
+//            String outTradeNo = result.getOutTradeNo();
+//
+//            // 通过outTradeNo查找paymentInfo
+//            PaymentInfo paymentInfo = orderServiceI.selectPaymentInfoByOutTradeNo(outTradeNo);
+//
+//            // 通过outTradeNo更新订单状态
+//            Order order = orderService.selectOrderByOrderId(paymentInfo.getOrderId());
+//
+//            if (EOrderStatus.PAYED.getVal().equals(order.getOrderStatus())) {
+//                // 如果状态已修改,则返回
+//                return;
+//            }
+//
+//            paymentInfo.setSuccessTime(nowDate);
+//            paymentInfo.setTransactionId(result.getTransactionId());
+//            paymentInfo.setTradeType(result.getTradeType());
+//            paymentInfo.setTradeState(result.getTradeState());
+//            paymentInfo.setTradeStateDesc(result.getTradeStateDesc());
+//            paymentInfo.setBankType(result.getBankType());
+//            paymentInfo.setSuccessTime(DateUtils.parseDate(result.getSuccessTime()));
+//
+//            paymentInfo.setUpdateUser("WXPAY");
+//            paymentInfo.setUpdateTime(nowDate);
+//
+//            paymentInfoService.updatePaymentInfo(paymentInfo);
+//
+//            if (ETradeState.SUCCESS.getVal().equals(result.getTradeState())) {
+//                // 支付成功
+//                //锁数据 for update
+//                order = orderServiceI.lockOrderByPrescId(order.getOrderId());
+//
+//                order.setPayTime(nowDate);
+//                order.setOrderStatus(EOrderStatus.PAYED.getVal());
+//                order.setUpdateTime(nowDate);
+//                order.setUpdateUser("WXPAY");
+//                orderService.updateOrder(order);
+//
+//            }
+//
+//        } catch (Exception e) {
+//            log.error(e.getMessage());
+//            try {
+//                buildFailResult(response);
+//            } catch (Exception e1) {
+//                log.error(e1.getMessage());
+//            }
+//        }
+//    }
+//
+//    private void buildFailResult(HttpServletResponse response) throws Exception {
+//        response.setStatus(400);
+//        response.getWriter().write(objectMapper.writeValueAsString(new HashMap<String, String>() {
+//            {
+//                put("code", "FAIL");
+//                put("message", "失败");
+//            }
+//        }));
+//    }
 
 }

+ 2 - 1
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/data/domain/MercProdRequest.java

@@ -1,9 +1,10 @@
 package com.xingxi.api.data.domain;
 
+import com.xingxi.api.common.PageDTO;
 import lombok.Data;
 
 @Data
-public class MercProdRequest {
+public class MercProdRequest extends PageDTO {
 
     private Long mercProdId;
 

+ 0 - 3
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/service/impl/OrderApiServiceImpl.java

@@ -37,7 +37,6 @@ import com.xingxi.common.enums.EOrderStatus;
 import com.xingxi.common.exception.BusinessException;
 import com.xingxi.common.mq.bo.order.OrderBO;
 import com.xingxi.common.mq.publisher.order.OrderCreatedMqPublisher;
-import com.xingxi.common.mq.publisher.order.OrderPayedMqPublisher;
 import com.xingxi.common.utils.DateUtils;
 import com.xingxi.common.utils.PageUtils;
 import com.xingxi.common.utils.StringUtils;
@@ -55,8 +54,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-import org.springframework.validation.annotation.Validated;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;

+ 64 - 1
08.src/Xingxi/xingxi-miniprogram-api/src/main/java/com/xingxi/api/service/impl/ProdApiServiceImpl.java

@@ -1,12 +1,17 @@
 package com.xingxi.api.service.impl;
 
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.xingxi.api.data.domain.OrderDTO;
 import com.xingxi.api.data.mapper.WxApiProductMapper;
 import com.xingxi.api.data.domain.MercProdRequest;
 import com.xingxi.api.data.domain.MercProdResponse;
 import com.xingxi.api.model.ProdAttrResponse;
 import com.xingxi.api.service.ProdServiceI;
+import com.xingxi.business.Order.domain.Order;
 import com.xingxi.common.enums.EDelFlag;
 import com.xingxi.common.enums.ERoleKey;
+import com.xingxi.common.utils.PageUtils;
 import com.xingxi.common.utils.StringUtils;
 import com.xingxi.master.merchant.domain.MerchantProd;
 import com.xingxi.master.product.domain.*;
@@ -68,7 +73,65 @@ class ProdApiServiceImpl implements ProdServiceI {
 
     @Override
     public List<MercProdResponse> selectMercProdList(MercProdRequest request) {
-        return productMapper.selectProductList(request);
+
+        Integer pageNum = request.getPageNum();
+        Integer pageSize = request.getPageSize();
+        PageUtils.startPage();
+        Page<MercProdResponse> rtn  = PageHelper.startPage(pageNum, pageSize)
+                .doSelectPage(() -> productMapper.selectProductList(request));
+
+//        List<MercProdResponse> rtn = productMapper.selectProductList(request);
+
+        for (MercProdResponse mp : rtn) {
+            ProdPic condPic = new ProdPic();
+            condPic.setProdId(mp.getProdId());
+            condPic.setDelFlag(EDelFlag.NO.getVal());
+
+            List<ProdPic> prodPicList = prodPicService.selectProdPicList(condPic);
+
+            mp.setProdPicList(prodPicList);
+
+            ProdAttr condAttr = new ProdAttr();
+            condAttr.setProdId(mp.getProdId());
+            condAttr.setDelFlag(EDelFlag.NO.getVal());
+
+            List<ProdAttr> prodAttrList = prodAttrService.selectProdAttrList(condAttr);
+
+            List<ProdAttrResponse> prodAttrResponseList = new ArrayList<>();
+
+            for (ProdAttr prodAttr : prodAttrList) {
+                ProdAttrResponse prodAttrResponse = new ProdAttrResponse();
+
+                prodAttrResponse.setProdAttrId(prodAttr.getProdAttrId());
+                prodAttrResponse.setProdId(prodAttr.getProdId());
+                prodAttrResponse.setAttrName(prodAttr.getAttrName());
+                prodAttrResponse.setAttrType(prodAttr.getAttrType());
+                prodAttrResponse.setDelFlag(prodAttr.getDelFlag());
+
+                ProdAttrPrice condPrice = new ProdAttrPrice();
+                condPrice.setProdAttrId(prodAttr.getProdAttrId());
+                condPrice.setProdId(prodAttr.getProdId());
+                condPrice.setDelFlag(EDelFlag.NO.getVal());
+                condPrice.setBuyerRoleKey(ERoleKey.CUSTOMER.getCode());
+                condPrice.setSellerId(mp.getMercId());
+
+                List<ProdAttrPrice> priceList = prodAttrPriceService.selectProdAttrPriceList(condPrice);
+                if (priceList != null && !priceList.isEmpty()) {
+                    prodAttrResponse.setProdAttrPrice(priceList.get(0));
+                }
+
+                ProdAttrJoint condJoint = new ProdAttrJoint();
+                condJoint.setDelFlag(EDelFlag.NO.getVal());
+                condJoint.setProdId(prodAttr.getProdId());
+                condJoint.setProdAttrId(prodAttr.getProdAttrId());
+
+                List<ProdAttrJoint> prodAttrJointList = prodAttrJointService.selectProdAttrJointList(condJoint);
+                prodAttrResponse.setProdAttrJointList(prodAttrJointList);
+            }
+            mp.setProdAttrList(prodAttrResponseList);
+        }
+
+        return rtn;
     }
 
     @Override

+ 1 - 1
08.src/Xingxi/xingxi-miniprogram-api/src/main/resources/META-INF/sqlmap/WxApiProductMapper.xml

@@ -19,7 +19,7 @@
     </resultMap>
 
     <select id="selectProductList" parameterType="MercProdRequest" resultMap="MercProdResponse">
-        SELECT mmp.mercProdId,mmp.mercId,mp.prodClassId,mmp.prodId,mp.prodName,mp.idId,mp.designerId,mp.description,mp.prodStatus,mmp.delFlag
+        SELECT mmp.mercProdId,mmp.mercId,mp.prodClassId,mmp.prodId,mp.prodName,mp.Id,mp.designerId,mp.description,mp.prodStatus,mmp.delFlag
         FROM m_merchant_prod mmp
         LEFT JOIN m_prod mp ON mmp.prodId = mp.id
         <where>