|
@@ -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
|