Jelajahi Sumber

小程序退款、再来一单、图片上传修复

hyq 6 tahun lalu
induk
melakukan
fab853b5f9

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -268,7 +268,7 @@ public class OrderController {
             }
         }
 
-        return R.ok();
+        return R.ok("退款成功");
     }
 
     /**

+ 3 - 2
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -232,7 +232,7 @@ public class OrderServiceImpl implements OrderService {
         if (null != couponVo) {
             userCouponDao.cancelOrder(couponVo);
         }
-        orderDao.update(order);
+        orderDao.update(order);//修改为退款中
 
         OrderRefundEntity mallOrderRefund = orderRefundDao.queryObjectByOrderId(order.getId());
 
@@ -240,11 +240,12 @@ public class OrderServiceImpl implements OrderService {
         orderRefund.setRefundId(result.getRefund_id());
         orderRefund.setOutRefundNo(result.getOut_refund_no());
         orderRefund.setRefundMoney(BigDecimal.valueOf(Long.valueOf(result.getRefund_fee())).divide(Constant.ONE_HUNDRED));
-        orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));
+        orderRefund.setRefundStatus(Integer.parseInt(Dict.RefundStatus.item_2.getItem()));//退款成功
         orderRefund.setModTime(new Date());
 
         if(mallOrderRefund !=null){
             orderRefund.setId(mallOrderRefund.getId());
+            orderRefund.setRefundType(mallOrderRefund.getRefundType());
             orderRefundDao.update(orderRefund);
         }else{
             orderRefund.setOrderId(Integer.parseInt(order.getId()+""));

+ 3 - 2
kmall-api/src/main/java/com/kmall/api/api/ApiCartController.java

@@ -334,7 +334,7 @@ public class ApiCartController extends ApiBaseAction {
             cartInfo.setList_pic_url(goodsVo.getList_pic_url());
             cartInfo.setNumber(goodsVo.getNumber());
             cartInfo.setStore_id(storeId);
-            cartInfo.setUser_id(loginUser.getId());
+            cartInfo.setUser_id(getUserId());
             cartInfo.setRetail_price(goodsVo.getRetail_price());
             cartInfo.setMarket_price(goodsVo.getMarket_price());
             cartInfo.setGoods_specification_name_value(goodsVo.getGoods_specification_name_value());
@@ -344,7 +344,8 @@ public class ApiCartController extends ApiBaseAction {
             cartInfo.setStockNum(productInfo.getStock_num());
 
             Map map = new HashMap();
-            map.put("user_id",loginUser.getId());
+            map.put("user_id", getUserId());
+            map.put("store_id", getStoreId());
             map.put("goods_id",goodsVo.getGoods_id());
             map.put("product_id",goodsVo.getProduct_id());
             map.put("number",goodsVo.getNumber());

+ 3 - 1
kmall-api/src/main/java/com/kmall/api/api/ApiOrderController.java

@@ -134,7 +134,8 @@ public class ApiOrderController extends ApiBaseAction {
         //查询物流轨迹
         List<Map> mapList = new ArrayList<>();
 
-        if(orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem())
+        if((orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem()) ||
+                orderInfo.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem()))
                 && orderInfo.getOrder_status() == Integer.parseInt(Dict.orderStatus.item_301.getItem())){
             Map map = new HashMap();
             map.put("AcceptStation", "交易完成,用户已提走");
@@ -401,6 +402,7 @@ public class ApiOrderController extends ApiBaseAction {
             if(mallOrderRefund !=null){
                 orderRefund.setId(mallOrderRefund.getId());
                 apiOrderRefundService.update(orderRefund);
+                return toResponsMsgSuccess("该订单已申请过退款,重新申请成功");
             }else{
                 orderRefund.setCreateTime(new Date());
                 apiOrderRefundService.save(orderRefund);

+ 13 - 3
kmall-api/src/main/java/com/kmall/api/api/ApiPayController.java

@@ -25,6 +25,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -56,7 +57,6 @@ public class ApiPayController extends ApiBaseAction {
      */
     @RequestMapping("index")
     public Object index(@LoginUser UserVo loginUser) {
-        //
         return toResponsSuccess("");
     }
 
@@ -64,8 +64,7 @@ public class ApiPayController extends ApiBaseAction {
      * 获取支付的请求参数
      */
     @GetMapping("pay_prepay")
-    public Object payPrepay(@LoginUser UserVo loginUser, Long[] orderIds) {
-        //
+    public Object payPrepay(@LoginUser UserVo loginUser, Long[] orderIds,String isMergePay) {
         List<Long> orderIdList=new ArrayList<>();
         String merchOrderSn = "";
         for(int i=0;i<orderIds.length;i++){
@@ -83,6 +82,17 @@ public class ApiPayController extends ApiBaseAction {
                 return toResponsObject(400, "订单号为"+orderInfo.getOrder_sn()+"的订单已支付,请不要重复操作", "");
             }
             merchOrderSn = orderInfo.getMerchOrderSn();
+            OrderVo orderVo = new OrderVo();
+            if(Dict.isMergePay.item_0.getItem().equalsIgnoreCase(isMergePay)){//如此次是单笔支付,则查询下单时该商户订单是否是拆单订单,如果都满足,则更新商户订单号,生成新的预支付信息
+                if(orderService.queryCountByMerchOrderSn(merchOrderSn) > 1) {//不止一笔订单则为拆单订单
+                    merchOrderSn = "EMATO" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
+                    orderInfo.setMerchOrderSn(merchOrderSn);
+                    orderVo.setMerchOrderSn(orderInfo.getMerchOrderSn());
+                }
+            }
+            orderVo.setIsMergePay(isMergePay);
+            orderVo.setId(orderInfo.getId());
+            orderService.update(orderVo);
 
             OrderProcessRecordEntity processRecordEntity = orderProcessRecordService.queryObjectByOrderSn(orderInfo.getOrder_sn());
             if(processRecordEntity != null){

+ 18 - 1
kmall-api/src/main/java/com/kmall/api/api/ApiUploadController.java

@@ -1,8 +1,10 @@
 package com.kmall.api.api;
 
 import com.kmall.api.annotation.IgnoreAuth;
+import com.kmall.common.fileserver.util.FileManager;
 import com.kmall.common.oss.OSSFactory;
 import com.kmall.api.util.ApiBaseAction;
+import com.kmall.common.utils.R;
 import com.kmall.common.utils.RRException;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -10,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.Date;
+
 /**
  * 作者: @author Scott <br>
  * 时间: 2017-09-08 13:20<br>
@@ -28,8 +32,21 @@ public class ApiUploadController extends ApiBaseAction {
         if (file.isEmpty()) {
             throw new RRException("上传文件不能为空");
         }
+//        //上传文件
+//        String url = OSSFactory.build().upload(file);
         //上传文件
-        String url = OSSFactory.build().upload(file);
+        String url = FileManager.upload(file);
+
+        /*//保存文件信息
+        SysOssEntity ossEntity = new SysOssEntity();
+        ossEntity.setUrl(url);
+        ossEntity.setCreateDate(new Date());
+        sysOssService.save(ossEntity);
+
+        R r = new R();
+        r.put("url", url);
+        r.put("link", url);
+        return r;*/
         return toResponsSuccess(url);
     }
 }

+ 32 - 0
kmall-api/src/main/java/com/kmall/api/contants/Dict.java

@@ -541,4 +541,36 @@ public class Dict {
             this.itemName = itemName;
         }
     }
+
+    /**
+     *  是否合并支付 0:单笔支付 1:合并支付
+     */
+    public enum isMergePay {
+        item_0("0", "单笔支付"),
+        item_1("1", "合并支付");
+
+        private String item;
+        private String itemName;
+
+        isMergePay(String item, String itemName) {
+            this.item = item;
+            this.itemName = itemName;
+        }
+
+        public String getItem() {
+            return item;
+        }
+
+        public void setItem(String item) {
+            this.item = item;
+        }
+
+        public String getItemName() {
+            return itemName;
+        }
+
+        public void setItemName(String itemName) {
+            this.itemName = itemName;
+        }
+    }
 }

+ 4 - 0
kmall-api/src/main/java/com/kmall/api/dao/ApiOrderMapper.java

@@ -36,4 +36,8 @@ public interface ApiOrderMapper extends BaseDao<OrderVo> {
     List<OrderVo> queryObjectByIdList(@Param("orderIdList")List<Long> orderIdList);
 
     List<OrderVo> queryObjectByMerchOrderSn(@Param("merchOrderSn")String merchOrderSn);
+
+    int queryCountByMerchOrderSn(@Param("merchOrderSn")String merchOrderSn);
+
+    List<OrderVo> queryOrderByMerchOrderSnAndRefundStatus(@Param("merchOrderSn")String merchOrderSn);
 }

+ 13 - 3
kmall-api/src/main/java/com/kmall/api/entity/OrderVo.java

@@ -169,6 +169,16 @@ public class OrderVo implements Serializable {
 
     private String stockNum;
 
+    private String isMergePay;
+
+    public String getIsMergePay() {
+        return isMergePay;
+    }
+
+    public void setIsMergePay(String isMergePay) {
+        this.isMergePay = isMergePay;
+    }
+
     public String getStockNum() {
         return stockNum;
     }
@@ -650,7 +660,7 @@ public class OrderVo implements Serializable {
 
         //如果订单已付款,没有发货,则可退款操作
         if (order_status == 201) {
-            handleOption.put("cancel", true);
+//            handleOption.put("cancel", true);
         }
 
         //如果订单已经发货,没有收货,则可收货操作和退款、退货操作
@@ -797,9 +807,9 @@ public class OrderVo implements Serializable {
         this.coupon_name = coupon_name;
     }
 
-    public Long getEnd_time() {
+    public Long getEnd_time() {//todo 配置未付款的倒计时时间
         if (getOrder_status() == 0) {
-            end_time = getAdd_time().getTime() + 60 * 10 * 1000;
+            end_time = getAdd_time().getTime() + 60 * 15 * 1000;
         }
         return end_time;
     }

+ 10 - 1
kmall-api/src/main/java/com/kmall/api/service/ApiOrderService.java

@@ -102,7 +102,7 @@ public class ApiOrderService {
             productInfo.minusSellVolume();
             apiProductMapper.updateStockNum(productInfo);
         }
-        apiOrderMapper.update(order);
+        update(order);
         // 判断是否有优惠券
         UserCouponVo couponVo = apiUserCouponMapper.queryByOrderId(order.getId());
         if (null != couponVo) {
@@ -112,6 +112,7 @@ public class ApiOrderService {
 
     public void update(OrderVo order) {
         order.setIsScan("0");
+        order.setModTime(new Date());
         apiOrderMapper.update(order);
     }
 
@@ -626,6 +627,7 @@ public class ApiOrderService {
         orderVo.setOrder_status(301);
         orderVo.setShipping_status(2);
         orderVo.setConfirm_time(new Date());
+        orderVo.setModTime(new Date());
         apiOrderMapper.update(orderVo);
     }
 
@@ -744,4 +746,11 @@ public class ApiOrderService {
     public List<OrderVo> queryObjectByMerchOrderSn(String merchOrderSn){
         return apiOrderMapper.queryObjectByMerchOrderSn(merchOrderSn);
     }
+    public int queryCountByMerchOrderSn(String merchOrderSn){
+        return apiOrderMapper.queryCountByMerchOrderSn(merchOrderSn);
+    }
+    public List<OrderVo> queryOrderByMerchOrderSnAndRefundStatus(String merchOrderSn){
+        return apiOrderMapper.queryOrderByMerchOrderSnAndRefundStatus(merchOrderSn);
+    }
+
 }

+ 3 - 3
kmall-api/src/main/java/com/kmall/api/service/ApiPayService.java

@@ -181,12 +181,12 @@ public class ApiPayService {
                     // 微信支付成功通知
                     orderService.notifyPaySuccess(orderInfo);
 
-                    // 打印机打印
+                   /* // 打印机打印 todo 后台打印小票
                     try {
                         orderService.printMsg(orderInfo.getId());
                     } catch (Exception e) {
                         logger.error("打印机打印异常【" + e.getMessage() + "】");
-                    }
+                    }*/
                 }
             }
         }
@@ -277,7 +277,7 @@ public class ApiPayService {
         String success_time = refundApiResult.getSuccess_time();
         String out_trade_no = refundApiResult.getOut_trade_no();//商户订单号
         // 业务处理
-        List<OrderVo> orderVoList = orderService.queryObjectByMerchOrderSn(out_trade_no);
+        List<OrderVo> orderVoList = orderService.queryOrderByMerchOrderSnAndRefundStatus(out_trade_no);
         Date successTime = DateUtils.strToDate(success_time);
         if(orderVoList != null && orderVoList.size()>0) {
             for(OrderVo orderInfo:orderVoList) {

+ 23 - 0
kmall-api/src/main/resources/mybatis/mapper/ApiOrderMapper.xml

@@ -68,6 +68,7 @@
         <result property="isRefundStatus" column="isRefundStatus"/>
         <result property="refundStatus" column="refund_status"/>
         <result property="approvalRemark" column="approval_remark"/>
+        <result property="isMergePay" column="is_merge_pay"/>
     </resultMap>
 
     <select id="queryObject" resultMap="orderMap">
@@ -222,6 +223,9 @@
         <if test="isScan != null" >
             is_scan,
         </if>
+        <if test="isMergePay != null" >
+            is_merge_pay,
+        </if>
         <if test="orderBizType != null" >
             order_biz_type,
         </if>
@@ -299,6 +303,9 @@
         <if test="isScan != null" >
             #{isScan,jdbcType=VARCHAR},
         </if>
+        <if test="isMergePay != null" >
+            #{isMergePay},
+        </if>
         <if test="orderBizType != null" >
             #{orderBizType,jdbcType=CHAR},
         </if>
@@ -382,6 +389,7 @@
          merch_sn,
         merch_order_sn,
         is_scan,
+        is_merge_pay,
          order_biz_type,
          pay_transaction_id,
          pay_mobile,
@@ -432,6 +440,7 @@
             #{orderInfo.merchSn,jdbcType=VARCHAR},
             #{orderInfo.merchOrderSn,jdbcType=VARCHAR},
             #{orderInfo.isScan,jdbcType=VARCHAR},
+            #{orderInfo.isMergePay},
             #{orderInfo.orderBizType,jdbcType=CHAR},
             #{orderInfo.payTransactionId,jdbcType=VARCHAR},
             #{orderInfo.payMobile,jdbcType=VARCHAR},
@@ -494,6 +503,9 @@
             <if test="isScan != null" >
                 is_scan = #{isScan,jdbcType=VARCHAR},
             </if>
+            <if test="isMergePay != null" >
+                is_merge_pay = #{isMergePay},
+            </if>
             <if test="orderBizType != null" >
                 order_biz_type = #{orderBizType,jdbcType=CHAR},
             </if>
@@ -574,4 +586,15 @@
         from mall_order a
         where a.merch_order_sn = #{merchOrderSn}
     </select>
+
+    <select id="queryCountByMerchOrderSn" resultType="java.lang.Integer">
+        select count(*)
+        from mall_order a
+        where a.merch_order_sn = #{merchOrderSn}
+    </select>
+
+    <select id="queryOrderByMerchOrderSnAndRefundStatus" resultMap="orderMap">
+        select * from mall_order o inner join mall_order_refund r on r.order_id = o.id where o.merch_order_sn = #{merchOrderSn}
+         and r.refund_status = 2
+    </select>
 </mapper>

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

@@ -27,7 +27,7 @@
         LEFT JOIN mall_product_store_rela c ON b.product_id = c.product_id
         AND c.store_id = a.store_id
         WHERE 1 = 1
-        AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -10 MINUTE)
+        AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
         AND a.order_status = 0 and a.order_type = 1
     </select>
     <update id="unpayPastUpdate">
@@ -50,7 +50,8 @@
     <select id="queryRefundOrderList" resultType="map">
         select a.pay_transaction_id,a.merch_order_sn,a.order_sn,a.order_status,a.pay_status,f.out_refund_no,f.refund_id,f.order_id,f.id 'orderRefundId'
         from mall_order a
-        inner join mall_order_refund f on a.id = f.order_id	where (f.out_refund_no is null or f.refund_id is null) and a.order_status != '101' and f.refund_status not in (1,3)
+        inner join mall_order_refund f on a.id = f.order_id	where (f.out_refund_no is null or f.refund_id is null) and a.order_status != '101' and f.refund_status
+        not in (1,3,4)
     </select>
 
     <select id="queryPayingOrderList" resultType="map">

+ 2 - 2
wx-mall/pages/commentPost/commentPost.js

@@ -67,9 +67,9 @@ Page({
       success: function (res) {
         if (!res.cancel) {
           if (res.tapIndex == 0) {
-            that.chooseWxImage('album', goodsIndex, pics)
+            that.chooseWxImage('album', goodsIndex, pics);
           } else if (res.tapIndex == 1) {
-            that.chooseWxImage('camera', goodsIndex, pics)
+            that.chooseWxImage('camera', goodsIndex, pics);
           }
         }
       }

+ 8 - 3
wx-mall/pages/pay/pay.js

@@ -5,13 +5,15 @@ var api = require('../../config/api.js');
 Page({
   data: {
     orderIds: [],
-    actualPrice: 0.00
+    actualPrice: 0.00,
+    isMergePay: ''
   },
   onLoad: function (options) {
     // 页面初始化 options为页面跳转所带来的参数
     this.setData({
       orderIds: options.orderIds,
-      actualPrice: options.actualPrice
+      actualPrice: options.actualPrice,
+      isMergePay: options.isMergePay
     })
     console.log(this.data.orderIds);
   },
@@ -38,7 +40,10 @@ Page({
     //   url: '/pages/payResult/payResult?status=1&orderId=' + that.data.orderId,
     // })
     // todo
-    util.request(api.PayPrepayId, { orderIds: that.data.orderIds, payType: 1 }).then(function (res) {
+    util.request(api.PayPrepayId, {
+      orderIds: that.data.orderIds, payType: 1,
+      isMergePay: that.data.isMergePay
+      }).then(function (res) {
       if (res.errno === 0) {
         let payParam = res.data;
         wx.requestPayment({

+ 1 - 1
wx-mall/pages/shopping/checkout/checkout.js

@@ -304,7 +304,7 @@ Page({
           orderIds[i] = res.data.orderInfo[i].id;
         }
         wx.redirectTo({
-          url: '/pages/pay/pay?orderIds=' + orderIds + '&actualPrice=' + actualPrice
+          url: '/pages/pay/pay?orderIds=' + orderIds + '&actualPrice=' + actualPrice + '&isMergePay=1'//此处提交支付属于合并支付
         })
 
       } else {

+ 1 - 1
wx-mall/pages/ucenter/order/order.js

@@ -84,7 +84,7 @@ Page({
   payOrder(event) {
         wx.redirectTo({
           url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
-                + '&actualPrice=' + event.target.dataset.actualPrice
+            + '&actualPrice=' + event.target.dataset.actualPrice + '&isMergePay=0'//此处提交支付属于单笔支付
         })
   }, 
   applyRefund(event) {

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

@@ -64,13 +64,13 @@
     <view class="list-cell">
       <view class="goods-list">
         <view wx:for="{{orderGoods}}" wx:key="{{index}}" class="goods-list-cell">
-          <view wx:if ='{{currentStoreId != orderInfo.store_id}}'>
+          <view wx:if ='{{currentStoreId != orderInfo.store_id || (orderInfo.orderBizType ==02 || orderInfo.orderBizType == 10)}}'>
             <image class="order-image" src="{{item.list_pic_url}}"></image>
             <text class="name">{{item.goods_name}}</text>
             <text class="num fr">x{{item.number}}</text>
             <text class="price fr">¥{{item.retail_price}}</text>
           </view>
-          <navigator open-type='navigate' wx:if = '{{currentStoreId == orderInfo.store_id}}' url='/pages/goods/goods?id={{item.goods_id}}'>
+          <navigator open-type='navigate' wx:if = '{{currentStoreId == orderInfo.store_id && (orderInfo.orderBizType ==00 || orderInfo.orderBizType == 11)}}' url='/pages/goods/goods?id={{item.goods_id}}'>
             <image class="order-image" src="{{item.list_pic_url}}"></image>
             <text class="name">{{item.goods_name}}</text>
             <text class="num fr">x{{item.number}}</text>