dever hace 3 años
padre
commit
592b65685b

+ 3 - 3
app/factory/database/goods_sku.php

@@ -45,9 +45,9 @@ $config = array
         'sku_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '商品sku',
-            'default'   => '',
-            'desc'      => '商品sku',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
             'match'     => 'is_numeric',
         ),
 

+ 1 - 0
app/goods/database/info.php

@@ -354,6 +354,7 @@ $config = array
         # 列表里的按钮
         'list_button' => array
         (
+            'update' => array('编辑', 'info'),
             'fast' => array('属性设置', '"info_attr&project=goods&search_option_info_id={id}&search_option_category={category}&oper_parent=info&oper_project=goods&oper_save_jump=info&where_id={id}"', '{price_type} == 2'),
 
             'fast_list' => array('价格设置', '"info_sku&project=goods&goods_id={id}&page_type=1"', '{price_type} <= 2'),

+ 9 - 0
app/goods/database/info_attr.php

@@ -57,6 +57,15 @@ $config = array
             'value'     => $category
         ),
 
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '数据状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
         'cdate'     => array
         (
             'type'      => 'int-11',

+ 9 - 0
app/goods/database/info_category.php

@@ -43,6 +43,15 @@ return array
             'update'    => 'text',
             'list'      => true,
         ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '数据状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
         
         'cdate'     => array
         (

+ 1 - 1
app/goods/database/info_sku.php

@@ -37,7 +37,7 @@ $config = array
         (
             'type'      => 'varchar-100',
             'name'      => '属性标识',
-            'default'   => '',
+            'default'   => '-1',
             'desc'      => '属性标识',
             'match'     => 'is_string',
             'update'    => 'text',

+ 18 - 0
app/goods/lib/Info.php

@@ -10,6 +10,7 @@ class Info
 {
     private $table_info = 'goods/info';
     private $table_attr = 'goods/info_attr';
+    private $table_sku = 'goods/info_sku';
     /**
      * instance
      *
@@ -317,6 +318,23 @@ class Info
         return $this->freight($info, $goods_price, $user, $num);
     }
 
+    # 根据已经选择的sku获取商品信息
+    public function getInfoBySku($id, $sku_id)
+    {
+        $info = Dever::db($this->table_info)->find($id);
+
+        if ($info && $sku_id > 0) {
+            $sku = Dever::db($this->table_sku)->find($sku_id);
+
+            if ($sku && $sku['attr']) {
+                $sku['attr'] = Dever::json_decode($sku['attr']);
+                $info['sku'] = Dever::load('attr/api')->getInfoByJson($sku['attr']);
+            }
+        }
+
+        return $info;
+    }
+
     # 获取基本信息
     public function getInfo($id, $attr = true, $order = 'view_reorder', $user = array(), $reward = false)
     {

+ 26 - 0
app/shop/assets/manage/html/sell_order_goods.html

@@ -0,0 +1,26 @@
+</form>
+<form class="layui-form form10" action="" target="f10" method="post">
+<iframe id="f10" name="f10" style="display:none;"></iframe>
+<div class="layui-form-item" id="show">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>

+ 2 - 1
app/shop/database/goods.php

@@ -155,7 +155,8 @@ return array
             'type' => 'update',
             'where' => array
             (
-                'id' => 'yes',
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
             ),
             'set' => array
             (

+ 8 - 6
app/shop/database/goods_sku.php

@@ -50,9 +50,9 @@ $config = array
         'sku_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '商品sku',
-            'default'   => '',
-            'desc'      => '商品sku',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
             'match'     => 'is_numeric',
         ),
 
@@ -146,8 +146,8 @@ $config = array
             'option' => array
             (
                 'shop_id' => 'yes',
-                'sku_id' => 'yes',
                 'goods_id' => 'yes',
+                'sku_id' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
@@ -162,8 +162,8 @@ $config = array
             'option' => array
             (
                 'shop_id' => 'yes',
-                'sku_id' => 'yes',
                 'goods_id' => 'yes',
+                'sku_id' => 'yes',
                 'state' => 1,
             ),
             'type' => 'one',
@@ -176,7 +176,9 @@ $config = array
             'type' => 'update',
             'where' => array
             (
-                'id' => 'yes',
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
             ),
             'set' => array
             (

+ 34 - 3
app/shop/database/info.php

@@ -7,6 +7,12 @@ $status = array
     3 => '申请合作中',
 );
 
+$type = array
+(
+    1 => '普通店',
+    2 => '平台店',
+);
+
 $yes = array
 (
     1 => '是',
@@ -51,7 +57,7 @@ return array
             'desc'      => '',
             'match'     => 'is_numeric',
             'search'    => 'order',
-            'list'      => true,
+            //'list'      => true,
             'order'     => 'desc',
         ),
 
@@ -389,6 +395,19 @@ return array
             //'search'    => 'select',
         ),
 
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店类型-自营为平台店,当没有找到加盟店时,将自动获取平台店',
+            'default'   => '1',
+            'desc'      => '门店类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
         'status'        => array
         (
             'type'      => 'int-11',
@@ -426,7 +445,7 @@ return array
 
     'manage' => array
     (
-        'insert' => false,
+        //'insert' => false,
         'list_button' => array
         (
             'delete' => '删除',
@@ -451,6 +470,18 @@ return array
 
     'request' => array
     (
-        
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'city' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*',
+        ),
     ),
 );

+ 22 - 6
app/shop/database/sell_order.php

@@ -77,7 +77,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'hidden',
             'value'     => Dever::input('search_option_shop_id'),
-            'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
+            //'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
         ),
 
         'uid'       => array
@@ -95,7 +95,7 @@ return array
                 'col' => 'username',
                 'result' => 'id',
             ),
-            'list'      => '{uid} > 0 ? Dever::load("passport/user-find#username", {uid}) : "匿名用户"',
+            'list'      => 'Dever::load("shop/lib/manage.user", {id})',
         ),
 
         'parent_uid'       => array
@@ -179,9 +179,9 @@ return array
         'price'      => array
         (
             'type'      => 'varchar-50',
-            'name'      => '购买价格',
+            'name'      => '付款金额',
             'default'   => '',
-            'desc'      => '购买价格',
+            'desc'      => '付款金额',
             'match'     => 'option',
             'update'    => 'text',
             'list'        => true,
@@ -195,7 +195,7 @@ return array
             'desc'      => '购买数量',
             'match'     => 'is_numeric',
             'search'    => 'select',
-            'list'        => true,
+            //'list'        => true,
         ),
 
         'card_code_id'      => array
@@ -287,6 +287,7 @@ return array
             'desc'      => '请选择支付状态',
             'match'     => 'is_numeric',
             'option'    => $pay_status,
+            'list'      => true,
         ),
 
         'pay_price'      => array
@@ -308,6 +309,7 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $pay_method,
+            'list'      => true,
         ),
 
         'info'      => array
@@ -384,6 +386,17 @@ return array
             //'show'        => 'status=5',
         ),
 
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -418,7 +431,10 @@ return array
             //'导出订单' => array('location', 'user/lib/manage.out'),
         ),
 
-        'list_button' => array(
+        'list_button' => array
+        (
+            'fast_list' => array('查看详情', '"sell_order_goods&project=shop&order_id={id}&page_type=1"'),
+
             'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2'),
             //'delete' => array('删除', '', '{status} == 1'),
         ),

+ 2 - 2
app/shop/database/sell_order_goods.php

@@ -83,7 +83,7 @@ return array
         (
             'type'      => 'int-11',
             'name'      => 'sku_id',
-            'default'   => '',
+            'default'   => '-1',
             'desc'      => 'sku_id',
             'match'     => 'is_numeric',
         ),
@@ -148,7 +148,7 @@ return array
 
     'manage' => array
     (
-        
+        'page_list_table' => 'sell_order_goods',
     ),
 
     'request' => array

+ 31 - 0
app/shop/lib/Manage.php

@@ -6,6 +6,37 @@ use Dever;
 
 class Manage
 {
+    # 获取用户信息
+    public function user($id)
+    {
+        $info = Dever::db('shop/sell_order')->one($id);
+
+        $user = Dever::db('passport/user')->one($info['uid']);
+
+        $result = $user['username'];
+        if ($info['mobile']) {
+            $result .= '('.$info['mobile'].')';
+        }
+        return $result;
+    }
+
+    # 获取订单信息
+    public function sell_order($id)
+    {
+        $table = array();
+        $info = Dever::db('shop/sell_order')->one($id);
+
+        $goods = Dever::db('shop/sell_order_goods')->select(array('order_id' => $info['id']));
+
+        foreach ($goods as $k => $v) {
+            $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
+            //print_r($goods_info);die;
+            $table[$goods_info['name']] = $v['price'];
+        }
+        
+        return Dever::table($table);
+    }
+
     /**
      * 更新信息
      *

+ 88 - 24
app/shop/lib/Sell.php

@@ -52,25 +52,27 @@ class Sell
         }
 
         $order_data['order_num'] = $this->getOrderId();
-        $order_data['pay_id'] = $order_data['order_num'] . '_p1';
+        $order_data['pay_id'] = $order_data['order_num'];
         $order_data['pay_status'] = 1;
         $order_data['pay_price'] = 0;
-        $id = Dever::db('goods/order')->insert($order_data);
+        $id = Dever::db('shop/sell_order')->insert($order_data);
 
         if (!$id) {
             Dever::alert('支付失败');
         }
 
         foreach($goods as $k => $v) {
-        	$data['uid'] = $uid;
-        	$data['shop_id'] = $shop['id'];
-        	$data['order_id'] = $id;
-        	$data['goods_id'] = $v['id'];
-        	$data['sku_id'] = $v['sku_id'];
-        	$data['price'] = $v['price'];
-        	$data['num'] = $v['buy_num'];
-
-        	Dever::db('shop/sell_order_goods')->insert($data);
+            if ($v['ku_state'] == 1) {
+                $data['uid'] = $uid;
+                $data['shop_id'] = $shop['id'];
+                $data['order_id'] = $id;
+                $data['goods_id'] = $v['id'];
+                $data['sku_id'] = $v['sku_id'];
+                $data['price'] = $v['price'];
+                $data['num'] = $v['buy_num'];
+
+                Dever::db('shop/sell_order_goods')->insert($data);
+            }
         }
 
         if ($card || $price <= 0) {
@@ -95,7 +97,7 @@ class Sell
         (
             'project_id' => 1,
             'channel_id' => 1,
-            'system_source' => 1,
+            'system_source' => 5,
             'uid' => $uid,
             'name' => $order_data['name'],
             'cash' => $price,
@@ -152,8 +154,7 @@ class Sell
     	$param = array
         (
             'project_id' => 1,
-            'channel_id' => 1,
-            'system_source' => 1,
+            'account_id' => 5,
             'uid' => $order['uid'],
             'name' => $order['name'],
             'cash' => $order['price'],
@@ -202,19 +203,11 @@ class Sell
 
             if ($status == 2) {
                 # 减少库存 增加销量
-                $update['where_id'] = $order['info_id'];
-                $update['sell_num'] = $order['num'];
-                Dever::db('shop/goods')->updateSell($update);
-
-                if ($order['sku_id'] > 0) {
-                    $update['where_id'] = $order['sku_id'];
-                    $update['sell_num'] = $order['num'];
-                    Dever::db('shop/goods_sku')->updateSell($update);
-                }
+                $this->updateSell($order);
 
                 # 发消息
                 if (Dever::project('message')) {
-                    Dever::load('message/lib/data')->push(-1, $order['uid'], '订购成功通知', '购买成功', 11);
+                    Dever::load('message/lib/data')->push(-1, $order['uid'], '订购成功通知', '购买成功', 1);
                 }
 
                 # 如果是自提订单,生成自提码
@@ -237,6 +230,32 @@ class Sell
         return 'ok';
     }
 
+    # 减少库存,增加销量
+    public function updateSell($order)
+    {
+        $where['order_id'] = $order['id'];
+        $data = Dever::db('shop/sell_order_goods')->select($where);
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $up = array();
+                $up['where_shop_id'] = $v['shop_id'];
+                $up['where_goods_id'] = $v['goods_id'];
+                $up['sell_num'] = $v['num'];
+                Dever::db('shop/goods')->updateSell($up);
+
+                if ($v['sku_id'] > 0) {
+                    
+                } else {
+                    $v['sku_id'] = -1;
+                }
+                $upSku = $up;
+                $upSku['where_sku_id'] = $v['sku_id'];
+                Dever::db('shop/goods_sku')->updateSell($upSku);
+            }
+        }
+    }
+
     # 生成自提码
     public function getCode()
     {
@@ -260,4 +279,49 @@ class Sell
             return $this->getOrderId();
         }
     }
+
+    # 展示订单详情
+    public function show()
+    {
+        
+        return '
+<table class="layui-table">
+      <thead>
+        <tr>
+          <th>付款金额</th>
+          <th>总数量</th>
+          <th>状态</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+      </tbody>
+    </table>
+
+        <table class="layui-table">
+      <thead>
+        <tr>
+          <th>商品名称</th>
+          <th>商品属性</th>
+          <th>商品数量</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>';
+    }
 }

+ 13 - 8
app/shop/src/Buy.php

@@ -145,6 +145,7 @@ class Buy extends Core
 
         $coupon_id = Dever::input('coupon_id');
 
+        $this->data['user_coupon_id'] = 0;
         $this->data['coupon_id'] = 0;
         $this->data['coupon_cash'] = 0;
 
@@ -278,27 +279,27 @@ class Buy extends Core
         foreach ($goods_id as $k => $v) {
             $s = isset($sku_id[$k]) ? $sku_id[$k] : 0;
             $n = isset($num[$k]) ? $num[$k] : 1;
-            $this->data['list'][$k]['goods'] = Dever::load('goods/lib/info')->getPayInfo($v, $s, $n);
+            $this->data['list'][$k] = Dever::load('goods/lib/info')->getPayInfo($v, $s, $n);
 
             # 2是库存不足
-            $this->data['list'][$k]['goods']['ku_state'] = 1;
+            $this->data['list'][$k]['ku_state'] = 1;
 
             # 验证是否有货
             $total = $this->total($n, $v, $this->shop_id, $s);
 
             if ($total <= 0) {
-                $this->data['list'][$k]['goods']['ku_state'] = 2;
+                $this->data['list'][$k]['ku_state'] = 2;
             }
 
-            if ($this->data['list'][$k]['goods']['ku_state'] == 1) {
-                $this->data['list'][$k]['goods']['buy_num'] = $n;
+            if ($this->data['list'][$k]['ku_state'] == 1) {
+                $this->data['list'][$k]['buy_num'] = $n;
                 $this->data['num'] += $n;
-                $this->data['price'] += $this->data['list'][$k]['goods']['price'] * $n;
+                $this->data['price'] += $this->data['list'][$k]['price'] * $n;
                 if (!$this->data['name']) {
                     if ($count > 1) {
-                        $this->data['name'] = $this->data['list'][$k]['goods']['name'] . '等' . $count . '种商品';
+                        $this->data['name'] = $this->data['list'][$k]['name'] . '等' . $count . '种商品';
                     } else {
-                        $this->data['name'] = $this->data['list'][$k]['goods']['name'];
+                        $this->data['name'] = $this->data['list'][$k]['name'];
                     }
                 }
             }
@@ -327,6 +328,10 @@ class Buy extends Core
             Dever::alert('收货地址不能为空');
         }
 
+        if (!isset($this->data['card'])) {
+            $this->data['card'] = false;
+        }
+
         $pay = Dever::load('shop/lib/sell')->action($this->data['method'], $this->data['pay_method'], $this->user, $this->shop, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $address_id, $invoice_id, $info, $this->data['card'], $this->data['coupon_id'], $this->data['user_coupon_id'], $parent_uid, $cart, $refer);
 
         return $pay;

+ 1 - 1
app/shop/src/Main.php

@@ -23,7 +23,7 @@ class Main extends Core
         if ($where['city']) {
             # 获取当前城市是否开通门店
             $where['status'] = 1;
-            $this->data['shop'] = Dever::db('shop/info')->find($where);
+            $this->data['shop'] = Dever::db('shop/info')->getOne($where);
             if ($this->data['shop']) {
                 # 有开通的门店
                 $this->data['city'] = 1;

+ 5 - 0
app/shop/template/manage/sell_order_goods.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'shop/lib/sell.show')
+->display();

+ 3 - 3
app/store/database/goods_sku.php

@@ -50,9 +50,9 @@ $config = array
         'sku_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '商品sku',
-            'default'   => '',
-            'desc'      => '商品sku',
+            'name'      => 'sku_id',
+            'default'   => '-1',
+            'desc'      => 'sku_id',
             'match'     => 'is_numeric',
         ),