Parcourir la source

Merge branch 'master' of hyq/kmall-pt into master

黄亚琴 il y a 6 ans
Parent
commit
651a382d67

+ 25 - 2
kmall-api/src/main/java/com/kmall/api/api/ApiOrderController.java

@@ -13,6 +13,7 @@ import com.kmall.api.service.express.kdn.ApiKdniaoService;
 import com.kmall.api.util.ApiBaseAction;
 import com.kmall.api.util.ApiPageUtils;
 import com.kmall.common.utils.Constant;
+import com.kmall.common.utils.DateUtils;
 import com.kmall.common.utils.Query;
 import com.kmall.common.utils.wechat.WechatRefundApiResult;
 import com.kmall.common.utils.wechat.WechatUtil;
@@ -189,7 +190,7 @@ public class ApiOrderController extends ApiBaseAction {
     }
 
     @GetMapping("detailList")
-    public Object detailList(@LoginUser UserVo loginUser, Long[] orderIds) {
+    public Object detailList(@LoginUser UserVo loginUser, Long[] orderIds,Integer status) {
         List<Long> orderIdList=new ArrayList<>();
         for(int i=0;i<orderIds.length;i++){
             orderIdList.add(orderIds[i]);
@@ -204,10 +205,32 @@ public class ApiOrderController extends ApiBaseAction {
                 return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单不存在", "");
             }
             actualPrice = actualPrice.add(orderInfo.getActual_price());
+            /*if (status == 0) {
+                OrderVo orderVo = new OrderVo();
+                orderVo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_0.getItem()));
+                orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_0.getItem()));
+                orderVo.setId(orderInfo.getId());
+                orderService.update(orderVo);
+            }*/
+            String out_trade_no = orderInfo.getMerchOrderSn();
+            WechatRefundApiResult result = WechatUtil.wxOrderQuery(out_trade_no);
+            if (result.getReturn_code().equalsIgnoreCase("SUCCESS")) {
+                if(result.getResult_code().equalsIgnoreCase("SUCCESS")
+                        && result.getTrade_state().equalsIgnoreCase("NOTPAY")) {//订单未支付
+                    OrderVo orderVo = new OrderVo();
+                    orderVo.setOrder_status(Integer.parseInt(Dict.orderStatus.item_0.getItem()));
+                    orderVo.setPay_status(Integer.parseInt(Dict.payStatus.item_0.getItem()));
+                    orderVo.setId(orderInfo.getId());
+                    orderService.update(orderVo);
+                }else{
+                    logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate 微信查询接口返回失败信息:code 【"+result.getErr_code()+"】,des【"+result.getErr_code_des()+"】");
+                }
+            }else {
+                logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate 微信查询接口调用失败: "+result.getReturn_msg());
+            }
         }
         //订单的商品
         List<OrderGoodsVo> orderGoods = orderGoodsService.queryListByIds(orderIdList);
-
         resultObj.put("actualPrice", actualPrice);
         resultObj.put("orderGoods", orderGoods);
         return toResponsSuccess(resultObj);

+ 13 - 12
kmall-api/src/main/java/com/kmall/api/service/ApiOrderService.java

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -179,15 +180,19 @@ public class ApiOrderService {
         for (CartVo goodsItem : checkedGoodsList) {
             //取得规格的信息,判断规格库存
             ProductVo productInfo = apiProductMapper.queryByStoreId(goodsItem.getProduct_id(), storeId);
-            if (null == productInfo || null == productInfo.getStock_num() || productInfo.getStock_num() < goodsItem.getNumber()) {
-                resultObj.put("errno", 400);
-                resultObj.put("errmsg", "库存不足,仅剩余" + productInfo.getStock_num());
-                return resultObj;
+            synchronized (productInfo){
+                if (null == productInfo || null == productInfo.getStock_num() || productInfo.getStock_num() < goodsItem.getNumber()) {
+                    resultObj.put("errno", 400);
+                    resultObj.put("errmsg", "库存不足,仅剩余" + productInfo.getStock_num());
+                    return resultObj;
+                }else{
+                    productInfo.setStock_num(productInfo.getStock_num() - goodsItem.getNumber());
+                    productInfo.setStore_id(storeId);
+                    productInfo.addSellVolume();
+                    productVos.add(productInfo);
+                    apiProductMapper.updateStockNum(productInfo);
+                }
             }
-            productInfo.setStock_num(productInfo.getStock_num() - goodsItem.getNumber());
-            productInfo.setStore_id(storeId);
-            productInfo.addSellVolume();
-            productVos.add(productInfo);
         }
 
         BigDecimal freightPrice00 = new BigDecimal(0.00);
@@ -294,10 +299,6 @@ public class ApiOrderService {
             }
             orderProcessRecordMapper.saveBatch(processRecordEntityList);//新增订单流转信息
 
-            for (ProductVo productVo : productVos) {
-                apiProductMapper.updateStockNum(productVo);
-            }
-
             //清空已购买的商品
             apiCartMapper.deleteByCart(loginUser.getId(), storeId, 1);
             resultObj.put("errno", 0);

+ 32 - 6
kmall-schedule/src/main/java/com/kmall/schedule/service/QzOrderService.java

@@ -295,14 +295,17 @@ public class QzOrderService {
             for (Map map : orderList) {
                 String out_trade_no = MapUtils.getString("merch_order_sn", map);
                 String orderId = MapUtils.getString("order_id", map);
+                String add_time = MapUtils.getString("add_time", map);
+                Date addTime = DateUtils.strToDate(add_time);
+                Date nowDate = new Date();
                 WechatRefundApiResult result = WechatUtil.wxOrderQuery(out_trade_no);
                 if (result.getReturn_code().equalsIgnoreCase("SUCCESS")) {
                     if(result.getResult_code().equalsIgnoreCase("SUCCESS") && result.getTrade_state().equalsIgnoreCase("SUCCESS")) {
                         Date successTime = DateUtils.convertStringToDate(result.getTime_end(),DateUtils.DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS);
 
                         Map orderRaram = new HashMap();
-                        orderRaram.put("payStatus", 2);
-                        orderRaram.put("orderStatus", 201);
+                        orderRaram.put("payStatus", 2);//已支付
+                        orderRaram.put("orderStatus", 201);//已支付
                         orderRaram.put("payTransactionId", result.getTransaction_id());
                         orderRaram.put("payTime", successTime);
                         orderRaram.put("orderId", orderId);
@@ -310,8 +313,13 @@ public class QzOrderService {
                     }else if(result.getResult_code().equalsIgnoreCase("SUCCESS")
                             && result.getTrade_state().equalsIgnoreCase("NOTPAY")) {//订单未支付
                         Map orderRaram = new HashMap();
-                        orderRaram.put("payStatus", 0);
-                        orderRaram.put("orderStatus", 0);
+                        if(getDateBetween(addTime,nowDate) >= 15){//订单下单时间超过15分钟直接取消订单
+                            orderRaram.put("payStatus", 0);//支付状态未支付
+                            orderRaram.put("orderStatus", 101);//订单状态已取消
+                        }else{
+                            orderRaram.put("payStatus", 0);//支付状态未支付
+                            orderRaram.put("orderStatus", 0);//订单状态未支付
+                        }
                         orderRaram.put("orderId", orderId);
                         qzOrderMapper.updateOrderInfo(orderRaram);
                     }else{
@@ -327,7 +335,23 @@ public class QzOrderService {
         logger.info(">>>>>>>>>>>>>>>>>>>>orderQueryUpdate is end ");
     }
 
+    public long getDateBetween(Date begin,Date end){
+        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        long between = (end.getTime() - begin.getTime())/1000;
+
+        long min = between/60;
+
+        return min;
+    }
     public static void main(String[] args) {
+
+        SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        long between = (new Date().getTime() - DateUtils.strToDate("2018-11-16 09:30:12").getTime())/1000;
+
+        long min = between/60;
+        System.out.println(min);
 //        Calendar calendar = Calendar.getInstance();
 //        calendar.add(Calendar.DAY_OF_MONTH, 3);
 //
@@ -343,10 +367,12 @@ public class QzOrderService {
 
         long currentTime = System.currentTimeMillis() + 2 * 60 * 60 * 1000;
         Date date = new Date(currentTime);
-        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String nowTime="";nowTime= df.format(date);
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String nowTime="";
+        nowTime= df.format(date);
         System.out.println(nowTime);
 
-        Date successTime = DateUtils.strToDate("2018-11-02 14:57:12");
+        Date successTime = DateUtils.strToDate("2018-11-02 14:57:12.0");
         System.out.println(successTime);
     }
 }

+ 1 - 1
kmall-schedule/src/main/resources/mybatis/mapper/QzOrderMapper.xml

@@ -56,7 +56,7 @@
     </select>
 
     <select id="queryPayingOrderList" resultType="map">
-		select a.pay_transaction_id,a.order_sn,a.order_status,a.pay_status,a.id 'order_id',a.merch_order_sn
+		select a.pay_transaction_id,a.order_sn,a.order_status,a.pay_status,a.id 'order_id',a.merch_order_sn,date_format(a.add_time,'%Y-%m-%d %H:%i:%s') as add_time
         from mall_order a where (a.order_status in ('100','201') and a.pay_status in (1,2))
         and (a.pay_transaction_id = '' or a.pay_transaction_id is null or a.pay_time is null or a.pay_time = '')
     </select>

+ 2 - 1
wx-mall/pages/cart/cart.js

@@ -428,7 +428,8 @@ Page({
           productList: res.data.productList,
           openAttr: !that.data.openAttr,
           stockNum: res.data.productList[0].stock_num,
-          cartNumber: res.data.cartNumber
+          cartNumber: res.data.cartNumber,
+          checkedSpecText: res.data.specificationList[0].valueList[0].value
         });
         //
         let _specificationList = res.data.specificationList;

+ 4 - 3
wx-mall/pages/goods/goods.js

@@ -62,7 +62,8 @@ Page({
           userHasCollect: res.data.userHasCollect,
           stockNum: res.data.stockNum,
           cartNumber: res.data.cartNumber,
-          defaultFreight: res.data.defaultFreight
+          defaultFreight: res.data.defaultFreight,
+          checkedSpecText: res.data.specificationList[0].valueList[0].value
         });
         wx.hideLoading();
 
@@ -86,8 +87,8 @@ Page({
         let _specificationList = that.data.specificationList;
         for (let i = 0; i < _specificationList.length; i++) {
           if (_specificationList[i].valueList.length == 1) {
-            //如果已经选中,则反选
-            _specificationList[i].valueList[0].checked = false;
+            //如果已经选中,则反选,前端默认选中
+            _specificationList[i].valueList[0].checked = true;
           }
         }
         that.setData({

+ 14 - 3
wx-mall/pages/hotGoods/hotGoods.js

@@ -24,7 +24,9 @@ Page({
     specificationList: {},
     checkedSpecText: '请选择规格数量',
     number: 1,
-    retailPrice:''
+    retailPrice: '',
+    stockNum: 0,
+    cartNumber: 0,
   },
   toggleNav() {
     this.setData({
@@ -154,6 +156,9 @@ Page({
   //购物车增加
   addCart: function (e) {
     let that = this;
+    that.setData({
+      number: 1
+    });
     var goodsId = e.currentTarget.dataset.goodsId;
     var retailPrice = e.currentTarget.dataset.retailPrice; 
     util.request(api.GoodsSku, {
@@ -165,7 +170,10 @@ Page({
           specificationList: res.data.specificationList,
           productList: res.data.productList,
           openAttr: !that.data.openAttr,
-          retailPrice: retailPrice
+          retailPrice: retailPrice,
+          stockNum: res.data.productList[0].stock_num,
+          cartNumber: res.data.cartNumber,
+          checkedSpecText: res.data.specificationList[0].valueList[0].value
         });
         //
         let _specificationList = res.data.specificationList;
@@ -255,7 +263,10 @@ Page({
         })
         that.getFootCart();
       } else {
-        util.showErrorToast(res.errmsg)
+        wx.showToast({
+          title: res.errmsg,
+          icon: 'none'
+        })
       }
     });
   },

+ 1 - 1
wx-mall/pages/hotGoods/hotGoods.wxml

@@ -117,7 +117,7 @@
         <view class="selnum">
           <view class="cut" bindtap="cutNumber">-</view>
           <input value="{{number}}" class="number" disabled="true" type="number" />
-          <view class="add" bindtap="addNumber">+</view>
+          <view class="{{number+cartNumber>= stockNum? 'addEnabel':'add'}}" bindtap="{{number+cartNumber>= stockNum ? '':'addNumber'}}">+</view>
         </view>
       </view>
     </view>

+ 7 - 0
wx-mall/pages/hotGoods/hotGoods.wxss

@@ -338,4 +338,11 @@ page{
   flex: 1;
   text-align: center;
   color: #fff;
+}
+.addEnabel {
+  width: 93.75rpx;
+  height: 100%;
+  text-align: center;
+  line-height: 65rpx;
+  color: #ccc;
 }

+ 2 - 1
wx-mall/pages/payResult/payResult.js

@@ -23,7 +23,8 @@ Page({
     getOrderDetail() {
         let that = this;
         util.request(api.OrderDetailList, {
-            orderIds: that.data.orderIds
+            orderIds: that.data.orderIds,
+            status:that.data.status
         }).then(function (res) {
             if (res.errno === 0) {
                 console.log(res.data);

+ 1 - 1
wx-mall/pages/payResult/payResult.wxml

@@ -18,7 +18,7 @@
       </view>
       <view class="btns">
         <navigator class="btn" url="/pages/ucenter/order/order" open-type="redirect">查看订单</navigator>
-        <navigator class="btn" url="/pages/pay/pay?orderIds={{orderIds}}&actualPrice={{actualPrice}}" open-type="redirect">重新付款</navigator>
+        <navigator class="btn" url="/pages/pay/pay?orderIds={{orderIds}}&actualPrice={{actualPrice}}&isMergePay=0" open-type="redirect">重新付款</navigator>
       </view>
     </view>
   </view>

+ 2 - 2
wx-mall/pages/ucenter/orderDetail/orderDetail.js

@@ -61,8 +61,8 @@ Page({
   payOrder() {
     let that = this;
     wx.redirectTo({
-      url: '/pages/pay/pay?orderId=' + that.data.orderId
-      + '&actualPrice=' + that.data.orderInfo.actual_price
+      url: '/pages/pay/pay?orderIds=' + that.data.orderId
+        + '&actualPrice=' + that.data.orderInfo.actual_price + '&isMergePay=0'
     })
   },
   onReady: function () {

+ 2 - 1
wx-mall/pages/ucenter/orderDetail/orderDetail.wxml

@@ -17,8 +17,9 @@
       <view class="list-cell">
         <view class="list-cell-bd">
           <view class="list-label week3">
+            {{orderInfo.order_status==0?"您的订单待付款":""}}
             {{orderInfo.order_status==101?"您的订单已取消":""}}
-            {{orderInfo.order_status==100?"订单正在付款中":""}}
+            {{orderInfo.order_status==100?"您的订单正在付款中":""}}
             {{orderInfo.order_status==201?"您的订单已付款":""}}
             {{orderInfo.order_status==300?"您的订单已发货":""}}   
             {{orderInfo.order_status==301?"用户已确认收货":""}}