rabin 1 year ago
parent
commit
5745b90b5d

+ 46 - 3
src/dai/seller/lib/Manage.php

@@ -165,6 +165,47 @@ class Manage extends Auth
         foreach ($id as $k => $v) {
             $info = Dever::db('order', 'seller')->find($v);
             if ($info['status'] >= 10) {
+                if ($info['status'] == 10) {
+                    # 成功,分配卡密
+                    $channel = Dever::load('order', 'seller')->channel($info['seller_id'], $info['goods_id'], $info['sku_id']);
+                    if (!$channel) {
+                        Dever::error('未分配渠道');
+                    }
+                    if ($channel['type'] == 2) {
+                        # 获取卡密并占用
+                        $param['seller_id'] = array('in', '-1,' . $info['seller_id']);
+                        $param['channel_id'] = $channel['id'];
+                        $param['goods_id'] = $info['goods_id'];
+                        $param['sku_id'] = $info['sku_id'];
+                        $param['status'] = 1;
+                        $param['use_status'] = 1;
+                        $card = Dever::db('card', 'channel')->select($param, array('order' => 'seller_id desc','limit' => '0, ' . $info['num']), true);
+                        $total = count($card);
+                        if ($total < $info['num']) {
+                            Dever::error('卡密剩余数量不足');
+                        }
+                        foreach ($card as $k1 => $v1) {
+                            Dever::db('card', 'channel')->update($v1['id'], array('use_status' => 2, 'order_id' => $info['id']));
+                        }
+                        $result['status'] = 1;
+
+                        $update = array();
+                        $update['channel_id'] = $channel['id'];
+                        $update['channel_order_date'] = time();
+                        if (isset($channel['goods']['id'])) {
+                            $update['channel_goods_id'] = $channel['goods']['id'];
+                        }
+                        $update['channel_goods_discount'] = $channel['discount'];
+                        if (isset($channel['goods']['discount']) && $channel['goods']['discount']) {
+                            $update['channel_goods_discount'] = $channel['goods']['discount'];
+                        }
+                        if (!$update['channel_goods_discount']) {
+                            $update['channel_goods_discount'] = 1;
+                        }
+                        $update['buy_price'] = round($info['cash'] * $update['channel_goods_discount'], 2) * $info['num'];
+                        Dever::db('order', 'seller')->update($info['id'], $update);
+                    }
+                }
                 if ($info['status'] == 11) {
                     # 失败,余额加回来
                     Dever::load('info', 'seller')->inc($info['seller_id'], $info['price']);
@@ -212,10 +253,12 @@ class Manage extends Auth
     }
 
     # 展示订单账号
-    public function showOrderAccount($account)
+    public function showOrderAccount($status, $account)
     {
         if (strstr($account, 'km_')) {
-            return '<a>提取卡密</a>';
+            if ($status == 10) {
+                return '<a>提取卡密</a>';
+            }
         }
         return $account;
     }
@@ -477,7 +520,7 @@ class Manage extends Auth
     # 展示订单卡密扩展信息
     public function showOrderExpandKm($data)
     {
-        if ($data && strstr($data['account'], 'km_')) {
+        if ($data && $data['status'] == 10 && strstr($data['account'], 'km_')) {
             $seller = Dever::db('info', 'seller')->find($data['seller_id']);
             $result['type'] = 'desc';
             $result['content'][] = array

+ 2 - 0
src/dai/seller/lib/Order.php

@@ -98,6 +98,8 @@ class Order
             }
             $result = Dever::load('func/api', 'connect')->run(1, $info['cate_id'], $channel, $param);
         } elseif ($channel['type'] == 2) {
+            # 需要审核
+            return 'ok';
             # 获取卡密并占用
             $param['seller_id'] = array('in', '-1,' . $info['seller_id']);
             $param['channel_id'] = $channel['id'];

+ 1 - 1
src/dai/seller/table/manage/seller_order_list.php

@@ -20,7 +20,7 @@ return array
             ),
             'account' => array
             (
-                'show' => 'Dever::load("manage", "seller")->showOrderAccount("{account}")',
+                'show' => 'Dever::load("manage", "seller")->showOrderAccount("{status}", "{account}")',
                 'type' => 'show',
                 'remote' => 'seller/manage.showOrderExpandKm',
             ),

+ 1 - 1
src/dai/seller/table/manage/seller_order_log_list.php

@@ -20,7 +20,7 @@ return array
             ),
             'account' => array
             (
-                'show' => 'Dever::load("manage", "seller")->showOrderAccount("{account}")',
+                'show' => 'Dever::load("manage", "seller")->showOrderAccount("{status}", "{account}")',
                 'type' => 'show',
                 'remote' => 'seller/manage.showOrderExpandKm',
             ),