dever 3 tahun lalu
induk
melakukan
a74110612d

+ 23 - 0
app/content/database/feature.php

@@ -86,6 +86,29 @@ return array
             'match'     => 'is_string',
             'update'    => 'editor',
             'key'       => '1',
+            'editor'    => array
+            (
+                'name' => '选择插入模块',
+                'button' => array
+                (
+                    /*
+                    array
+                    (
+                        # 名称
+                        'name' => '图片',
+                        # 资源库id
+                        'key' => 1,
+                        # 类型
+                        'type' => 'image',
+                    ),
+                    */
+                    array
+                    (
+                        'name' => '商品',
+                        'key' => 'goods/lib/manage.editor',
+                    ),
+                ),
+            ),
         ),
 
         'reorder'       => array

+ 141 - 0
app/content/lib/Feature.php

@@ -0,0 +1,141 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Feature
+{
+    # 根据文章id 获取文章信息
+    public function get($data, $uid = false)
+    {
+        if (!is_array($data)) {
+            $data = Dever::db('content/feature')->find($data);
+        }
+        
+        if (!$data) {
+            Dever::alert('错误的专题信息');
+        }
+    
+        $data = $this->getContent($data, $uid);
+
+        return $data;
+    }
+
+    public function getContent($data, $uid = false)
+    {
+        //embed
+        $data['content_array'] = array();
+
+        $data['content'] = Dever::filter($data['content']);
+
+        $content = $data['content'];
+        $replace = array();
+
+        if (strstr($data['content'], 'data-id')) {
+            # 商品
+            preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $content, $matches);
+            
+            
+            if (!isset($matches[2][0])) {
+                preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $content, $matches);
+                $temp = array();
+                if (isset($matches[2][0]) && isset($matches[3][0])) {
+                    $temp = $matches;
+                    $matches[2] = $temp[3];
+                    $matches[3] = $temp[2];
+                    unset($temp);
+                }
+            }
+            
+            if (isset($matches[2][0]) && isset($matches[3][0])) {
+
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    if ($matches[3][$k] == 'goods/lib/manage.editor') {
+                        $method = 'goods/lib/info';
+                        $type = 3;
+
+                        $info = Dever::load($method)->getInfo($v);
+                        if (isset($info['content'])) {
+                            unset($info['content']);
+                        }
+
+                        $replace[] = array('id' => $v, 'type' => $type, 'content' => $info);
+                    }
+                }
+            }
+        } 
+        elseif (strstr($data['content'], 'jpg')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.jpg" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 2, 'pic' => $pic . '.jpg');
+                }
+            }
+        }
+
+        elseif (strstr($data['content'], 'gif')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.gif" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 2, 'pic' => $pic . '.gif');
+                }
+            }
+        }
+
+        elseif (strstr($data['content'], 'png')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.png" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 2, 'pic' => $pic . '.png');
+                }
+            }
+        }
+
+        //$data['content'] = preg_replace('/<div class="dever-drop">([\s\S]*?)<\/div>/i', '', $data['content']);
+
+        $content = explode('{replace}', $content);
+        $data['content_array'] = array();
+        //print_r($content);die;
+        foreach ($content as $k => $v) {
+            $v = trim($v);
+            if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
+                $data['content_array'][] = $replace[$v];
+            } elseif ($v) {
+                $data['content_array'][] = array
+                (
+                    'type' => 1,
+                    'content' => $v,
+                );
+            }
+        }
+
+        if (!$data['content_array']) {
+            $data['content_array'][] = array
+            (
+                'type' => 1,
+                'content' => $data['content'],
+            );
+        }
+
+        unset($data['content']);
+
+        return $data;
+    }
+}

+ 107 - 0
app/content/lib/News.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class News
+{
+    # 根据文章id 获取文章信息
+    public function get($data, $uid = false)
+    {
+        if (!is_array($data)) {
+            $data = Dever::db('content/news')->find($data);
+        }
+        
+        if (!$data) {
+            Dever::alert('错误的专题信息');
+        }
+    
+        $data = $this->getContent($data, $uid);
+
+        return $data;
+    }
+
+    public function getContent($data, $uid = false)
+    {
+        //embed
+        $data['content_array'] = array();
+
+        $data['content'] = Dever::filter($data['content']);
+
+        $content = $data['content'];
+        $replace = array();
+
+        if (strstr($data['content'], 'jpg')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.jpg" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 2, 'pic' => $pic . '.jpg');
+                }
+            }
+        }
+
+        elseif (strstr($data['content'], 'gif')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.gif" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 2, 'pic' => $pic . '.gif');
+                }
+            }
+        }
+
+        elseif (strstr($data['content'], 'png')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.png" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 2, 'pic' => $pic . '.png');
+                }
+            }
+        }
+
+        //$data['content'] = preg_replace('/<div class="dever-drop">([\s\S]*?)<\/div>/i', '', $data['content']);
+
+        $content = explode('{replace}', $content);
+        $data['content_array'] = array();
+        //print_r($content);die;
+        foreach ($content as $k => $v) {
+            $v = trim($v);
+            if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
+                $data['content_array'][] = $replace[$v];
+            } elseif ($v) {
+                $data['content_array'][] = array
+                (
+                    'type' => 1,
+                    'content' => $v,
+                );
+            }
+        }
+
+        if (!$data['content_array']) {
+            $data['content_array'][] = array
+            (
+                'type' => 1,
+                'content' => $data['content'],
+            );
+        }
+
+        unset($data['content']);
+
+        return $data;
+    }
+}

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

@@ -567,6 +567,7 @@ $config = array
                 'shop_id' => 'yes',
                 'brand_id' => 'yes',
                 'name' => array('yes', 'like'),
+                'column_id' => array('yes', 'like'),
                 'category' => array('yes', 'like'),
                 'top_category_id' => 'yes',
                 'second_category_id' => 'yes',

+ 26 - 0
app/goods/lib/Manage.php

@@ -336,4 +336,30 @@ class Manage
         Dever::db('goods/card_code')->update($update);
         return 'ok';
     }
+
+    public function editor_api()
+    {
+        $data['name'] = '商品';
+        $where = array();
+        $name = Dever::input('search_name');
+        $cate = Dever::input('search_cate');
+        if ($name) {
+            $where['name'] = $name;
+        }
+        if ($cate > 0) {
+            $where['column_id'] = $cate;
+        }
+        $data['file'] = Dever::db('goods/info')->getPageAll($where);
+        $data['cate'] = Dever::db('goods/column')->select();
+
+        if ($data['file']) {
+            foreach ($data['file'] as $k => $v) {
+                $data['file'][$k]['source_name'] = $v['name'];
+                $data['file'][$k]['file'] = $v['cover'];
+                $data['file'][$k]['pic'] = $v['cover'];
+            }
+        }
+
+        return $data;
+    }
 }

+ 309 - 0
app/mshop/lib/Buy.php

@@ -0,0 +1,309 @@
+<?php
+
+# 支付
+
+namespace Mshop\Lib;
+
+use Dever;
+
+class Buy
+{
+    # 发起支付
+    public function action($shop, $name, $num, $goods, $price, $info, $refer = '')
+    {
+        if (!$shop) {
+            Dever::alert('错误的门店信息');
+        }
+        
+        $order_data['shop_id'] = $shop['id'];
+        $order_data['mobile'] = $shop['mobile'];
+        $order_data['name'] = $name;
+        $order_data['num'] = $num;
+        $order_data['info'] = $info;
+        $order_data['price'] = $price;
+
+        $order_data['area'] = $shop['area'];
+        $order_data['province'] = $shop['province'];
+        $order_data['city'] = $shop['city'];
+        $order_data['county'] = $shop['county'];
+        $order_data['town'] = $shop['town'];
+
+        $order_data['order_num'] = $this->getOrderId();
+        $order_data['pay_id'] = $order_data['order_num'];
+        $order_data['pay_status'] = 1;
+        $order_data['pay_price'] = 0;
+        $id = Dever::db('shop/buy_order')->insert($order_data);
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        foreach($goods as $k => $v) {
+            if ($v['ku_state'] == 1) {
+                $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/buy_order_goods')->insert($data);
+            }
+        }
+
+        if ($card || $price <= 0) {
+
+            $param['pay_product_id'] = $id;
+            $param['pay_order_id'] = $order_data['pay_id'];
+            $param['pay_status'] = 2;
+            $param['pay_cash'] = $price;
+            $param['pay_msg'] = '';
+            $this->success($param);
+            return 'ok';
+        }
+
+        $param = array
+        (
+            'project_id' => 1,
+            'channel_id' => 1,
+            'system_source' => 5,
+            'uid' => -1,
+            'name' => $order_data['name'],
+            'cash' => $price,
+            'product_id' => $id,
+            'order_id' => $order_data['pay_id'],
+            'refer' => $refer,
+        );
+
+        $receipt = Dever::input('receipt');
+        if ($receipt) {
+            $param['receipt'] = $receipt;
+        }
+
+        $result = Dever::load('pay/api.pay', $param);
+        return $result;
+    }
+
+    # 再次发起支付
+    public function raction($id, $refer = '')
+    {
+        $order = Dever::db('goods/order')->find($id);
+
+        if (!$order) {
+            Dever::alert('订单信息错误');
+        }
+
+        if ($order['status'] > 1) {
+            Dever::alert('订单已支付或已取消');
+        }
+
+        $param = array
+        (
+            'project_id' => 1,
+            'account_id' => 5,
+            'uid' => -1;
+            'name' => $order['name'],
+            'cash' => $order['price'],
+            'product_id' => $id,
+            'order_id' => $order['pay_id'],
+            'refer' => $refer,
+        );
+
+        $receipt = Dever::input('receipt');
+        if ($receipt) {
+            $param['receipt'] = $receipt;
+        }
+
+        $result = Dever::load('pay/api.pay', $param);
+
+        return $result;
+    }
+
+    # 支付成功回调 安全加密 设置token
+    public function success_secure_api_token()
+    {
+        $project_id = Dever::input('pay_project_id');
+        $info = Dever::db('pay/project')->one($project_id);
+        if ($info) {
+            return $info['key'];
+        }
+        return 'shop_buy_dever_2020';
+    }
+
+    # 支付成功回调 安全加密
+    public function success_secure_api($param = array())
+    {
+        $this->success($param);
+    }
+
+    # 支付成功回调
+    public function success($param = array())
+    {
+        $send = $param ? $param : Dever::preInput('pay_');
+        $product_id = $send['pay_product_id'];
+        $order_id = $send['pay_order_id'];
+        $status = $send['pay_status'];
+        $cash = $send['pay_cash'];
+        $msg = $send['pay_msg'];
+
+        $order = Dever::db('shop/buy_order')->one(array('id' => $product_id, 'time' => time()));
+        if ($order && $order['pay_status'] == 1) {
+
+            if ($status == 2) {
+                # 减少库存 增加销量
+                $this->updateSell($order);
+
+                # 发消息
+                if (Dever::project('message')) {
+                    Dever::load('message/lib/data')->push(-1, $order['uid'], '订购成功通知', '购买成功', 1);
+                }
+            }
+
+            $update['pay_status'] = $status;
+            $update['status'] = 2;
+            $update['where_id'] = $order['id'];
+            $update['pay_time'] = time();
+            $update['pay_price'] = $cash;
+            Dever::db('shop/buy_order')->update($update);
+        }
+
+        return 'ok';
+    }
+
+    # 生成订单号
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('C');
+        $state = Dever::db('shop/buy_order')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+
+    # 展示订单详情
+    public function show()
+    {
+        $id = Dever::input('order_id');
+
+        $config = Dever::db('shop/buy_order')->config;
+
+        $info = Dever::db('shop/buy_order')->one($id);
+
+        $shop = Dever::db('shop/info')->find($info['shop_id']);
+
+        
+        $html = '[基本信息]:<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody>';
+
+        $html .= '<tr>
+          <td>订单号</td>
+          <td>'.$this->table(false, array(array($info['order_num']))).'</td>
+
+        </tr>';
+
+        $html .= '<tr>
+          <td>门店信息</td>
+          <td>'.$this->table(false, array(array('门店名称:' . $shop['name'], '联系人:' . $shop['truename'], '联系电话:' . $shop['mobile']))).'</td>
+
+        </tr>';
+
+        $html .= '<tr>
+          <td>订单信息</td>
+          <td>'.$this->table(array('订单状态', '金额', '数量'), array(array($config['status'][$info['status']], $info['price'], $info['num']))).'</td>
+        </tr>';
+
+        # 增加仓库和工厂信息
+
+        $html .= '</tbody></table>';
+
+        $html .= '[商品清单]:';
+
+        $head = array('商品名称', '商品属性', '商品价格', '商品数量');
+
+        $body = array();
+        $goods = Dever::db('shop/buy_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']);
+            $body[$k] = array
+            (
+                $goods_info['name'],
+                $v['price'],
+                $v['price'],
+                $v['num'],
+            );
+        }
+        $html .= $this->table($head, $body);
+
+        return $html;
+    }
+
+    private function table($head, $data)
+    {
+        $html = '';
+        if ($head) {
+            $html = '<table class="layui-table">';
+
+            $html .= '<thead><tr>';
+            foreach ($head as $k => $v) {
+                $html .= '<th>'.$v.'</th>';
+            }
+            $html .= '</tr></thead>';
+
+            $html .= '<tbody>';
+            foreach ($data as $k => $v) {
+                $html .= '<tr>';
+                foreach ($v as $k1 => $v1) {
+                    $html .= '<td>'.$v1.'</td>';
+                }
+                $html .= '</tr>';
+            }
+
+            $html .= '</tbody>';
+
+            $html .= '</table>';
+        } else {
+            foreach ($data as $k => $v) {
+                $html .= '';
+                foreach ($v as $k1 => $v1) {
+                    $html .= $v1 . '&nbsp;&nbsp;&nbsp;&nbsp;';
+                }
+                $html .= '';
+            }
+        }
+        return $html;
+    }
+
+    # 采购订单审核 拆单
+    public function audit()
+    {
+        $order_id = Dever::input('id');
+        $info = Dever::db('shop/buy_order')->find($order_id);
+
+        $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $order_id));
+
+        $shop = Dever::db('shop/info')->find($info['shop_id']);
+
+        # 获取门店分配的仓库和工厂
+
+        $store = Dever::db('shop/store')->select(array('shop_id' => $shop['id']));
+        $store_id = array();
+        foreach ($store as $k => $v) {
+            $store_id[] = $v['store_id'];
+        }
+
+        $store_id = implode(',', $store_id);
+
+        $where = ' id in('.$store_id.') and status = 1 ';
+
+        $sql = 'select *,round((st_distance(point(lng, lat), point('.$shop['lng'].', '.$shop['lat'].'))*111195)/1000, 2) as distance from {table} where '.$where.' order by distance asc';
+
+        $store = Dever::db('factory/info')->$method($sql, array(), $page);
+
+        # 得到所有的仓库,先验证库存
+        foreach ($goods as $k => $v) {
+            
+        }
+
+    }
+}

+ 66 - 4
app/mshop/src/Act.php

@@ -6,11 +6,26 @@ use Dever;
 
 class Act extends Core
 {
-    # 采购
-    public function buy()
+    # 获取商品列表
+    public function getGoods()
     {
-        $shop = $this->shop;
+        $this->data['data'] = Dever::load('shop/lib/info')->getGoods($this->shop_id);
 
+        return $this->data;
+    }
+
+    # 确认订单页面
+    public function confirm()
+    {
+        $this->data['user'] = $this->user;
+        $this->goods();
+
+        return $this->data;
+    }
+
+    # 得到商品和总价
+    private function goods()
+    {
         $goods_id = Dever::input('goods_id');
         if (!$goods_id) {
             Dever::alert('请传入商品');
@@ -24,8 +39,55 @@ class Act extends Core
         
         $num = Dever::input('num');
         if (!$num) {
-            Dever::alert('请传入数量');
+            Dever::alert('请传入商品数量');
         }
         $num = explode(',', $num);
+
+        $this->data['price'] = 0;
+        $this->data['num'] = 0;
+        $this->data['name'] = '';
+        $count = count($goods_id);
+        # 计算总价格
+        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] = Dever::load('goods/lib/info')->getPayInfo($v, $s, $n);
+
+            $this->data['list'][$k]['buy_num'] = $n;
+            $this->data['num'] += $n;
+            $this->data['price'] += $this->data['list'][$k]['price'] * $n;
+            if (!$this->data['name']) {
+                if ($count > 1) {
+                    $this->data['name'] = $this->data['list'][$k]['name'] . '等' . $count . '种商品';
+                } else {
+                    $this->data['name'] = $this->data['list'][$k]['name'];
+                }
+            }
+        }
+    }
+
+    # 开始下单
+    public function pay()
+    {
+        $refer = Dever::input('refer');
+        $cart = Dever::input('cart', 1);
+        
+        $info = Dever::input('info');
+
+        $this->goods();
+
+        $pay = Dever::load('mshop/lib/buy')->action($this->shop, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $info, $refer);
+        return $pay;
+    }
+
+    # 再次付款
+    public function r_pay()
+    {
+        $refer = Dever::input('refer');
+        $order_id = Dever::input('order_id');
+
+        $pay = Dever::load('mshop/lib/buy')->raction($order_id, $refer);
+
+        return $pay;
     }
 }

+ 67 - 0
app/shop/database/buy_order.php

@@ -47,6 +47,22 @@ return array
             'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
         ),
 
+        'mobile'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '下单手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            'search'    => array
+            (
+                'api' => 'shop/info-select',//接口地址,最好是获取多条数据的地址
+                'col' => 'mobile',//要查询的字段
+                'result' => 'id',//返回的字段
+                'search' => 'shop_id',//本表的字段,默认为当前的字段
+            ),
+        ),
+
         'name'      => array
         (
             'type'      => 'varchar-80',
@@ -197,6 +213,57 @@ return array
             //'show'        => 'status=5',
         ),
 
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '所在地区',
+            'default'   => '',
+            'desc'      => '所在地区',
+            'match'     => 'option',
+            'search'    => 'linkage',
+            'option'    => Dever::url('api.get?level_total=4', 'area'),
+        ),
+
+        'province'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '省份',
+            'default'   => '',
+            'desc'      => '省份',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'city'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '城市',
+            'default'   => '',
+            'desc'      => '城市',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'county'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '县区',
+            'default'   => '',
+            'desc'      => '县区',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'town'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '街道',
+            'default'   => '',
+            'desc'      => '街道',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
         'status'        => array
         (
             'type'      => 'tinyint-1',

+ 30 - 21
app/shop/database/buy_order_goods.php

@@ -4,7 +4,14 @@ $status = array
 (
     1 => '正常',
     2 => '缺货',
-    3 => '退款',
+    3 => '申请退款',
+    4 => '已退款',
+);
+
+$type = array
+(
+    1 => '仓库',
+    2 => '工厂',
 );
 
 return array
@@ -30,24 +37,6 @@ return array
             //'list'        => true,
         ),
 
-        'uid'       => array
-        (
-            'type'      => 'int-11',
-            'name'      => '用户名',
-            'default'   => '0',
-            'desc'      => '请选择用户',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-            //'search'  => 'select',
-            'search'    => array
-            (
-                'api' => 'passport/user-all',
-                'col' => 'username',
-                'result' => 'id',
-            ),
-            'list'      => '{uid} > 0 ? Dever::load("passport/user-find#username", {uid}) : "匿名用户"',
-        ),
-
         'shop_id'      => array
         (
             'type'      => 'int-11',
@@ -55,6 +44,8 @@ return array
             'default'   => '',
             'desc'      => '所属门店',
             'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_shop_id'),
             'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
         ),
 
@@ -81,11 +72,29 @@ return array
         (
             'type'      => 'int-11',
             'name'      => 'sku_id',
-            'default'   => '',
+            'default'   => '-1',
             'desc'      => 'sku_id',
             'match'     => 'is_numeric',
         ),
 
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '采购来源',
+            'default'   => '',
+            'desc'      => '采购来源',
+            'match'     => 'is_numeric',
+        ),
+
+        'type_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '来源id',
+            'default'   => '',
+            'desc'      => '来源id',
+            'match'     => 'is_numeric',
+        ),
+
         'attr'      => array
         (
             'type'      => 'text-255',
@@ -157,7 +166,7 @@ return array
 
     'manage' => array
     (
-        
+        'page_list_table' => 'buy_order_goods',
     ),
 
     'request' => array

+ 36 - 0
app/shop/database/goods.php

@@ -230,6 +230,7 @@ return array
                 'hot' => array('yes-t_2.hot'),
                 'top' => array('yes-t_2.top'),
                 //'youhui' => array('yes-t_2.youhui'),
+                'name' => array('yes-t_2.name', 'like'),
                 'column' => array('yes-t_2.column_id', 'like'),
                 'category' => array('yes-t_2.category', 'like'),
                 'top_category_id' => array('yes-t_2.top_category_id'),
@@ -253,5 +254,40 @@ return array
             'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
             'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
         ),
+
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => array('yes-t_1.shop_id'),
+                'hot' => array('yes-t_2.hot'),
+                'top' => array('yes-t_2.top'),
+                //'youhui' => array('yes-t_2.youhui'),
+                'name' => array('yes-t_2.name', 'like'),
+                'column' => array('yes-t_2.column_id', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'goods/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*,t_2.*,t_1.total_num-t_1.sell_num as num,t_1.sell_num',
+        ),
     ),
 );

+ 13 - 4
app/shop/lib/Info.php

@@ -51,13 +51,22 @@ class Info
     }
 
     # 获取店铺的商品列表
-    public function getGoods($shop, $column)
+    public function getGoods($shop, $column = false)
     {
         $table = 'shop/goods';
         $where['shop_id'] = isset($shop['id']) ? $shop['id'] : $shop;
-        $where['column'] = $column;
-        $method = 'getData';
-
+        if ($column) {
+            $where['column'] = $column;
+            $method = 'getData';
+        } else {
+            $method = 'getDataPage';
+        }
+        
+        $name = Dever::input('name');
+        if ($name) {
+            $where['name'] = $name;
+        }
+        
         $data = Dever::db($table)->$method($where);
 
         if ($data) {

+ 3 - 1
app/shop/lib/Sell.php

@@ -147,7 +147,7 @@ class Sell
     # 再次发起支付
     public function raction($id, $refer = '')
     {
-    	$order = Dever::db('goods/order')->find($id);
+    	$order = Dever::db('shop/sell_order')->find($id);
 
     	if (!$order) {
     		Dever::alert('订单信息错误');
@@ -175,6 +175,8 @@ class Sell
         }
 
         $result = Dever::load('pay/api.pay', $param);
+
+        return $result;
     }
 
     # 支付成功回调 安全加密 设置token

+ 4 - 0
app/shop/src/Buy.php

@@ -328,6 +328,10 @@ class Buy extends Core
             }
             
             $num = Dever::input('num');
+            $num = Dever::input('num');
+            if (!$num) {
+                Dever::alert('请传入商品数量');
+            }
             $num = explode(',', $num);
         }
 

+ 20 - 0
app/shop/src/Main.php

@@ -90,4 +90,24 @@ class Main extends Core
 
         return $data;
     }
+
+    # 获取文章详情
+    public function news()
+    {
+        $id = Dever::input('id');
+
+        $this->data['news'] = Dever::load('content/lib/news')->get($id);
+
+        return $this->data;
+    }
+
+    # 获取专题详情
+    public function feature()
+    {
+        $id = Dever::input('id');
+
+        $this->data['feature'] = Dever::load('content/lib/feature')->get($id);
+
+        return $this->data;
+    }
 }