Browse Source

一些功能

Kirin 3 years ago
parent
commit
fef0b5732a
2 changed files with 26 additions and 4 deletions
  1. 22 0
      app/api/controller/order/StoreOrderController.php
  2. 4 4
      app/models/store/StoreOrder.php

+ 22 - 0
app/api/controller/order/StoreOrderController.php

@@ -369,6 +369,28 @@ class StoreOrderController
         return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), $type, $page, $limit, $search));
     }
 
+    public function gift($id, Request $request)
+    {
+        list($uid) = UtilService::postMore([['uid', 0]]);
+        if (!$uid) return app('json')->fail('请选择要赠送的用户');
+        if (!\app\admin\model\order\StoreOrder::where('id', $id)
+            ->where('uid', $uid)
+            ->where('refund_status', 0)
+            ->where('paid', 1)
+            ->where('status', 0)
+            ->where('is_del', 0)
+            ->where('is_system_del', 0)
+            ->where('is_system_del', 0)
+            ->where('store_id', 0)
+            ->where('shipping_type', 2)
+            ->where('gift_uid', 0)
+            ->find()
+        ) return app('json')->fail('订单错误');
+        $res = StoreOrder::where('id', $id)->update(['gift_uid' => $uid]);
+        if ($res) return app('json')->fail('赠送成功');
+        else return app('json')->fail('赠送失败');
+    }
+
     /**
      * 订单详情
      * @param Request $request

+ 4 - 4
app/models/store/StoreOrder.php

@@ -1161,7 +1161,7 @@ class StoreOrder extends BaseModel
         else if ($status == -3)//退款
             return $model->where('paid', 1)->where('refund_status', 'IN', '1,2');
         else if ($status == 10086)//退款
-            return $model->where('paid', 1)->where('status', 0)->where('refund_status', 0)->where('store_id', 0)->where('shipping_type', 2);
+            return $model->where('paid', 1)->where('refund_status', 0)->where('store_id', 0)->where('shipping_type', 2);
 //        else if($status == 11){
 //            return $model->where('order_id','IN',implode(',',$orderId));
 //        }
@@ -1182,10 +1182,10 @@ class StoreOrder extends BaseModel
      */
     public static function getUserOrderList($uid, $status = '', $page = 0, $limit = 8)
     {
-        if ($page) $list = self::statusByWhere($status, $uid)->where('is_del', 0)->where('uid', $uid)
+        if ($page) $list = self::statusByWhere($status, $uid)->where('is_del', 0)->where('uid|gift_uid', $uid)
             ->field('add_time,seckill_id,bargain_id,combination_id,id,order_id,pay_price,total_num,total_price,pay_postage,total_postage,paid,status,refund_status,pay_type,coupon_price,deduction_price,pink_id,delivery_type,is_del,shipping_type')
             ->order('add_time DESC')->page((int)$page, (int)$limit)->select()->toArray();
-        else  $list = self::statusByWhere($status, $uid)->where('is_del', 0)->where('uid', $uid)
+        else  $list = self::statusByWhere($status, $uid)->where('is_del', 0)->where('uid|gift_uid', $uid)
             ->field('add_time,seckill_id,bargain_id,combination_id,id,order_id,pay_price,total_num,total_price,pay_postage,total_postage,paid,status,refund_status,pay_type,coupon_price,deduction_price,pink_id,delivery_type,is_del,shipping_type')
             ->order('add_time DESC')->page((int)$page, (int)$limit)->select()->toArray();
         foreach ($list as $k => $order) {
@@ -1218,7 +1218,7 @@ class StoreOrder extends BaseModel
      */
     public static function searchUserOrder($uid, $order_id)
     {
-        $order = self::where('uid', $uid)->where('order_id', $order_id)->where('is_del', 0)->field('seckill_id,bargain_id,combination_id,id,order_id,pay_price,total_num,total_price,pay_postage,total_postage,paid,status,refund_status,pay_type,coupon_price,deduction_price,delivery_type,shipping_type')
+        $order = self::where('uid|gift_uid', $uid)->where('order_id', $order_id)->where('is_del', 0)->field('seckill_id,bargain_id,combination_id,id,order_id,pay_price,total_num,total_price,pay_postage,total_postage,paid,status,refund_status,pay_type,coupon_price,deduction_price,delivery_type,shipping_type')
             ->order('add_time DESC')->find();
         if (!$order)
             return false;