dever 3 年之前
父节点
当前提交
b7896c36c8
共有 5 个文件被更改,包括 220 次插入63 次删除
  1. 40 13
      app/mshop/lib/Buy.php
  2. 26 2
      app/mshop/src/Buy.php
  3. 1 22
      app/shop/database/buy_order.php
  4. 3 26
      app/shop/database/buy_order_goods.php
  5. 150 0
      app/shop/database/buy_order_tui.php

+ 40 - 13
app/mshop/lib/Buy.php

@@ -329,18 +329,41 @@ class Buy
         }
     }
 
-    # 全部退款
-    public function tui($id, $order_id, $status = 8, $desc = '')
+    # 申请退款
+    public function tui_action($shop_id, $order_id, $order_goods_id, $status, $price, $num = false, $desc = '', $pic = '')
     {
-        if ($status != 8 && $status != 9) {
+        $data['shop_id'] = $shop_id;
+        $data['order_id'] = $order_id;
+        $data['order_goods_id'] = $order_goods_id;
+        $info = Dever::db('shop/buy_order_tui')->find($data);
+
+        $data['status'] = $status;
+        $data['price'] = $price;
+        if ($num) {
+            $data['num'] = $num;
+        }
+        $data['desc'] = $desc;
+        $data['pic'] = $pic;
+        
+        if ($info) {
+            $data['where_id'] = $info['id'];
+            return Dever::db('shop/buy_order_tui')->update($data);
+        } else {
+            return Dever::db('shop/buy_order_tui')->insert($data);
+        }
+    }
+
+    # 全部退款申请
+    public function tui($id, $order_id, $status = 1, $desc = '', $pic = '')
+    {
+        if ($status != 1 && $status != 2) {
             Dever::alert('当前订单状态不允许退货退款');
         }
 
         $data = $this->getView($id, $order_id, false);
         if ($data['status'] == 2) {
-            $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => $status, 'tk_desc' => $desc, 'tk_cash' => $data['price']));
 
-            $this->pay_tui($state, $data, $data['price']);
+            $state = $this->tui_action($data['shop_id'], $data['id'], -1, $status, $data['price'], false, $desc, $pic);
 
             return 'ok';
         } else {
@@ -352,7 +375,7 @@ class Buy
     public function tui_one_info($id, $order_id, $order_goods_id)
     {
         $data = $this->getView($id, $order_id, false);
-        if ($data['status'] == 2 || $data['status'] == 3 || $data['status'] == 4) {
+        if ($data['status'] == 4) {
             $info = Dever::db('shop/buy_order_goods')->find(array('id' => $order_goods_id, 'order_id' => $data['id'], 'shop_id' => $id));
             if ($info && $info['status'] <= 4) {
                 $info['tui_price'] = $info['price'];
@@ -365,15 +388,15 @@ class Buy
         }
     }
 
-    # 部分退款
-    public function tui_one($id, $order_id, $order_goods_id, $num = false, $status = 6, $desc = '')
+    # 部分退款申请
+    public function tui_one($id, $order_id, $order_goods_id, $num = false, $status = 6, $desc = '', $pic = '')
     {
         if ($status != 5 && $status != 6) {
             Dever::alert('当前订单状态不允许退货退款');
         }
 
         $data = $this->getView($id, $order_id, false);
-        if ($data['status'] == 2 || $data['status'] == 3 || $data['status'] == 4 || $data['status'] == 5) {
+        if ($data['status'] == 4 || $data['status'] == 5) {
             $info = Dever::db('shop/buy_order_goods')->find(array('id' => $order_goods_id, 'order_id' => $data['id'], 'shop_id' => $id));
             if ($info && $info['status'] <= 4) {
                 $info['price'] = $info['price'];
@@ -381,19 +404,23 @@ class Buy
                     $price = round($info['price'] / $info['num'], 2);
                     $info['price'] = round($price * $num, 2);
                 }
-                $state = Dever::db('shop/buy_order_goods')->update(array('where_id' => $info['id'], 'status' => $status, 'tk_desc' => $desc, 'tk_cash' => $info['price']));
 
+                $state = $this->tui_action($data['shop_id'], $data['id'], $order_goods_id, $status, $info['price'], $num, $desc, $pic);
+
+                /*
                 if ($state) {
                     $this->pay_tui($state, $data, $info['price']);
 
                     # 检查这个订单下的商品是不是都退了
                     $total = Dever::db('shop/buy_order_goods')->total(array('order_id' => $data['id'], 'shop_id' => $id, 'status' => 1));
                     if ($total <= 0) {
-                        $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => 8, 'tk_desc' => $desc, 'tk_cash' => $info['price']));
-                    } elseif ($data['status'] == 5) {
-                        $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => 6));
+                        $status += 3;
+                        $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => $status, 'tk_desc' => $desc, 'tk_cash' => $info['price'], 'tk_pic' => $pic));
                     }
                 }
+                */
+            } else {
+                Dever::alert('当前订单状态不允许退货退款');
             }
             return 'ok';
         } else {

+ 26 - 2
app/mshop/src/Buy.php

@@ -120,13 +120,37 @@ class Buy extends Core
         return Dever::load('mshop/lib/buy')->cancel($this->shop_id, $order_id);
     }
 
-    # 用户退款
+    # 全部退款
     public function order_tui()
     {
         $order_id = Dever::input('order_id');
         $status = Dever::input('status');
+        $desc = Dever::input('desc');
+        $pic = Dever::input('pic');
 
-        return Dever::load('mshop/lib/buy')->tui($this->shop_id, $order_id, $status);
+        return Dever::load('mshop/lib/buy')->tui($this->shop_id, $order_id, $status, $desc, $pic);
+    }
+
+    # 部分退款信息
+    public function order_tui_one_info()
+    {
+        $order_id = Dever::input('order_id');
+        $order_goods_id = Dever::input('order_goods_id');
+
+        return Dever::load('mshop/lib/buy')->tui_one_info($this->shop_id, $order_id, $order_goods_id);
+    }
+
+    # 部分退款
+    public function order_tui_one()
+    {
+        $order_id = Dever::input('order_id');
+        $order_goods_id = Dever::input('order_goods_id');
+        $num = Dever::input('num');
+        $status = Dever::input('status');
+        $desc = Dever::input('desc');
+        $pic = Dever::input('pic');
+
+        return Dever::load('mshop/lib/buy')->tui_one($this->shop_id, $order_id, $order_goods_id, $num, $status, $desc, $pic);
     }
 
     # 测试审核拆单

+ 1 - 22
app/shop/database/buy_order.php

@@ -11,8 +11,7 @@ $status = array
     5 => '已完成',
     6 => '已完成(有退款)',
     7 => '已取消',
-    8 => '退款退货',
-    9 => '无货退款',
+    8 => '已退款',
     11 => '已过期',
 );
 
@@ -135,26 +134,6 @@ return array
             'match'     => 'is_numeric',
         ),
 
-        'tk_cash'      => array
-        (
-            'type'      => 'varchar-300',
-            'name'      => '退款金额',
-            'default'   => '',
-            'desc'      => '退款金额',
-            'match'     => 'option',
-            'update'    => 'text',
-        ),
-
-        'tk_desc'      => array
-        (
-            'type'      => 'varchar-300',
-            'name'      => '退款描述',
-            'default'   => '',
-            'desc'      => '退款描述',
-            'match'     => 'option',
-            'update'    => 'textarea',
-        ),
-
         'info'      => array
         (
             'type'      => 'varchar-300',

+ 3 - 26
app/shop/database/buy_order_goods.php

@@ -2,12 +2,9 @@
 
 $status = array
 (
-    1 => '待分配',
-    2 => '已分配',
-    3 => '已完成',
-    4 => '缺货',
-    5 => '门店退款',
-    6 => '上游退款',
+    1 => '正常',
+    2 => '缺货',
+    3 => '退款',
 );
 
 return array
@@ -95,26 +92,6 @@ return array
             'list'        => true,
         ),
 
-        'tk_cash'      => array
-        (
-            'type'      => 'varchar-300',
-            'name'      => '退款金额',
-            'default'   => '',
-            'desc'      => '退款金额',
-            'match'     => 'option',
-            'update'    => 'text',
-        ),
-
-        'tk_desc'      => array
-        (
-            'type'      => 'varchar-300',
-            'name'      => '退款描述',
-            'default'   => '',
-            'desc'      => '退款描述',
-            'match'     => 'option',
-            'update'    => 'textarea',
-        ),
-
         'status'        => array
         (
             'type'      => 'int-11',

+ 150 - 0
app/shop/database/buy_order_tui.php

@@ -0,0 +1,150 @@
+<?php
+
+$status = array
+(
+    1 => '报损退款',
+    2 => '无货退款',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy_order_tui',
+    # 显示给用户看的名称
+    'lang' => '订单退款申请表',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属门店',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_shop_id'),
+            'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'order_goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单商品表id',
+            'default'   => '-1',
+            'desc'      => '订单商品表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款金额',
+            'default'   => '',
+            'desc'      => '退款金额',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款数量',
+            'default'   => '',
+            'desc'      => '退款数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款描述',
+            'default'   => '',
+            'desc'      => '退款描述',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'pic'      => array
+        (
+            'type'      => 'varchar-8000',
+            'name'      => '退款图片',
+            'default'   => '',
+            'desc'      => '退款图片',
+            'match'     => 'option',
+            'update'    => 'images',
+            'key'       => '1',
+            'place'     => '660*660',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创建时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);