songxingwei 2 年之前
父節點
當前提交
934329f750
共有 70 個文件被更改,包括 5866 次插入0 次删除
  1. 70 0
      application/order/controller/CrystalCash.php
  2. 77 0
      application/order/controller/CrystalOrder.php
  3. 96 0
      application/order/controller/GoodsOrder.php
  4. 97 0
      application/order/controller/IntegralOrder.php
  5. 87 0
      application/order/controller/Order.php
  6. 46 0
      application/order/view/crystal_order/index.html
  7. 28 0
      application/order/view/crystal_order/index_search.html
  8. 50 0
      application/order/view/goods_order/deliver.html
  9. 91 0
      application/order/view/goods_order/detail.html
  10. 52 0
      application/order/view/goods_order/index.html
  11. 50 0
      application/order/view/goods_order/index_search.html
  12. 79 0
      application/order/view/integral_order/deliver.html
  13. 125 0
      application/order/view/integral_order/detail.html
  14. 36 0
      application/order/view/integral_order/form.html
  15. 44 0
      application/order/view/integral_order/index.html
  16. 50 0
      application/order/view/integral_order/index_search.html
  17. 50 0
      application/order/view/order/deliver.html
  18. 109 0
      application/order/view/order/detail.html
  19. 36 0
      application/order/view/order/form.html
  20. 44 0
      application/order/view/order/index.html
  21. 50 0
      application/order/view/order/index_search.html
  22. 196 0
      application/store/command/AutoRun.php
  23. 64 0
      application/store/controller/Config.php
  24. 139 0
      application/store/controller/ExchangeCode.php
  25. 407 0
      application/store/controller/Goods.php
  26. 161 0
      application/store/controller/IntegralGoods.php
  27. 97 0
      application/store/controller/Message.php
  28. 38 0
      application/store/controller/api/Data.php
  29. 38 0
      application/store/controller/api/Express.php
  30. 122 0
      application/store/controller/api/Goods.php
  31. 80 0
      application/store/controller/api/Member.php
  32. 74 0
      application/store/controller/api/Notify.php
  33. 92 0
      application/store/controller/api/Wechat.php
  34. 128 0
      application/store/controller/api/member/Address.php
  35. 122 0
      application/store/controller/api/member/Center.php
  36. 313 0
      application/store/controller/api/member/Order.php
  37. 84 0
      application/store/service/ExpressService.php
  38. 423 0
      application/store/service/ExtendService.php
  39. 71 0
      application/store/service/GoodsService.php
  40. 67 0
      application/store/service/OrderService.php
  41. 19 0
      application/store/sys.php
  42. 18 0
      application/store/view/config/index-about-us.html
  43. 18 0
      application/store/view/config/index-agreement.html
  44. 18 0
      application/store/view/config/index-chain_on_query.html
  45. 18 0
      application/store/view/config/index-registration_agreement.html
  46. 18 0
      application/store/view/config/index-terms_service.html
  47. 40 0
      application/store/view/config/index.html
  48. 18 0
      application/store/view/config/platform-agreement.html
  49. 18 0
      application/store/view/config/platform-notice.html
  50. 100 0
      application/store/view/config/platform-set.html
  51. 18 0
      application/store/view/config/privacy.html
  52. 18 0
      application/store/view/config/purchase-notice.html
  53. 18 0
      application/store/view/config/self.html
  54. 18 0
      application/store/view/config/service.html
  55. 28 0
      application/store/view/exchange_code/form.html
  56. 61 0
      application/store/view/exchange_code/index.html
  57. 25 0
      application/store/view/exchange_code/index_search.html
  58. 55 0
      application/store/view/goods/detail.html
  59. 214 0
      application/store/view/goods/form.html
  60. 479 0
      application/store/view/goods/form2.html
  61. 39 0
      application/store/view/goods/hash.html
  62. 96 0
      application/store/view/goods/index.html
  63. 16 0
      application/store/view/goods/index_search.html
  64. 52 0
      application/store/view/goods/send.html
  65. 115 0
      application/store/view/integral_goods/form.html
  66. 108 0
      application/store/view/integral_goods/index.html
  67. 16 0
      application/store/view/integral_goods/index_search.html
  68. 39 0
      application/store/view/message/form.html
  69. 60 0
      application/store/view/message/index.html
  70. 23 0
      application/store/view/message/index_search.html

+ 70 - 0
application/order/controller/CrystalCash.php

@@ -0,0 +1,70 @@
+<?php
+namespace app\order\controller;
+use library\Controller;
+use think\Db;
+/**
+ * 元石提现管理
+ * Class CrystalCash
+ * @package app\order\controller
+ */
+class CrystalCash extends Controller
+{
+    protected $table = 'CrystalOrder';
+    /**
+     * 充值订单
+     * @auth true
+     * @menu true
+     */
+    public function index()
+    {
+        $this->title = '充值订单';
+        $this->order_status = ['待支付','已支付'];
+        $query = $this->_query($this->table);
+        $where = [];
+        if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
+        if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
+        if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
+        if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
+        $query->alias('o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT');
+        if(!empty($where)) $query->where($where);
+        $query ->order('o.id desc')->page();
+    }
+
+    /**
+     * 订单详情
+     * @auth true
+     * @menu true
+     */
+    public function detail()
+    {
+        $this->title = '订单详情';
+        $order_id = input('id');
+        $detail = Db::table('crystal_order o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT')
+            ->where('o.id',$order_id)
+            ->find();
+        $this->assign('detail',$detail);
+        $this->fetch('detail');
+    }
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if ($this->request->isPost() && $this->request->action() == 'deliver') {
+            $express_company =  Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
+            $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
+            $data['express_send_at'] = date("Y-m-d H:i:s");
+            $data['express_state'] = 1;
+        }
+    }
+
+}

+ 77 - 0
application/order/controller/CrystalOrder.php

@@ -0,0 +1,77 @@
+<?php
+namespace app\order\controller;
+use library\Controller;
+use think\Db;
+/**
+ * 元石充值订单管理
+ * Class CrystalOrder
+ * @package app\order\controller
+ */
+class CrystalOrder extends Controller
+{
+    protected $table = 'CrystalOrder';
+    /**
+     * 充值订单
+     * @auth true
+     * @menu true
+     */
+    public function index()
+    {
+        $this->title = '充值订单';
+        $this->order_status = ['待支付','已支付'];
+        $order_stat = Db::table('crystal_order')
+            ->where('status',1)
+            ->field('price_total')
+            ->select();
+        $this->order_num = empty($order_stat) ? 0: count($order_stat);
+        $this->total_money = empty($order_stat) ? 0: array_sum(array_column($order_stat,'price_total'));
+
+        $query = $this->_query($this->table);
+        $where = [];
+        if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
+        if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
+        if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
+        $where[]= ['o.status','=',1];
+        $query->alias('o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT');
+        if(!empty($where)) $query->where($where);
+        $query ->order('o.id desc')->page();
+    }
+
+    /**
+     * 订单详情
+     * @auth true
+     * @menu true
+     */
+    public function detail()
+    {
+        $this->title = '订单详情';
+        $order_id = input('id');
+        $detail = Db::table('crystal_order o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT')
+            ->where('o.id',$order_id)
+            ->find();
+        $this->assign('detail',$detail);
+        $this->fetch('detail');
+    }
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if ($this->request->isPost() && $this->request->action() == 'deliver') {
+            $express_company =  Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
+            $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
+            $data['express_send_at'] = date("Y-m-d H:i:s");
+            $data['express_state'] = 1;
+        }
+    }
+
+}

+ 96 - 0
application/order/controller/GoodsOrder.php

@@ -0,0 +1,96 @@
+<?php
+namespace app\order\controller;
+use library\Controller;
+use think\Db;
+/**
+ * 商品订单
+ * Class Order
+ * @package app\order\controller
+ */
+class GoodsOrder extends Controller
+{
+    protected $table = 'store_order';
+    /**
+     * 订单列表
+     * @auth true
+     * @menu true
+     */
+    public function index()
+    {
+        $this->title = '订单管理';
+        $this->order_status = ['待支付','已支付','已取消'];
+        $order_stat = Db::table($this->table)
+            ->where('status',1)
+            ->where('is_deleted',0)
+            ->field('pay_price')
+            ->select();
+        $this->order_num = empty($order_stat) ? 0: count($order_stat);
+        $this->total_money = empty($order_stat) ? 0: array_sum(array_column($order_stat,'pay_price'));
+        $query = $this->_query($this->table);
+        $where = [];
+        if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
+        if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
+        if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
+        if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
+        $query->alias('o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.mid = u.id ','LEFT');
+        if(!empty($where)) $query->where($where);
+        $query ->order('o.id desc')->page();
+    }
+
+
+    /**
+     * 订单详情
+     * @auth true
+     * @menu true
+     */
+    public function detail()
+    {
+        $this->order_status = ['待支付','已支付','已取消'];
+        $this->title = '订单详情';
+        $order_id = input('id');
+        $detail = Db::table('store_order o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.mid = u.id ','LEFT')
+            ->where('o.id',$order_id)
+            ->find();
+        $detail['pro_info'] = json_decode($detail['pro_info'],true);
+        $detail['pay_type'] = $detail['pay_type']=='wx' ? '微信' : '支付宝';
+        $this->assign('detail',$detail);
+        $this->fetch('detail');
+    }
+
+    /**
+     * 订单发货
+     * @auth true
+     * @menu true
+     */
+
+    public function deliver()
+    {
+        $this->title = '发货';
+        $this->express_company = Db::table('store_express_company')->field('id,express_title')->select();
+        $this->_form($this->table,'deliver');
+    }
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if ($this->request->isPost() && $this->request->action() == 'deliver') {
+            $express_company =  Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
+            $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
+            $data['express_send_at'] = date("Y-m-d H:i:s");
+            $data['express_state'] = 1;
+        }
+    }
+
+
+}

+ 97 - 0
application/order/controller/IntegralOrder.php

@@ -0,0 +1,97 @@
+<?php
+namespace app\order\controller;
+use library\Controller;
+use think\Db;
+/**
+ * 兑换订单管理
+ * Class IntegralOrder
+ * @package app\order\controller
+ */
+class IntegralOrder extends Controller
+{
+    protected $table = 'ExchangeOrder';
+    /**
+     * 订单列表
+     * @auth true
+     * @menu true
+     */
+    public function index()
+    {
+        $this->title = '兑换订单管理';
+        $this->order_status = ['待支付','已支付/待发货','已发货/待收货','已收货'];
+        $query = $this->_query($this->table);
+        $where = [];
+        $where[] = ['o.is_deleted','=',0];
+        $where[] = ['o.cancel_state','=',0];
+        if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
+        if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
+        if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
+        if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
+
+        $query->alias('o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT');
+        if(!empty($where)) $query->where($where);
+        $query ->order('o.id desc')->page();
+    }
+
+
+    /**
+     * 订单详情
+     * @auth true
+     * @menu true
+     */
+    public function detail()
+    {
+        $this->title = '兑换订单详情';
+        $order_id = input('id');
+        $detail = Db::table('exchange_order o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT')
+            ->where('o.id',$order_id)
+            ->find();
+        $address_info = Db::table('delivery_address')->field('id,mer_name,detail,phone,name')->find($detail['address_id']);
+        $this->assign('detail',$detail);
+        $this->assign('address_info',$address_info);
+        $this->fetch('detail');
+    }
+
+    /**
+     * 订单发货
+     * @auth true
+     * @menu true
+     */
+
+    public function deliver()
+    {
+        $this->title = '发货';
+        $this->express_company = Db::table('store_express_company')->field('id,express_title')->select();
+        $this->_form($this->table,'deliver');
+    }
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if ($this->request->isPost() && $this->request->action() == 'deliver') {
+            $express_company =  Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
+            $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
+            $data['express_send_at'] = date("Y-m-d H:i:s");
+            $data['express_state'] = 1;
+            $data['status'] = 2;
+        }
+        if ($this->request->isGet() && $this->request->action() == 'deliver') {
+            if (isset($data['address_id'])){
+                $this->address_info = Db::table('delivery_address')->field('id,mer_name,detail,phone,name')->find($data['address_id']);
+            }
+        }
+    }
+
+
+}

+ 87 - 0
application/order/controller/Order.php

@@ -0,0 +1,87 @@
+<?php
+namespace app\order\controller;
+use library\Controller;
+use think\Db;
+/**
+ * 订单管理
+ * Class Order
+ * @package app\order\controller
+ */
+class Order extends Controller
+{
+    protected $table = 'StoreOrder';
+    /**
+     * 订单列表
+     * @auth true
+     * @menu true
+     */
+    public function index()
+    {
+        $this->title = '线上商城订单管理';
+        $this->order_status = ['待支付','已支付/待发货','已发货/待收货','已收货','已评论','','','','','已取消'];
+        $query = $this->_query($this->table);
+        $where = [];
+        if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
+        if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
+        if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
+        if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
+        $where[] =['source','=',0] ;
+        $query->alias('o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT');
+        if(!empty($where)) $query->where($where);
+        $query ->order('o.id desc')->page();
+    }
+
+
+    /**
+     * 订单详情
+     * @auth true
+     * @menu true
+     */
+    public function detail()
+    {
+        $this->title = '订单详情';
+        $order_id = input('id');
+        $detail = Db::table('store_order o')
+            ->field('o.* , u.name as user_name ,u.phone')
+            ->join('store_member u',' o.uid = u.id ','LEFT')
+            ->where('o.id',$order_id)
+            ->find();
+        $this->assign('detail',$detail);
+        $this->fetch('detail');
+    }
+
+    /**
+     * 订单发货
+     * @auth true
+     * @menu true
+     */
+
+    public function deliver()
+    {
+        $this->title = '发货';
+        $this->express_company = Db::table('store_express_company')->field('id,express_title')->select();
+        $this->_form($this->table,'deliver');
+    }
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if ($this->request->isPost() && $this->request->action() == 'deliver') {
+            $express_company =  Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
+            $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
+            $data['express_send_at'] = date("Y-m-d H:i:s");
+            $data['express_state'] = 1;
+        }
+    }
+
+
+}

+ 46 - 0
application/order/view/crystal_order/index.html

@@ -0,0 +1,46 @@
+{extend name='admin@main'}
+{block name="content"}
+<div class="think-box-shadow">
+    <div style="background-color: #e3e3c7 ;height: 50px;overflow: hidden">
+        <p style="line-height: 50px;font-size: 16px">&nbsp;&nbsp;
+            总订单数:<span style='color:red'>{$order_num}</span> ,
+            总金额:<span style='color:red'>{$total_money}</span>
+        </p>
+    </div>
+    {include file='crystal_order/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
+            <th class='text-left nowrap'>用户名</th>
+            <th class='text-left nowrap'>手机号</th>
+            <th class='text-left nowrap'>订单金额</th>
+            <th class='text-left nowrap'>充值元石</th>
+            <th class='text-left nowrap'>订单号</th>
+            <th class='text-left nowrap'>订单状态</th>
+            <th class="text-left nowrap">支付时间</th>
+            <th class="text-left nowrap">添加时间</th>
+
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class='text-left nowrap'>{$vo.user_name|default=''}</td>
+            <td class='text-left nowrap'>{$vo.phone|default=''}</td>
+            <td class='text-left nowrap'>{$vo.price_total|default=''}</td>
+            <td class='text-left nowrap'>{$vo.crystal|default=''}</td>
+            <td class='text-left nowrap'>{$vo.order_no|default=''}</td>
+            <td class='text-left nowrap'>{$order_status[$vo.status]|default=''}</td>
+            <td class='text-left nowrap'>{$vo.pay_at|default='--'}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+{/block}

+ 28 - 0
application/order/view/crystal_order/index_search.html

@@ -0,0 +1,28 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单号</label>
+            <div class="layui-input-inline">
+                <input name="order_no" value="{$Think.get.order_no|default=''}" placeholder="请输入订单号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">手机号</label>
+            <div class="layui-input-inline">
+                <input name="tel" value="{$Think.get.tel|default=''}" placeholder="请输入手机号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">用户名称</label>
+            <div class="layui-input-inline">
+                <input name="user_name" value="{$Think.get.user_name|default=''}" placeholder="请输入用户名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 50 - 0
application/order/view/goods_order/deliver.html

@@ -0,0 +1,50 @@
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body" style="height: 400px">
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">订单号</label>
+            <label class="layui-col-xs10">
+                <input name="order_no"  style="background-color: #e6e6e6" readonly value='{$vo.order_no|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">快递公司</label>
+            <div class="layui-input-inline">
+                <select name="express_company_id" >
+                    {foreach $express_company as $ck=>$cv}
+                        {if $cv.id == $vo.express_company_id}
+                        <option selected value="{$cv.id}">{$cv.express_title}</option>
+                        {else}
+                        <option value="{$cv.id}">{$cv.express_title}</option>
+                        {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">物流单号</label>
+            <label class="layui-col-xs10">
+                <input name="express_send_no"  value='{$vo.express_send_no}' placeholder="请输入物流单号" class="layui-input">
+            </label>
+        </div>
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">发货时间</label>
+            <label class="layui-col-xs10">
+                <input readonly name="express_send_at"  value='{$vo.express_send_at|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center">
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <input type='hidden' value='{$vo.uid}' name='uid'>
+        <button class="layui-btn" type='submit'>发货</button>
+    </div>
+</form>
+<script>
+    window.form.render();
+    $("#layui-layer-content").height(600)
+</script>

+ 91 - 0
application/order/view/goods_order/detail.html

@@ -0,0 +1,91 @@
+<style>
+    .layui-card-body
+    {
+        height: 60%;
+    }
+</style>
+<div class="layui-card-body">
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">订单号</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.order_no|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">用户名</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.user_name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">会员手机</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.phone|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">商品数</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.num|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">藏品名称</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.pro_info.name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">商品封面</label>
+        <div class="layui-input-block">
+            <img  src="{$detail.pro_info.cover|default=''}" width="50px">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">订单金额</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.pay_price|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">支付方式</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.pay_type|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">支付方式</label>
+        <div class="layui-input-block">
+            <input readonly  value="{$order_status[$detail.status]}{if $detail.status eq 2}({eq name='detail.cancel_state' value='1'}自动取消{/eq}{eq name='detail.cancel_state' value='2'}手动取消{/eq}){/if}" placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">支付时间</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.pay_at|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">创建时间</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.create_at|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+</div>
+
+<script>
+    window.form.render();
+
+</script>

+ 52 - 0
application/order/view/goods_order/index.html

@@ -0,0 +1,52 @@
+{extend name='admin@main'}
+{block name="content"}
+<div class="think-box-shadow">
+    <div style="background-color: #e3e3c7 ;height: 50px;overflow: hidden">
+        <p style="line-height: 50px;font-size: 16px">&nbsp;&nbsp;
+            总支付单数:<span style='color:red'>{$order_num}</span> ,
+            总销售额:<span style='color:red'>{$total_money}</span>
+        </p>
+    </div>
+    {include file='goods_order/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
+            <th class='text-left nowrap'>用户名</th>
+            <th class='text-left nowrap'>手机号</th>
+            <th class='text-left nowrap'>订单金额</th>
+            <th class='text-left nowrap'>商品数量</th>
+            <th class='text-left nowrap'>订单号</th>
+            <th class='text-left nowrap'>订单状态</th>
+            <th class="text-left nowrap">支付方式</th>
+            <th class="text-left nowrap">下单时间</th>
+            <th class="text-left nowrap">支付时间</th>
+            <th class="text-left nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class='text-left nowrap'>{$vo.user_name|default=''}</td>
+            <td class='text-left nowrap'>{$vo.phone|default=''}</td>
+            <td class='text-left nowrap'>{$vo.pay_price|default=''}</td>
+            <td class='text-left nowrap'>{$vo.num|default=''}</td>
+            <td class='text-left nowrap'>{$vo.order_no|default=''}</td>
+            <td class='text-left nowrap'>{$order_status[$vo.status]}{if $vo.status eq 2}({eq name='vo.cancel_state' value='1'}自动取消{/eq}{eq name='vo.cancel_state' value='2'}手动取消{/eq}){/if}</td>
+            <td class='text-left nowrap'>{eq name='vo.pay_type' value='wx'}微信{/eq}{eq name='vo.pay_type' value='zfb'}支付宝{/eq}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+            <td class='text-left nowrap'>{$vo.pay_at}</td>
+
+            <td class='text-left nowrap'>
+                <a data-title="查看详情" class="layui-btn layui-btn-sm" data-modal='{:url("detail")}?id={$vo.id}'>查看详情</a>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+{/block}

+ 50 - 0
application/order/view/goods_order/index_search.html

@@ -0,0 +1,50 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单号</label>
+            <div class="layui-input-inline">
+                <input name="order_no" value="{$Think.get.order_no|default=''}" placeholder="请输入订单号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">手机号</label>
+            <div class="layui-input-inline">
+                <input name="tel" value="{$Think.get.tel|default=''}" placeholder="请输入手机号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">用户名称</label>
+            <div class="layui-input-inline">
+                <input name="user_name" value="{$Think.get.user_name|default=''}" placeholder="请输入用户名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单状态</label>
+            <div class="layui-input-inline">
+                <select class="layui-select" name="order_status">
+                    <option  value="-1">全部</option>
+                    {foreach $order_status as $k=>$v}
+                        {if $v}
+                            {if $Think.get.order_status eq $k}
+                            <option selected value="{$k}">{$v}</option>
+                            {else}
+                            <option  value="{$k}">{$v}</option>
+                            {/if}
+                        {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+
+
+
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 79 - 0
application/order/view/integral_order/deliver.html

@@ -0,0 +1,79 @@
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body" style="height: 400px">
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">订单号</label>
+            <label class="layui-col-xs10">
+                <input name="order_no"  style="background-color: #e6e6e6" readonly value='{$vo.order_no|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">收货地区</label>
+            <label class="layui-col-xs10">
+                <input  style="background-color: #e6e6e6" readonly value='{$address_info.mer_name|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">详细地址</label>
+            <label class="layui-col-xs10">
+                <input  style="background-color: #e6e6e6" readonly value='{$address_info.detail|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">收货人</label>
+            <label class="layui-col-xs10">
+                <input  style="background-color: #e6e6e6" readonly value='{$address_info.name|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">电话</label>
+            <label class="layui-col-xs10">
+                <input  style="background-color: #e6e6e6" readonly value='{$address_info.phone|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">快递公司</label>
+            <div class="layui-input-inline">
+                <select name="express_company_id" >
+                    {foreach $express_company as $ck=>$cv}
+                    {if $cv.id == $vo.express_company_id}
+                    <option selected value="{$cv.id}">{$cv.express_title}</option>
+                    {else}
+                    <option value="{$cv.id}">{$cv.express_title}</option>
+                    {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">物流单号</label>
+            <label class="layui-col-xs10">
+                <input name="express_send_no"  value='{$vo.express_send_no}' placeholder="请输入物流单号" class="layui-input">
+            </label>
+        </div>
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">发货时间</label>
+            <label class="layui-col-xs10">
+                <input readonly name="express_send_at"  value='{$vo.express_send_at|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center" style="margin-top: 100px">
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <input type='hidden' value='{$vo.uid}' name='uid'>
+        <button class="layui-btn" type='submit'>发货</button>
+    </div>
+</form>
+<script>
+    window.form.render();
+    $("#layui-layer-content").height(800)
+</script>

+ 125 - 0
application/order/view/integral_order/detail.html

@@ -0,0 +1,125 @@
+<style>
+    .layui-card-body
+    {
+        height: 60%;
+    }
+</style>
+<div class="layui-card-body">
+    <div class="layui-form-item">
+        <label class="layui-form-label ">订单号</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.order_no|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    {if $detail.express_send_no}
+    <div class="layui-form-item">
+        <label class="layui-form-label ">物流单号</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.express_send_no|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    {/if}
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">用户名</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.user_name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label ">会员手机</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.phone|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">商品名称</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.goods_name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">商品封面</label>
+        <div class="layui-input-block">
+            <img  src="{$detail.goods_cover}" style="height: 50px;width: 50px" />
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">商品数</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.goods_num|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label ">订单总额</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.price_total|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">收货地区</label>
+        <div class="layui-input-block">
+            <input  readonly value='{$address_info.mer_name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">详细地址</label>
+        <div class="layui-input-block">
+            <input  readonly value='{$address_info.detail|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">收货人</label>
+        <div class="layui-input-block">
+            <input   readonly value='{$address_info.name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label ">电话</label>
+        <div class="layui-input-block">
+            <input  readonly value='{$address_info.phone|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label ">物流公司</label>
+        <div class="layui-input-block">
+            <input name="express_company_title"  value='{$detail.express_company_title}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">物流单号</label>
+        <div class="layui-input-block">
+            <input name="express_send_no"  value='{$detail.express_send_no}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label ">发货时间</label>
+        <div class="layui-input-block">
+            <input readonly name="express_send_at"  value='{$detail.express_send_at|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label ">兑换时间</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.pay_time|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+</div>
+
+<script>
+    window.form.render();
+
+</script>

+ 36 - 0
application/order/view/integral_order/form.html

@@ -0,0 +1,36 @@
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body">
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">用户名</label>
+            <label class="layui-col-xs10">
+                {notempty name='vo.id'}  <input name="name" required value='{$vo.name|default=""}' style="background-color: #e6e6e6" readonly class="layui-input">{/notempty}
+                {empty name='vo.id'}  <input name="name" required value='{$vo.name|default=""}' placeholder="请输入用户名" class="layui-input">{/empty}
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">登录手机号</label>
+            <label class="layui-col-xs10">
+                {notempty name='vo.id'}    <input name="phone" required value='{$vo.phone|default=""}' style="background-color: #e6e6e6" readonly class="layui-input">{/notempty}
+                {empty name='vo.id'}       <input name="phone" required value='{$vo.phone|default=""}' placeholder="请输入登录手机号" class="layui-input">{/empty}
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">登录密码</label>
+            <label class="layui-col-xs10">
+                <input name="password" required value='{$vo.password|default=""}' placeholder="请输入登录密码" class="layui-input">
+            </label>
+        </div>
+
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center">
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <button class="layui-btn" type='submit'>保存数据</button>
+        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
+    </div>
+</form>

+ 44 - 0
application/order/view/integral_order/index.html

@@ -0,0 +1,44 @@
+{extend name='admin@main'}
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='integral_order/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
+            <th class='text-left nowrap'>用户名</th>
+            <th class='text-left nowrap'>手机号</th>
+            <th class='text-left nowrap'>订单金额</th>
+            <th class='text-left nowrap'>商品数量</th>
+            <th class='text-left nowrap'>订单号</th>
+            <th class='text-left nowrap'>订单状态</th>
+            <th class="text-left nowrap">添加时间</th>
+            <th class="text-left nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class='text-left nowrap'>{$vo.user_name|default=''}</td>
+            <td class='text-left nowrap'>{$vo.phone|default=''}</td>
+            <td class='text-left nowrap'>{$vo.price_total|default=''}</td>
+            <td class='text-left nowrap'>{$vo.goods_num|default=''}</td>
+            <td class='text-left nowrap'>{$vo.order_no|default=''}</td>
+            <td class='text-left nowrap'>{$order_status[$vo.status]|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+            <td class='text-left nowrap'>
+                {if $vo.status > 0 && $vo.status != 9}
+                <a data-title="发货" class="layui-btn layui-btn-sm" data-modal='{:url("deliver")}?id={$vo.id}'>发货</a>
+                {/if}
+                <a data-title="查看详情" class="layui-btn layui-btn-sm" data-modal='{:url("detail")}?id={$vo.id}'>查看详情</a>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+{/block}

+ 50 - 0
application/order/view/integral_order/index_search.html

@@ -0,0 +1,50 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单号</label>
+            <div class="layui-input-inline">
+                <input name="order_no" value="{$Think.get.order_no|default=''}" placeholder="请输入订单号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">手机号</label>
+            <div class="layui-input-inline">
+                <input name="tel" value="{$Think.get.tel|default=''}" placeholder="请输入手机号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">用户名称</label>
+            <div class="layui-input-inline">
+                <input name="user_name" value="{$Think.get.user_name|default=''}" placeholder="请输入用户名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单状态</label>
+            <div class="layui-input-inline">
+                <select class="layui-select" name="order_status">
+                    <option  value="-1">全部</option>
+                    {foreach $order_status as $k=>$v}
+                    {if $v}
+                    {if $Think.get.order_status eq $k}
+                    <option selected value="{$k}">{$v}</option>
+                    {else}
+                    <option  value="{$k}">{$v}</option>
+                    {/if}
+                    {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+
+
+
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 50 - 0
application/order/view/order/deliver.html

@@ -0,0 +1,50 @@
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body" style="height: 400px">
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">订单号</label>
+            <label class="layui-col-xs10">
+                <input name="order_no"  style="background-color: #e6e6e6" readonly value='{$vo.order_no|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">快递公司</label>
+            <div class="layui-input-inline">
+                <select name="express_company_id" >
+                    {foreach $express_company as $ck=>$cv}
+                        {if $cv.id == $vo.express_company_id}
+                        <option selected value="{$cv.id}">{$cv.express_title}</option>
+                        {else}
+                        <option value="{$cv.id}">{$cv.express_title}</option>
+                        {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">物流单号</label>
+            <label class="layui-col-xs10">
+                <input name="express_send_no"  value='{$vo.express_send_no}' placeholder="请输入物流单号" class="layui-input">
+            </label>
+        </div>
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">发货时间</label>
+            <label class="layui-col-xs10">
+                <input readonly name="express_send_at"  value='{$vo.express_send_at|default=""}' placeholder="" class="layui-input">
+            </label>
+        </div>
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center">
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <input type='hidden' value='{$vo.uid}' name='uid'>
+        <button class="layui-btn" type='submit'>发货</button>
+    </div>
+</form>
+<script>
+    window.form.render();
+    $("#layui-layer-content").height(600)
+</script>

+ 109 - 0
application/order/view/order/detail.html

@@ -0,0 +1,109 @@
+<style>
+    .layui-card-body
+    {
+        height: 60%;
+    }
+</style>
+<div class="layui-card-body">
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">订单号</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.order_no|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    {if $detail.express_send_no}
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">物流单号</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.express_send_no|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    {/if}
+    {if $detail.pay_state == 1}
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">支付号</label>
+            <div class="layui-input-block">
+                <input  readonly  value='{$detail.pay_no|default=""}' placeholder="" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">支付时间</label>
+            <div class="layui-input-block">
+                <input  readonly  value='{$detail.pay_at|default=""}' placeholder="" class="layui-input">
+            </div>
+        </div>
+    {/if}
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">用户名</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.user_name|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">会员手机</label>
+        <div class="layui-input-block">
+            <input  readonly  value='{$detail.phone|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">商品数</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.total_num|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">商品详情</label>
+        <div class="layui-input-block">
+            <table class="layui-table margin-top-10" lay-skin="line">
+                <thead>
+                <tr>
+                    <th class='text-left nowrap'>货号</th>
+                    <th class='text-left nowrap'>图片</th>
+                    <th class='text-left nowrap'>数量</th>
+                    <th class='text-left nowrap'>价格</th>
+                </tr>
+                </thead>
+                <tbody class="no_html">
+                {foreach :json_decode($detail.pro_info,true) as $sk=>$sv}
+                <tr class="no_detail">
+                    <td class='text-left nowrap'>
+                        <input class='layui-input' readonly style="background-color: #e6e6e6" name='goods_no[]' value="{$sv['goods_no']}"/>
+                    </td>
+                    <td class='text-left nowrap'><img  src="{$vo.spec_img|default=''}" width="30px"></td>
+                    <td class='text-left nowrap'>
+                        <input class='layui-input'  readonly style="background-color: #e6e6e6" name='store_num[]' value="{$sv['num']}"/>
+                    </td>
+                    <td class='text-left nowrap'>
+                        <input class='layui-input'  readonly style="background-color: #e6e6e6" name='sell_money[]' value="{$sv['sell_money']}"/>
+                    </td>
+                </tr>
+                {/foreach}
+                </tbody>
+            </table>
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">订单总金额</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.price_total|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+
+    <div class="layui-form-item">
+        <label class="layui-form-label label-required">创建时间</label>
+        <div class="layui-input-block">
+            <input readonly  value='{$detail.create_at|default=""}' placeholder="" class="layui-input">
+        </div>
+    </div>
+
+</div>
+
+<script>
+    window.form.render();
+
+</script>

+ 36 - 0
application/order/view/order/form.html

@@ -0,0 +1,36 @@
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body">
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">用户名</label>
+            <label class="layui-col-xs10">
+                {notempty name='vo.id'}  <input name="name" required value='{$vo.name|default=""}' style="background-color: #e6e6e6" readonly class="layui-input">{/notempty}
+                {empty name='vo.id'}  <input name="name" required value='{$vo.name|default=""}' placeholder="请输入用户名" class="layui-input">{/empty}
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">登录手机号</label>
+            <label class="layui-col-xs10">
+                {notempty name='vo.id'}    <input name="phone" required value='{$vo.phone|default=""}' style="background-color: #e6e6e6" readonly class="layui-input">{/notempty}
+                {empty name='vo.id'}       <input name="phone" required value='{$vo.phone|default=""}' placeholder="请输入登录手机号" class="layui-input">{/empty}
+            </label>
+        </div>
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">登录密码</label>
+            <label class="layui-col-xs10">
+                <input name="password" required value='{$vo.password|default=""}' placeholder="请输入登录密码" class="layui-input">
+            </label>
+        </div>
+
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center">
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <button class="layui-btn" type='submit'>保存数据</button>
+        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
+    </div>
+</form>

+ 44 - 0
application/order/view/order/index.html

@@ -0,0 +1,44 @@
+{extend name='admin@main'}
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='order/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
+            <th class='text-left nowrap'>用户名</th>
+            <th class='text-left nowrap'>手机号</th>
+            <th class='text-left nowrap'>订单金额</th>
+            <th class='text-left nowrap'>商品数量</th>
+            <th class='text-left nowrap'>订单号</th>
+            <th class='text-left nowrap'>订单状态</th>
+            <th class="text-center nowrap">添加时间</th>
+            <th class="text-center nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class='text-left nowrap'>{$vo.user_name|default=''}</td>
+            <td class='text-left nowrap'>{$vo.phone|default=''}</td>
+            <td class='text-left nowrap'>{$vo.price_total|default=''}</td>
+            <td class='text-left nowrap'>{$vo.goods_num|default=''}</td>
+            <td class='text-left nowrap'>{$vo.order_no|default=''}</td>
+            <td class='text-left nowrap'>{$order_status[$vo.status]|default=''}</td>
+            <td class='text-center nowrap'>{$vo.create_at}</td>
+            <td class='text-center nowrap'>
+                {if $vo.status > 0 && $vo.status != 9}
+                <a data-title="发货" class="layui-btn layui-btn-sm" data-modal='{:url("deliver")}?id={$vo.id}'>发货</a>
+                {/if}
+                <a data-title="查看详情" class="layui-btn layui-btn-sm" data-modal='{:url("detail")}?id={$vo.id}'>查看详情</a>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+{/block}

+ 50 - 0
application/order/view/order/index_search.html

@@ -0,0 +1,50 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单号</label>
+            <div class="layui-input-inline">
+                <input name="order_no" value="{$Think.get.order_no|default=''}" placeholder="请输入订单号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">手机号</label>
+            <div class="layui-input-inline">
+                <input name="tel" value="{$Think.get.tel|default=''}" placeholder="请输入手机号" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">用户名称</label>
+            <div class="layui-input-inline">
+                <input name="user_name" value="{$Think.get.user_name|default=''}" placeholder="请输入用户名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">订单状态</label>
+            <div class="layui-input-inline">
+                <select class="layui-select" name="order_status">
+                    <option  value="-1">全部</option>
+                    {foreach $order_status as $k=>$v}
+                        {if $v}
+                            {if $Think.get.order_status eq $k}
+                            <option selected value="{$k}">{$v}</option>
+                            {else}
+                            <option  value="{$k}">{$v}</option>
+                            {/if}
+                        {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+
+
+
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 196 - 0
application/store/command/AutoRun.php

@@ -0,0 +1,196 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\Output;
+use think\Db;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\ModelNotFoundException;
+use think\Exception;
+use think\exception\DbException;
+use think\exception\PDOException;
+use We;
+
+/**
+ * 商城数据处理指令
+ * Class AutoRun
+ * @package app\store\command
+ */
+class AutoRun extends Command
+{
+
+    /**
+     * 配置指令信息
+     */
+    protected function configure()
+    {
+        $this->setName('xclean:store')->setDescription('[清理]检查并处理商城任务');
+    }
+
+    /**
+     * 业务指令执行
+     * @param Input $input
+     * @param Output $output
+     * @throws Exception
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
+     * @throws PDOException
+     */
+    protected function execute(Input $input, Output $output)
+    {
+        // 自动取消30分钟未支付的订单
+        $this->autoCancelOrder();
+        // 清理一天前未支付的订单
+        $this->autoRemoveOrder();
+        // 订单自动退款处理
+        // $this->autoRefundOrder();
+        // 提现自动打款处理
+        // $this->autoTransfer();
+    }
+
+    /**
+     * 自动取消30分钟未支付的订单
+     * @throws Exception
+     * @throws PDOException
+     */
+    private function autoCancelOrder()
+    {
+        $datetime = $this->getDatetime('store_order_wait_time');
+        $where = [['status', 'in', ['1', '2']], ['pay_state', 'eq', '0'], ['create_at', '<', $datetime]];
+        $count = Db::name('StoreOrder')->where($where)->update([
+            'status'       => '0',
+            'cancel_state' => '1',
+            'cancel_at'    => date('Y-m-d H:i:s'),
+            'cancel_desc'  => '30分钟未完成支付自动取消订单',
+        ]);
+        if ($count > 0) {
+            $this->output->info("共计自动取消了30分钟未支付的{$count}笔订单!");
+        } else {
+            $this->output->comment('没有需要自动取消30分钟未支付的订单记录!');
+        }
+    }
+
+    /**
+     * 清理一天前未支付的订单
+     * @throws Exception
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
+     * @throws PDOException
+     */
+    private function autoRemoveOrder()
+    {
+        $datetime = $this->getDatetime('store_order_clear_time');
+        $where = [['status', 'eq', '0'], ['pay_state', 'eq', '0'], ['create_at', '<', $datetime]];
+        $list = Db::name('StoreOrder')->where($where)->limit(20)->select();
+        if (count($orderNos = array_unique(array_column($list, 'order_no'))) > 0) {
+            $this->output->info("自动删除前一天已经取消的订单:" . PHP_EOL . join(',' . PHP_EOL, $orderNos));
+            Db::name('StoreOrder')->whereIn('order_no', $orderNos)->delete();
+            Db::name('StoreOrderList')->whereIn('order_no', $orderNos)->delete();
+        } else {
+            $this->output->comment('没有需要自动删除前一天已经取消的订单!');
+        }
+    }
+
+    /**
+     * 订单自动退款操作
+     * @throws Exception
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
+     * @throws PDOException
+     */
+    private function autoRefundOrder()
+    {
+        // 未完成退款的订单,执行微信退款操作
+        foreach (Db::name('StoreOrder')->where(['refund_state' => '1'])->select() as $order) try {
+            $this->output->writeln("正在为 {$order['order_no']} 执行退款操作...");
+            $result = We::WePayRefund(config('wechat.wxpay'))->create([
+                'transaction_id' => $order['pay_no'],
+                'out_refund_no'  => $order['refund_no'],
+                'total_fee'      => $order['price_total'] * 100,
+                'refund_fee'     => $order['pay_price'] * 100,
+                'refund_account' => 'REFUND_SOURCE_UNSETTLED_FUNDS',
+            ]);
+            if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') {
+                Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update([
+                    'refund_state' => '2', 'refund_desc' => '自动退款成功!',
+                ]);
+            } else {
+                Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update([
+                    'refund_desc' => isset($result['err_code_des']) ? $result['err_code_des'] : '自动退款失败',
+                ]);
+            }
+        } catch (\Exception $e) {
+            $this->output->writeln("订单 {$order['order_no']} 执行退款失败,{$e->getMessage()}!");
+            Db::name('StoreOrder')->where(['order_no' => $order['order_no']])->update(['refund_desc' => $e->getMessage()]);
+        }
+        $this->output->writeln('自动检测退款订单执行完成!');
+    }
+
+    /**
+     * 自动企业打款操作
+     * @throws Exception
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
+     * @throws PDOException
+     */
+    private function autoTransfer()
+    {
+        # 批量企业打款
+        foreach (Db::name('StoreProfitUsed')->where(['status' => '1'])->select() as $vo) try {
+            $wechat = We::WePayTransfers(config('wechat.wxpay'));
+            $result = $wechat->create([
+                'partner_trade_no' => $vo['trs_no'],
+                'openid'           => $vo['openid'],
+                'check_name'       => 'NO_CHECK',
+                'amount'           => $vo['pay_price'] * 100,
+                'desc'             => '营销活动拥金提现',
+                'spbill_create_ip' => '127.0.0.1',
+            ]);
+            if ($result['return_code'] === 'SUCCESS' && $result['result_code'] === 'SUCCESS') {
+                Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update([
+                    'status' => '2', 'pay_desc' => '拥金提现成功!', 'pay_no' => $result['payment_no'], 'pay_at' => date('Y-m-d H:i:s'),
+                ]);
+            } else {
+                Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update([
+                    'pay_desc' => isset($result['err_code_des']) ? $result['err_code_des'] : '自动打款失败', 'last_at' => date('Y-m-d H:i:s'),
+                ]);
+            }
+        } catch (\Exception $e) {
+            $this->output->writeln("订单 {$vo['trs_no']} 执行提现失败,{$e->getMessage()}!");
+            Db::name('StoreProfitUsed')->where(['trs_no' => $vo['trs_no']])->update(['pay_desc' => $e->getMessage()]);
+        }
+    }
+
+    /**
+     * 获取配置时间
+     * @param string $code
+     * @return string
+     * @throws Exception
+     * @throws PDOException
+     */
+    private function getDatetime($code)
+    {
+        $minutes = intval(sysconf($code) * 60);
+        return date('Y-m-d H:i:s', strtotime("-{$minutes} minutes"));
+    }
+
+}

+ 64 - 0
application/store/controller/Config.php

@@ -0,0 +1,64 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller;
+
+use app\store\service\ExtendService;
+use library\Controller;
+
+/**
+ * 活动参数配置
+ * Class Config
+ * @package app\store\controller
+ */
+class Config extends Controller
+{
+
+    /**
+     * 活动参数配置
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        $this->title = '参数配置';
+        $this->applyCsrfToken('save');
+        $this->query = ExtendService::queryChinaSmsBalance();
+        $this->query2 = ExtendService::queryGlobeSmsBalance();
+        $this->sell_switch = sysconf('sell_switch');
+        $this->crystal_switch = sysconf('crystal_switch');
+        $this->goods_detail_switch = sysconf('goods_detail_switch');
+        $this->fetch();
+    }
+
+    /**
+     * 保存商城参数
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function save()
+    {
+        if ($this->request->isPost()) {
+            $this->applyCsrfToken('save');
+            foreach ($this->request->post() as $k => $v) sysconf($k, $v);
+            setAdvanceMinutes();
+            $this->success('保存成功!');
+        }
+    }
+
+}

+ 139 - 0
application/store/controller/ExchangeCode.php

@@ -0,0 +1,139 @@
+<?php
+namespace app\store\controller;
+use library\Controller;
+use think\Db;
+
+/**
+ * 兑换码
+ * Class ExchangeCode
+ * @package app\store\controller
+ */
+class ExchangeCode extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'GoodsCode';
+
+    /**
+     * 兑换码列表
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        $this->title = '兑换码管理';
+        $goods_id = input('id',0);
+        $code = input('code','');
+        $status = input('status',0);
+        $this->goods_id = $goods_id;
+        $query = $this->_query($this->table)->alias('c')
+            ->field('c.*,m.name as user_name')
+            ->join('store_member m','m.id=c.user_id','LEFT')
+            ->where('c.goods_id',$goods_id);
+        if($code) $query->where('c.code',$code);
+        if($status) $query->where('c.status',$status);
+        $query->order('status asc , id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+        foreach ($data as $k=>&$v){
+
+        }
+    }
+
+
+
+    /**
+     * 添加兑换码
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加兑换码';
+        $goods_id = input('goods_id',0);
+        $this->goods_id = $goods_id;
+        $this->_form($this->table, 'form');
+    }
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if($this->request->post() &&  $this->request->action() == 'add'){
+            $code_arr=[];
+            for($i=0;$i< $data['num'];$i++){
+                $code_str = $this->getRegisterCode($data['goods_id']);
+                $code_arr[] = [
+                    'code' => $code_str,
+                    'goods_id' => $data['goods_id'],
+                ];
+            }
+            Db::table('goods_code')->insertAll($code_arr);
+            $this->success('添加成功!');
+        }
+    }
+
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 兑换码下架
+     */
+    public function del()
+    {
+        $this->_delete($this->table);
+    }
+
+
+
+    public function getRegisterCode($goods_id)
+    {
+        $length = 13;
+        $base_code = explode(',',"A,B,C,D,E,F,G,H,J,K,L,0,1,2,3,4,5,6,7,8,9,M,N,P,Q,R,S,T,U,V,W,X,Y,Z");
+        $id_length = strlen($goods_id);
+        $code_key = array_rand($base_code, $length - $id_length);
+        $code_str = '';
+        array_map(function ($val)use (&$code_str,$base_code){
+            $code_str .=$base_code[$val] ;
+        },$code_key);
+        return $code_str.$goods_id;
+    }
+
+
+
+
+
+
+
+}

+ 407 - 0
application/store/controller/Goods.php

@@ -0,0 +1,407 @@
+<?php
+namespace app\store\controller;
+use library\Controller;
+use think\cache\driver\Redis;
+use think\Db;
+
+/**
+ * 商品
+ * Class Goods
+ * @package app\store\controller
+ */
+class Goods extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'store_collection';
+
+    /**
+     * 商品列表
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        checkCollectionState();
+        $this->title = '藏品管理';
+        $query = $this->_query($this->table)->where('is_deleted',0)->like('name');
+        $query->dateBetween('create_at')->order('id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+        foreach ($data as &$v){
+            $checksell = $this->checkSellTime($v['id']);
+            if (!$checksell){
+                $v['is_save'] = 0;
+            }else{
+                $v['is_save'] = 1;
+            }
+
+            $v['zz']=Db::table('hash')->where('goods_id',$v['id'])->where('success',1)->count();
+        }
+    }
+
+
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加藏品';
+        $this->_form($this->table, 'form');
+    }
+
+
+    /**
+     * 编辑商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    function edit()
+    {
+        $this->title = '编辑商品';
+        $id = $this->request->get('id');
+        $checksell = $this->checkSellTime($id);
+        if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
+        $this->_form($this->table, 'form');
+    }
+
+
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if($this->request->post()){
+            if (isset($data['id']) || !empty($data['id'])){
+                $checksell = $this->checkSellTime($data['id']);
+                if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
+            }
+            if ($data['cover'] == '') $this->error('请上传藏品图片');
+            if ($data['auth_img'] == '') $this->error('请上传作者头像');
+            if ($data['describe'] == '') $this->error('请上传商品描述');
+            if ($data['buy_count']<1) $this->error('限购数量不能小于1');
+            //if ($data['share_img'] == '') $this->error('请上传分享二维码');
+            $data['date'] = date('Y-m-d',strtotime($data['sell_time']));
+            if (isset($data['id'])){
+                $buy_count = Db::name('store_order_info')->where('c_id',$data['id'])->count();
+            }else{
+                $buy_count = 0;
+            }
+
+            $data['now_inventory'] = $data['inventory']-$buy_count;
+        }else{
+            if (!empty($data)){
+                $data['covers'] = $data['cover'];
+                $data['auth_imgs'] = $data['auth_img'];
+                $data['describes'] = $data['describe'];
+                $data['share_imgs'] = $data['share_img'];
+            }
+        }
+    }
+
+    /**
+     * 处理成功回调
+     */
+    public function _form_result($result,$data){
+        if ($result) {
+            setCollectionInfoHash($result);
+            $redis = new Redis();
+            $count = Db::name($this->table)->where('id',$result)->value('now_inventory');
+            $redis->set('collection_count_'.$result,$count);
+            $this->success('操作成功',url('/#/store/goods/index'));
+        }
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品上架
+     */
+    public function up()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['status'=>1])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品下架
+     */
+    public function down()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['status'=>0])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+        //$this->_save($this->table, ['status' => '0']);
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品删除
+     */
+    public function del()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['is_deleted'=>1])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+        //$this->_save($this->table, ['is_deleted' => '1']);
+    }
+
+//    public function _save_result($result){
+//        if ($result){
+//            setCollectionInfoHash($result);
+//        }
+//    }
+
+    //判断是否已经抢购开始
+    function checkSellTime($id){
+        $sell_time = Db::name($this->table)->where('id',$id)->value('sell_time');
+        $advance_minutes = getAdvanceMinutes();
+        if ($advance_minutes>0){
+            $sell_time = strtotime($sell_time)-($advance_minutes*60);
+        }else{
+            $sell_time = strtotime($sell_time);
+        }
+        if ($sell_time<=time()) return false;
+        return true;
+    }
+
+
+    public function send(){
+        if($this->request->post()){
+            $data = $this->request->post();
+            if (!isset($data['mid']) || $data['mid']==''){
+                $this->error('请选择用户');
+            }
+            $inventory = Db::name($this->table)->where('id',$data['id'])->value('inventory');
+            $info = Db::name($this->table)->where('id',$data['id'])->find();
+
+            $zhuzao_count = Db::name('hash')
+                ->where('goods_id',$data['id'])
+                ->where('success',1)
+                ->where('status',0)
+                ->count();
+            if ($zhuzao_count<$data['number']){
+                $this->error('铸造的的数量不足,无法赠送');
+            }
+
+            $com = true;
+            Db::startTrans();
+            try {
+                $array = [];
+                for ($i=0;$i<$data['number'];$i++){
+                    //获取排名
+                    $rank = getRanking($data['id'])+1;
+                    $tag = getTag($data['id'],$rank,$inventory);
+                    saveRanking($data['id']);
+                    $company = '象寻数字科技(上海)有限公司';
+                    $hash = getCompanyHash($data['id']);
+                    $company_hash = $hash['hash'];
+                    $ddcid = Db::name('hash')->where('hash',$hash['hash'])->value('ddcid');
+                    $company_hash_time = $hash['create_at'] ? $hash['create_at'] : date('Y-m-d H:i:s');
+                    Db::name('hash')->where('hash',$hash['hash'])->update(['status'=>1]);
+                    $collectors_hash = '';
+                    $date = [
+                        'order_no'=>get_order_sn(),
+                        'tag'=>$tag,
+                        'mid'=>$data['mid'],
+                        'c_id'=>$data['id'],
+                        'pro_info'=>json_encode($info,true),
+                        'company'=>$company,
+                        'company_hash'=>$company_hash,
+                        'company_hash_time'=>$company_hash_time,
+                        'ddcid'=>$ddcid,
+                        'collectors_hash'=>$collectors_hash,
+                        'collectors_hash_time'=>''
+                    ];
+                    $array[] = $date;
+                }
+                Db::name('store_order_info')->insertAll($array);
+
+                //减少数据库库存
+                Db::name($this->table)->where('id',$data['id'])->setDec('now_inventory',$data['number']);
+
+                Db::commit();
+            } catch (\Exception $e){
+                Db::rollback();
+                $com = false;
+            }
+            if ($com){
+                //减掉库存
+                loseCollectionInventory($data['id'],$data['number']);
+                $this->success('赠送成功');
+            }else{
+                $this->error('赠送失败');
+            }
+        }else{
+
+            $id=$this->request->get('id');
+            $this->assign('id',$id);
+            $user = Db::name('store_member')->where('is_deleted',0)->field('id,name,phone')->where('is_auth',1)->select();
+            $this->assign('user',$user);
+            $this->fetch();
+
+        }
+    }
+
+
+    public function hash(){
+
+        if($this->request->post()){
+            $id = $this->request->post('id');
+            $number = $this->request->post('number');
+
+            if ($number<=0){
+                $this->error('数量错误');
+            }
+            if (Db::name('store_collection')->where('id',$id)->setInc('casting_num',$number)){
+                $redis = new Redis();
+                $redis->Incrby('castingHash_'.$id,$number);
+                $this->success('增加成功,正在铸造中');
+            }
+            $this->error('增加失败,请稍后重试');
+
+
+
+
+
+
+
+
+
+            Db::name('store_collection')->where('id',$id)->setInc('casting_num',$number);
+            $goods=Db::table('store_collection')->where('id',$this->request->post('id'))->find();
+
+            if($number){
+
+                $url2='http://192.144.219.204:8083/ddc/getNonce';
+                $nonce=$this->curlRequest($url2);
+                $result=json_decode($nonce,true);
+                if(isset($result['code'])){
+                    $this->error($result['msg']);
+                }
+                for ($i=1;$i<=$number;$i++){
+                    $address='0x8583c53ca3759f0893cb6c156b682e8fef22ed95';
+                    $str=$goods['id'].'-'.rand(1000000,9999999);
+                  //  $url='http://192.144.219.204:8083/ddc/createHash?address='.$address.'&ddcURI='.$str;
+                    $nonce = $nonce + 1;
+                    $url='http://192.144.219.204:8083/ddc/createHash?address='.$address.'&ddcURI='.$str.'&nonce='.$nonce;
+                    $res=$this->curlRequest($url);
+                    $result=json_decode($res,true);
+                    if($result['code']){
+                        $this->error($result['msg']);
+                    }
+                    $data['goods_id']=$id;
+                    $data['hash']=$res;
+                    $data['status']=0;
+                    $redis = new Redis();
+
+                    if (Db::table('hash')->insert($data)){
+                        //存入reids list
+                        $redis_data = ['hash'=>$res,'create_at'=>date('Y-m-d H:i:s')];
+                        $redis->rPush('collectionHash_'.$id,json_encode($redis_data));
+                    }
+
+                }
+            }else{
+                $this->error('请填写正确的铸造数量');
+            }
+
+            $this->success('铸造成功',url('/#/store/goods/index'));
+
+
+        }else{
+
+            $id=$this->request->get('id');
+            $this->assign('id',$id);
+            $this->fetch();
+
+        }
+
+    }
+
+
+    public function detail(){
+        $id=$this->request->get('id');
+        $this->title = Db::name($this->table)->where('id',$id)->value('name').'--铸造明细';
+        $query = $this->_query('hash')->where('goods_id',$id)->where('success',1);
+        $query->dateBetween('create_at')->order('id desc')->page();
+        $this->fetch();
+    }
+
+
+    public function curlRequest($url, $headers = [], $body = [], $method = "GET")
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//设置请求头
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);//设置请求体
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //定义请求类型
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HTTP_VERSION, 'CURL_HTTP_VERSION_1_1');
+        $output = curl_exec($ch);
+        curl_close($ch);
+
+        return $output;
+    }
+
+
+}

+ 161 - 0
application/store/controller/IntegralGoods.php

@@ -0,0 +1,161 @@
+<?php
+namespace app\store\controller;
+use library\Controller;
+use think\Db;
+
+/**
+ * 积分商品
+ * Class Goods
+ * @package app\store\controller
+ */
+class IntegralGoods extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'ExchangeGoods';
+
+    /**
+     * 商品列表
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        $this->title = '商品管理';
+        $query = $this->_query($this->table)->where('is_deleted',0)->like('name');
+        $query->dateBetween('create_at')->order('sort desc , id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+        foreach ($data as $k=>&$v){
+
+        }
+    }
+
+
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加商品';
+        // 分类
+        $goods_cate = Db::table('store_goods_cate')
+            ->field('id,title')
+            ->where(['is_deleted'=>0,'status'=>1,'pid'=>0])
+            ->order('sort desc ,id desc')
+            ->select();
+        $this->goods_cate =  $goods_cate;
+        $this->_form($this->table, 'form');
+    }
+
+
+    /**
+     * 编辑商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    function edit()
+    {
+        $this->title = '编辑商品';
+        // 分类
+        $goods_cate = Db::table('store_goods_cate')
+            ->field('id,title')
+            ->where(['is_deleted'=>0,'status'=>1,'pid'=>0])
+            ->order('sort desc ,id desc')
+            ->select();
+        $this->goods_cate =  $goods_cate;
+        $this->all_temp = Db::table('freight_template')
+            ->field('id,name')->where(['status'=>1,'is_deleted'=>0])
+            ->order('sort desc ,id desc')->select();
+        $this->_form($this->table, 'form');
+    }
+
+
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品上架
+     */
+    public function up()
+    {
+        $this->_save($this->table, ['status' => '1']);
+    }
+
+     /**
+     * @auth true
+     * @menu true
+     * 商品下架
+     */
+    public function down()
+    {
+        $this->_save($this->table, ['status' => '0']);
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品下架
+     */
+    public function del()
+    {
+        $this->_save($this->table, ['is_deleted' => '1']);
+    }
+
+
+
+
+
+
+
+
+
+
+}

+ 97 - 0
application/store/controller/Message.php

@@ -0,0 +1,97 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller;
+
+use library\Controller;
+
+/**
+ * 系统消息管理
+ * Class CategoryLabel
+ * @package app\store\controller
+ */
+class Message extends Controller
+{
+    
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'store_message';
+
+    /**
+     * 系统消息
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        $this->title = '系统消息';
+        $query = $this->_query($this->table)->like('title,content');
+        $query->where('is_deleted',0)->order('id desc')->page();
+    }
+
+
+    /**
+     * 添加消息
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->create_at = date('Y-m-d H:i:s');
+        $this->_form($this->table, 'form');
+    }
+
+
+    /**
+     * 编辑消息
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function edit()
+    {
+        $this->_form($this->table, 'form');
+    }
+
+
+
+    /**
+     * 删除消息
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function del()
+    {
+        $this->_save($this->table, ['is_deleted' => '1']);
+    }
+
+
+}

+ 38 - 0
application/store/controller/api/Data.php

@@ -0,0 +1,38 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api;
+
+use library\Controller;
+
+/**
+ * 数据商城基础数据
+ * Class Data
+ * @package app\store\controller\api
+ */
+class Data extends Controller
+{
+    /**
+     * 获取轮播图片数据
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function getSlider()
+    {
+        $this->keys = input('keys', 'slider_home');
+        $this->success('获取轮播图片数据!', sysdata($this->keys));
+    }
+
+}

+ 38 - 0
application/store/controller/api/Express.php

@@ -0,0 +1,38 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api;
+
+use library\Controller;
+
+/**
+ * 快递查询接口
+ * Class Express
+ * @package app\store\controller\api
+ */
+class Express extends Controller
+{
+    /**
+     * 物流查询结果
+     */
+    public function query()
+    {
+        $this->expressNo = input('express_no', '');
+        $this->expressCode = input('express_code', '');
+        $result = \library\tools\Express::query($this->expressCode, $this->expressNo);
+        $this->success('获取物流查询结果!', $result);
+    }
+
+}

+ 122 - 0
application/store/controller/api/Goods.php

@@ -0,0 +1,122 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api;
+
+use library\Controller;
+use think\Db;
+
+/**
+ * 商品管理接口
+ * Class Goods
+ * @package app\store\controller\api
+ */
+class Goods extends Controller
+{
+
+    /**
+     * 获取商品列表
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function gets()
+    {
+        $where = [['status', 'eq', '1'], ['is_deleted', 'eq', '0']];
+        $this->success('获取商品列表成功!', ['list' => $this->_getGoodsList($where)]);
+    }
+
+    /**
+     * 获取礼包商品列表
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function vips()
+    {
+        $where = [['status', 'eq', '1'], ['is_deleted', 'eq', '0']];
+        $this->success('获取礼包列表成功!', ['list' => $this->_getGoodsList($where)]);
+    }
+
+    /**
+     * 获取商品列表
+     * @param array $where
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    private function _getGoodsList($where = [])
+    {
+        if ($this->request->has('title', 'post', true)) {
+            $where[] = ['title', 'like', "%{$this->request->post('title')}%"];
+        }
+        if ($this->request->has('cate_id', 'post', true)) {
+            $where[] = ['cate_id', 'eq', $this->request->post('cate_id')];
+        }
+        $field = 'id,title,logo,cate_id,image,number_sales,number_stock,content,specs,lists';
+        $list = Db::name('StoreGoods')->field($field)->where($where)->order('sort desc,id desc')->select();
+        $goodsList = Db::name('StoreGoodsList')->whereIn('goods_id', array_unique(array_column($list, 'id')))->select();
+        foreach ($list as &$vo) {
+            $vo['list'] = [];
+            $vo['image'] = explode('|', $vo['image']);
+            $vo['specs'] = json_decode($vo['specs'], true);
+            $vo['lists'] = json_decode($vo['lists'], true);
+            foreach ($goodsList as $goods) if ($goods['goods_id'] === $vo['id']) {
+                array_push($vo['list'], $goods);
+            }
+        }
+        return $list;
+    }
+
+    /**
+     * 获取单个商品信息
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function get()
+    {
+        $goods_id = input('goods_id');
+        $where = ['is_deleted' => '0', 'status' => '1', 'id' => $goods_id];
+        $field = 'id,title,logo,cate_id,image,number_sales,number_stock,content,specs,lists';
+        $goods = Db::name('StoreGoods')->field($field)->where($where)->find();
+        if (empty($goods)) $this->error('指定商品不存在,请更换商品ID重试!');
+        $goods['image'] = explode('|', $goods['image']);
+        $goods['specs'] = json_decode($goods['specs'], true);
+        $goods['lists'] = json_decode($goods['lists'], true);
+        $goods['list'] = Db::name('StoreGoodsList')->where(['goods_id' => $goods_id])->select();
+        if (empty($goods['list'])) {
+            $this->error('指定商品规格不存在,请更换商品ID重试!');
+        } else {
+            $this->success('获取商品信息成功!', $goods);
+        }
+    }
+
+    /**
+     * 获取商品分类信息
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function cate()
+    {
+        $where = ['is_deleted' => '0', 'status' => '1'];
+        $field = 'id cate_id,logo cate_logo,title cate_title';
+        $list = Db::name('StoreGoodsCate')->field($field)->where($where)->order('sort desc,id desc')->select();
+        $this->success('获取商品分类成功!', ['list' => $list]);
+    }
+
+}

+ 80 - 0
application/store/controller/api/Member.php

@@ -0,0 +1,80 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api;
+
+use library\Controller;
+use think\Db;
+
+/**
+ * 会员管理基类
+ * Class Member
+ * @package app\store\controller\api
+ */
+class Member extends Controller
+{
+    /**
+     * 当前会员ID
+     * @var integer
+     */
+    protected $mid;
+
+    /**
+     * 当前会员数据
+     * @var array
+     */
+    protected $member;
+
+    /**
+     * 当前公众号OPENID
+     * @var string
+     */
+    protected $openid;
+
+    /**
+     * Member constructor.
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        // 会员信息检查
+        $this->mid = $this->request->post('mid');
+        $this->openid = $this->request->post('openid');
+        if (empty($this->mid)) $this->error('无效的会员ID参数!');
+        if (empty($this->openid)) $this->error('无效的会员绑定OPENID!');
+        $this->getMember();
+    }
+
+    /**
+     * 获取会员信息
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function getMember()
+    {
+        $where = ['id' => $this->mid, 'openid' => $this->openid];
+        $this->member = Db::name('StoreMember')->where($where)->find();
+        if (empty($this->member)) $this->error('无效的会员信息,请重新登录授权!');
+        // 会员当前已经领取次数
+        $where = [['mid', 'eq', $this->mid], ['status', 'in', ['2', '3', '4', '5']]];
+        $this->member['times_used'] = Db::name('StoreOrder')->where($where)->count();
+        return $this->member;
+    }
+
+}

+ 74 - 0
application/store/controller/api/Notify.php

@@ -0,0 +1,74 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api;
+
+use app\store\service\OrderService;
+use think\Db;
+
+/**
+ * 支付通知处理
+ * Class Notify
+ * @package app\store\controller\api
+ */
+class Notify
+{
+    /**
+     * 微信支付通知处理
+     * @return string
+     * @throws \WeChat\Exceptions\InvalidResponseException
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function wxpay()
+    {
+        $wechat = \We::WePayOrder(config('wechat.miniapp'));
+        $notify = $wechat->getNotify();
+        if ($notify['result_code'] == 'SUCCESS' && $notify['return_code'] == 'SUCCESS') {
+            if ($this->update($notify['out_trade_no'], $notify['transaction_id'], $notify['cash_fee'] / 100, 'wechat')) {
+                return $wechat->getNotifySuccessReply();
+            }
+        } else {
+            return $wechat->getNotifySuccessReply();
+        }
+    }
+
+    /**
+     * 订单状态更新
+     * @param string $order_no 订单号
+     * @param string $pay_no 交易号
+     * @param string $pay_price 交易金额
+     * @param string $type 支付类型
+     * @return boolean
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    private function update($order_no, $pay_no, $pay_price, $type = 'wechat')
+    {
+        // 检查订单支付状态
+        $where = ['order_no' => $order_no, 'pay_state' => '0', 'status' => '2'];
+        $order = Db::name('StoreOrder')->where($where)->find();
+        if (empty($order)) return false;
+        // 更新订单支付状态
+        $result = Db::name('StoreOrder')->where($where)->update([
+            'pay_type'  => $type, 'pay_no' => $pay_no, 'status' => '3',
+            'pay_price' => $pay_price, 'pay_state' => '1', 'pay_at' => date('Y-m-d H:i:s'),
+        ]);
+        // 调用会员升级机制
+        OrderService::update($order['order_no']);
+        return $result !== false;
+    }
+
+}

+ 92 - 0
application/store/controller/api/Wechat.php

@@ -0,0 +1,92 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api;
+
+use library\Controller;
+use think\Db;
+use think\exception\HttpResponseException;
+
+/**
+ * Class Wechat
+ * @package app\store\controller\api
+ */
+class Wechat extends Controller
+{
+    /**
+     * 获取小程序配置
+     * @return array
+     */
+    private function config()
+    {
+        return config('wechat.miniapp');
+    }
+
+    /**
+     * Code信息换取
+     */
+    public function session()
+    {
+        try {
+            $code = $this->request->post('code');
+            $result = \We::WeMiniCrypt($this->config())->session($code);
+            if (isset($result['openid'])) {
+                data_save('StoreMember', ['openid' => $result['openid']], 'openid');
+                $result['member'] = Db::name('StoreMember')->where(['openid' => $result['openid']])->find();
+                $this->success('授权CODE信息换取成功!', $result);
+            } else {
+                $this->error("[{$result['errcode']}] {$result['errmsg']}");
+            }
+        } catch (HttpResponseException $exception) {
+            throw $exception;
+        } catch (\Exception $exception) {
+            $this->error("授权CODE信息换取失败,{$exception->getMessage()}");
+        }
+    }
+
+    /**
+     * 小程序数据解密
+     */
+    public function decode()
+    {
+        try {
+            $iv = $this->request->post('iv');
+            $session = $this->request->post('session');
+            $content = $this->request->post('encrypted');
+            if (empty($session)) {
+                $code = $this->request->post('code');
+                $result = \We::WeMiniCrypt($this->config())->session($code);
+                $session = isset($result['session_key']) ? $result['session_key'] : '';
+            }
+            $result = \We::WeMiniCrypt($this->config())->decode($iv, $session, $content);
+            if ($result !== false && isset($result['openId'])) {
+                data_save('StoreMember', [
+                    'openid'   => $result['openId'],
+                    'headimg'  => $result['avatarUrl'],
+                    'nickname' => $result['nickName'],
+                ], 'openid');
+                $result['member'] = Db::name('StoreMember')->where(['openid' => $result['openId']])->find();
+                $this->success('小程序加密数据解密成功!', $result);
+            } else {
+                $this->error('小程序加密数据解密失败,请稍候再试!');
+            }
+        } catch (HttpResponseException $exception) {
+            throw $exception;
+        } catch (\Exception $e) {
+            $this->error("小程序加密数据解密失败,{$e->getMessage()}");
+        }
+    }
+
+}

+ 128 - 0
application/store/controller/api/member/Address.php

@@ -0,0 +1,128 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api\member;
+
+use app\store\controller\api\Member;
+use think\Db;
+
+/**
+ * 会员收货地址管理
+ * Class Address
+ * @package app\store\controller\api\member
+ */
+class Address extends Member
+{
+
+    /**
+     * 获取会员收货地址信息
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function gets()
+    {
+        $this->success('获取会员收货地址成功!', [
+            'list' => Db::name('StoreMemberAddress')
+                ->where(['mid' => $this->member['id']])
+                ->order('is_default desc,id desc')
+                ->select(),
+        ]);
+    }
+
+    /**
+     * 更新收货地址
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function set()
+    {
+        $data = $this->_input([
+            'mid'        => $this->request->post('mid'),
+            'openid'     => $this->request->post('openid'),
+            'name'       => $this->request->post('name'),
+            'phone'      => $this->request->post('phone'),
+            'province'   => $this->request->post('province'),
+            'city'       => $this->request->post('city'),
+            'area'       => $this->request->post('area'),
+            'address'    => $this->request->post('address'),
+            'is_default' => $this->request->post('is_default'),
+        ], [
+            'name'     => 'require',
+            'phone'    => 'require|mobile',
+            'province' => 'require',
+            'city'     => 'require',
+            'area'     => 'require',
+            'address'  => 'require',
+        ], [
+            'name.require'     => '收货人姓名不能为空!',
+            'phone.require'    => '收货人联系手机不能为空!',
+            'phone.mobile'     => '收货人联系手机格式不对!',
+            'province.require' => '收货地址省份不能为空!',
+            'city.require'     => '收货地址城市不能为空!',
+            'area.require'     => '收货地址区域不能为空!',
+            'address.require'  => '收货详情地址不能为空!',
+        ]);
+        if (!empty($data['is_default'])) {
+            Db::name('StoreMemberAddress')->where(['mid' => $this->member['id']])->setField('is_default', '0');
+        }
+        if ($this->request->has('id', 'post', true)) {
+            $data['id'] = $this->request->post('id');
+        }
+        if (data_save('StoreMemberAddress', $data, 'id')) {
+            $this->success('收货地址更新成功!');
+        }
+        $this->error('收货地址更新失败,请稍候再试!');
+    }
+
+    /**
+     * 删除收货地址
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function del()
+    {
+        $id = $this->request->post('address_id');
+        if (empty($id)) $this->error('待处理的收货地址ID不能为空!');
+        $where = ['id' => $id, 'mid' => $this->member['id']];
+        if (Db::name('StoreMemberAddress')->where($where)->delete() !== false) {
+            $this->success('删除收货地址成功!');
+        }
+        $this->error('删除收货地址失败,请稍候再试!');
+    }
+
+    /**
+     * 设置默认收货地址
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function setDefault()
+    {
+        $id = $this->request->post('address_id');
+        if (empty($id)) $this->error('待处理的收货地址ID不存在!');
+        $where = ['id' => $id, 'mid' => $this->member['id']];
+        $address = Db::name('StoreMemberAddress')->where($where)->find();
+        if (empty($address)) $this->error('待处理的收货地址获取失败,请稍候再试!');
+        Db::name('StoreMemberAddress')->where(['mid' => $this->member['id']])->update(['is_default' => '0']);
+        if (Db::name('StoreMemberAddress')->where($where)->update(['is_default' => '1']) !== false) {
+            $this->success('设置默认收货地址成功!');
+        }
+        $this->error('设置默认收货地址失败!');
+    }
+
+}

+ 122 - 0
application/store/controller/api/member/Center.php

@@ -0,0 +1,122 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api\member;
+
+use app\store\controller\api\Member;
+use app\store\service\ExtendService;
+use think\Db;
+
+/**
+ * 商品会员中心
+ * Class Center
+ * @package app\store\controller\api\member
+ */
+class Center extends Member
+{
+    /**
+     * 修改会员资料
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function info()
+    {
+        $data = [];
+        if ($this->request->has('headimg', 'post', true)) {
+            $data['headimg'] = $this->request->post('headimg');
+        }
+        if ($this->request->has('nickname', 'post', true)) {
+            $data['nickname'] = $this->request->post('nickname');
+        }
+        if ($this->request->has('username', 'post', true)) {
+            $data['username'] = $this->request->post('username');
+        }
+        if (empty($data)) $this->error('没有需要修改的数据哦!');
+        if (data_save('StoreMember', array_merge($data, ['id' => $this->mid]), 'id') !== false) {
+            $this->success('会员资料更新成功!', $this->getMember());
+        } else {
+            $this->error('会员资料更新失败,请稍候再试!');
+        }
+    }
+
+    /**
+     * 发送短信验证码
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function sendsms()
+    {
+        $phone = $this->request->post('phone');
+        if ($this->request->post('secure') !== sysconf('sms_secure')) {
+            $this->error('短信发送安全码不正确,请使用正确的安全码!');
+        }
+        $member = Db::name('StoreMember')->where(['phone' => $phone])->find();
+        if (!empty($member)) $this->error('该手机号已经注册了,请使用其它手机号!');
+        $cache = cache($cachekey = "send_register_sms_{$phone}");
+        if (is_array($cache) && isset($cache['time']) && $cache['time'] > time() - 120) {
+            $dtime = ($cache['time'] + 120 < time()) ? 0 : (120 - time() + $cache['time']);
+            $this->success('短信验证码已经发送!', ['time' => $dtime]);
+        }
+        list($code, $content) = [rand(1000, 9999), sysconf('sms_reg_template')];
+        if (empty($content) || stripos($content, '{code}') === false) {
+            $content = '您的验证码为{code},请在十分钟内完成操作!';
+        }
+        cache($cachekey, ['phone' => $phone, 'captcha' => $code, 'time' => time()], 600);
+        if (empty($content) || strpos($content, '{code}') === false) {
+            $this->error('获取短信模板失败,联系管理员配置!');
+        }
+        $cache = cache($cachekey);
+        if (ExtendService::sendChinaSms($this->mid, $phone, str_replace('{code}', $code, $content))) {
+            $dtime = ($cache['time'] + 120 < time()) ? 0 : (120 - time() + $cache['time']);
+            $this->success('短信验证码发送成功!', ['time' => $dtime]);
+        } else {
+            $this->error('短信发送失败,请稍候再试!');
+        }
+    }
+
+    /**
+     * 会员登录绑定
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function bind()
+    {
+        $code = $this->request->post('code');
+        $phone = $this->request->post('phone');
+        $cache = cache($cachekey = "send_register_sms_{$phone}");
+        if (is_array($cache) && isset($cache['captcha']) && $cache['captcha'] == $code) {
+            $where = ['id' => $this->member['id']];
+            if (Db::name('StoreMember')->where($where)->update(['phone' => $phone]) !== false) {
+                $this->success('手机绑定登录成功!');
+            } else {
+                $this->error('手机绑定登录失败,请稍候再试!');
+            }
+        } else {
+            $this->error('短信验证码验证失败!');
+        }
+    }
+
+    /**
+     * 获取会员资源成功
+     */
+    public function member()
+    {
+        $this->success('获取会员资料成功!', $this->member);
+    }
+
+}

+ 313 - 0
application/store/controller/api/member/Order.php

@@ -0,0 +1,313 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller\api\member;
+
+use app\store\controller\api\Member;
+use app\store\service\GoodsService;
+use app\store\service\OrderService;
+use library\tools\Data;
+use think\Db;
+use think\exception\HttpResponseException;
+
+/**
+ * 订单接口管理
+ * Class Order
+ * @package app\store\controller\api\member
+ */
+class Order extends Member
+{
+
+    /**
+     * 创建商城订单
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * 商品ID1@商品规格1@商品数量1||商品ID2@商品规格2@商品数量2
+     */
+    public function set()
+    {
+        // 商品规则
+        $rule = $this->request->post('rule', '');
+        if (empty($rule)) $this->error('下单商品规则不能为空!');
+        // 订单处理
+        list($orderList, $order) = [[], [
+            'status'   => '1', 'mid' => $this->mid,
+            'order_no' => Data::uniqidNumberCode(12),
+            'from_mid' => $this->request->post('from_mid', '0'),
+        ]];
+        // 推荐人处理
+        if (intval($order['from_mid']) === intval($this->mid)) {
+            $order['from_mid'] = '0';
+        } elseif ($order['from_mid'] > 0) {
+            if (Db::name('StoreMember')->where(['id' => $order['from_mid']])->count() < 1) {
+                $this->error('无效的推荐会员ID,稍候再试!');
+            }
+        }
+        foreach (explode('||', $rule) as $item) {
+            list($goods_id, $goods_spec, $number) = explode('@', $item);
+            // 商品信息检查
+            $goods = Db::name('StoreGoods')->where(['id' => $goods_id, 'status' => '1', 'is_deleted' => '0'])->find();
+            if (empty($goods)) $this->error('查询商品主体信息失败,请稍候再试!');
+            $spec = Db::name('StoreGoodsList')->where(['goods_id' => $goods_id, 'goods_spec' => $goods_spec])->find();
+            if (empty($spec)) $this->error('查询商品规则信息失败,请稍候再试!');
+            // 商品库存检查
+            if ($spec['number_sales'] + $number > $spec['number_stock']) {
+                $this->error('商品库存不足,请购买其它商品!');
+            }
+            // 订单详情处理
+            array_push($orderList, [
+                'mid'               => $order['mid'],
+                'from_mid'          => $order['from_mid'],
+                'order_no'          => $order['order_no'],
+                // 商品信息字段管理
+                'goods_id'          => $goods_id,
+                'goods_spec'        => $goods_spec,
+                'goods_logo'        => $goods['logo'],
+                'goods_title'       => $goods['title'],
+                'number_goods'      => $number,
+                'number_express'    => $spec['number_express'],
+                // 费用字段处理
+                'price_market'      => $spec['price_market'],
+                'price_selling'     => $spec['price_selling'],
+                'price_real'        => $spec['price_selling'] * $number,
+                'price_express'     => $goods['price_express'],
+                // 返利字段处理
+                'price_rate'        => $goods['price_rate'],
+                'price_rate_amount' => $spec['price_selling'] * $number * $goods['price_rate'] / 100,
+            ]);
+        }
+        $order['price_goods'] = array_sum(array_column($orderList, 'price_real')) + 0;
+        $order['price_express'] = max(array_column($orderList, 'price_express')) + 0;
+        $order['price_total'] = $order['price_goods'] + $order['price_express'];
+        $order['price_rate_amount'] = array_sum(array_column($orderList, 'price_rate_amount')) + 0;
+        try {
+            // 订单数据写入
+            Db::name('StoreOrder')->insert($order);
+            Db::name('StoreOrderList')->insertAll($orderList);
+            // 同步商品库存及销量
+            foreach (array_unique(array_column($orderList, 'goods_id')) as $goodsId) GoodsService::syncStock($goodsId);
+            $this->success('订单创建成功,请补全收货信息后支付!', ['order' => $order]);
+        } catch (HttpResponseException $exception) {
+            throw $exception;
+        } catch (\Exception $e) {
+            $this->error("创建订单失败,请稍候再试!{$e->getMessage()}");
+        }
+    }
+
+    /**
+     * 订单信息完成
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function perfect()
+    {
+        $data = $this->_input([
+            'order_no'   => $this->request->post('order_no'),
+            'address_id' => $this->request->post('address_id'),
+        ], [
+            'order_no'   => 'require',
+            'address_id' => 'require',
+        ], [
+            'order_no.require'   => '订单号不能为空!',
+            'address_id.require' => '收货地址ID不能为空(0自提可以为空)',
+        ]);
+        $map = ['order_no' => $data['order_no'], 'mid' => $this->member['id']];
+        $order = Db::name('StoreOrder')->whereIn('status', ['1', '2'])->where($map)->find();
+        if (empty($order)) $this->error('订单异常,请返回商品重新下单!');
+        $update = ['status' => '2'];
+        $where = ['id' => $data['address_id'], 'mid' => $this->member['id']];
+        $address = Db::name('StoreMemberAddress')->where($where)->find();
+        if (empty($address)) $this->error('会员收货地址异常,请刷新页面重试!');
+        $update['express_address_id'] = $data['address_id'];
+        $update['express_name'] = $address['name'];
+        $update['express_phone'] = $address['phone'];
+        $update['express_province'] = $address['province'];
+        $update['express_city'] = $address['city'];
+        $update['express_area'] = $address['area'];
+        $update['express_address'] = $address['address'];
+        if (Db::name('StoreOrder')->where($map)->update($update) !== false) {
+            $params = $this->getPayParams($order['order_no'], $order['price_total']);
+            $this->success('更新订单会员信息成功!', $params);
+        } else {
+            $this->error('更新订单会员信息失败,请稍候再试!');
+        }
+    }
+
+    /**
+     * 获取订单支付状态
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function pay()
+    {
+        $order_no = $this->request->post('order_no');
+        $order = Db::name('StoreOrder')->where(['order_no' => $order_no])->find();
+        if (empty($order_no)) $this->error('获取订单信息异常,请稍候再试!');
+        if ($order['pay_state']) $this->error('订单已经完成支付,不需要再次支付!');
+        if ($order['status'] <> 2) $this->error('该订单不能发起支付哦!');
+        try {
+            $param = $this->getPayParams($order['order_no'], $order['price_total']);
+            $this->success('获取订单支付参数成功!', $param);
+        } catch (HttpResponseException $exception) {
+            throw  $exception;
+        } catch (\Exception $e) {
+            $this->error("获取订单支付参数失败,{$e->getMessage()}");
+        }
+    }
+
+    /**
+     * 获取订单支付参数
+     * @param string $order_no
+     * @param string $pay_price
+     * @return array
+     */
+    private function getPayParams($order_no, $pay_price)
+    {
+        $options = [
+            'body'             => '商城订单支付',
+            'openid'           => $this->openid,
+            'out_trade_no'     => $order_no,
+            // 'total_fee'        => '1',
+            'total_fee'        => $pay_price * 100,
+            'trade_type'       => 'JSAPI',
+            'notify_url'       => url('@store/api.notify/wxpay', '', false, true),
+            'spbill_create_ip' => $this->request->ip(),
+        ];
+        try {
+            $pay = \We::WePayOrder(config('wechat.miniapp'));
+            $info = $pay->create($options);
+            if ($info['return_code'] === 'SUCCESS' && $info['result_code'] === 'SUCCESS') {
+                return $pay->jsapiParams($info['prepay_id']);
+            }
+            if (isset($info['err_code_des'])) {
+                throw new \think\Exception($info['err_code_des']);
+            }
+        } catch (\Exception $e) {
+            $this->error("创建订单失败参数失败,{$e->getMessage()}");
+        }
+    }
+
+    /**
+     * 获取订单列表
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function gets()
+    {
+        $where = [['mid', 'eq', $this->mid]];
+        if ($this->request->has('order_no', 'post', true)) {
+            $where[] = ['order_no', 'eq', $this->request->post('order_no')];
+        } else {
+            $where[] = ['status', 'in', ['0', '2', '3', '4', '5']];
+        }
+        if ($this->request->has('status', 'post', true)) {
+            $where[] = ['status', 'eq', $this->request->post('status')];
+        }
+        $result = $this->_query('StoreOrder')->where($where)->order('id desc')->page(true, false, false, 20);
+        $glist = Db::name('StoreOrderList')->whereIn('order_no', array_unique(array_column($result['list'], 'order_no')))->select();
+        foreach ($result['list'] as &$vo) {
+            list($vo['goods_count'], $vo['list']) = [0, []];
+            foreach ($glist as $goods) if ($vo['order_no'] === $goods['order_no']) {
+                $vo['list'][] = $goods;
+                $vo['goods_count'] += $goods['number_goods'];
+            }
+        }
+        $this->success('获取订单列表成功!', $result);
+    }
+
+    /**
+     * 订单取消
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function cancel()
+    {
+        $where = [
+            'mid'      => $this->member['id'],
+            'order_no' => $this->request->post('order_no'),
+        ];
+        $order = Db::name('StoreOrder')->where($where)->find();
+        if (empty($order)) $this->error('待取消的订单不存在,请稍候再试!');
+        if (in_array($order['status'], ['1', '2'])) {
+            $result = Db::name('StoreOrder')->where($where)->update([
+                'status'       => '0',
+                'cancel_state' => '1',
+                'cancel_at'    => date('Y-m-d H:i:s'),
+                'cancel_desc'  => '用户主动取消订单!',
+            ]);
+            if ($result !== false && OrderService::syncStock($order['order_no'])) {
+                $this->success('订单取消成功!');
+            } else {
+                $this->error('订单取消失败,请稍候再试!');
+            }
+        } else {
+            $this->error('该订单状态不允许取消哦~');
+        }
+    }
+
+    /**
+     * 订单确认收货
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function confirm()
+    {
+        $where = [
+            'mid'      => $this->member['id'],
+            'order_no' => $this->request->post('order_no'),
+        ];
+        $order = Db::name('StoreOrder')->where($where)->find();
+        if (empty($order)) $this->error('待确认的订单不存在,请稍候再试!');
+        if (in_array($order['status'], ['4'])) {
+            if (Db::name('StoreOrder')->where($where)->update(['status' => '5']) !== false) {
+                $this->success('订单确认成功!');
+            } else {
+                $this->error('订单取确认失败,请稍候再试!');
+            }
+        } else {
+            $this->error('该订单状态不允许确认哦~');
+        }
+    }
+
+    /**
+     * 订单状态统计
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function total()
+    {
+        $result = Db::name('StoreOrder')
+            ->fieldRaw('mid,status,count(1) count')
+            ->where(['mid' => $this->mid])
+            ->group('status')
+            ->select();
+        $this->success('获取订单统计记录!', $result);
+    }
+}

+ 84 - 0
application/store/service/ExpressService.php

@@ -0,0 +1,84 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\service;
+
+use think\Db;
+
+/**
+ * 商城邮费服务
+ * Class ExpressService
+ * @package app\store\service
+ */
+class ExpressService
+{
+
+    /**
+     * 订单邮费计算
+     * @param string $province 配送省份
+     * @param string $number 计费数量
+     * @param string $amount 订单金额
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public static function price($province, $number, $amount)
+    {
+        // 读取对应的模板规则
+        $map = [['is_default', 'eq', '0'], ['rule', 'like', "%{$province}%"]];
+        $rule = Db::name('StoreExpressTemplate')->where($map)->find();
+        if (!empty($rule)) return self::buildData($rule, '普通模板', $number, $amount);
+        $rule = Db::name('StoreExpressTemplate')->where(['is_default' => '1'])->find();
+        return self::buildData($rule, '默认模板', $number, $amount);
+    }
+
+    /**
+     * 生成邮费数据
+     * @param array $rule 模板规则
+     * @param string $type 模板类型
+     * @param integer $number 计费件数
+     * @param double $amount 订单金额
+     * @return array
+     */
+    protected static function buildData($rule, $type, $number, $amount)
+    {
+        // 异常规则
+        if (empty($rule)) return [
+            'express_price' => 0.00, 'express_type' => '未知模板', 'express_desc' => '未匹配到邮费模板',
+        ];
+        // 满减免邮
+        if ($rule['order_reduction_state'] && $amount >= $rule['order_reduction_price']) {
+            return [
+                'express_price' => 0.00, 'express_type' => $type,
+                'express_desc'  => "订单总金额满{$rule['order_reduction_price']}元减免全部邮费",
+            ];
+        }
+        // 首重计费
+        if ($number <= $rule['first_number']) return [
+            'express_price' => $rule['first_price'], 'express_type' => $type,
+            'express_desc'  => "首件计费,{$rule['first_number']}件及{$rule['first_number']}以内计费{$rule['first_price']}元",
+        ];
+        // 续重计费
+        list($price1, $price2) = [$rule['first_price'], 0];
+        if ($rule['next_number'] > 0 && $rule['next_price'] > 0) {
+            $price2 = $rule['next_price'] * ceil(($number - $rule['first_number']) / $rule['next_number']);
+        }
+        return [
+            'express_price' => $price1 + $price2, 'express_type' => $type,
+            'express_desc'  => "续件计费,超出{$rule['first_number']}件,首件费用{$rule['first_price']}元 + 续件费用{$price2}元",
+        ];
+    }
+}

+ 423 - 0
application/store/service/ExtendService.php

@@ -0,0 +1,423 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\service;
+
+use library\tools\Http;
+use think\Db;
+
+/**
+ * 短信业务扩展服务
+ * Class ExtendService
+ * @package app\store\service
+ * =================================
+ * =================================
+ * 发送国内短信需要给产品码 [productid]
+ * --- 验证短信的产品码为:676767
+ * --- 营销短信的产品码为:333333
+ * ---------------------------------
+ * ---------------------------------
+ * 发送国际短信需要给国家代码 [code]
+ * --- 国家代码见 getGlobeRegionMap
+ * ---------------------------------
+ * ---------------------------------
+ * 需要开通短信账号请联系客服
+ * --- 客服电话:18122377655
+ * =================================
+ */
+class ExtendService
+{
+
+    /**
+     * 发送国内短信验证码
+     * @param string $mid 会员ID
+     * @param string $phone 手机号
+     * @param string $content 短信内容
+     * @param string $productid 短信通道ID
+     * @return boolean
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public static function sendChinaSms($mid, $phone, $content, $productid = '676767')
+    {
+        $tkey = date("YmdHis");
+        $result = Http::post('http://www.ztsms.cn/sendNSms.do', [
+            'tkey'     => $tkey, 'mobile' => $phone, 'content' => $content,
+            'username' => sysconf('sms_zt_username'), 'productid' => $productid,
+            'password' => md5(md5(sysconf('sms_zt_password')) . $tkey),
+        ]);
+        list($code, $msg) = explode(',', $result . ',');
+        Db::name('StoreMemberSmsHistory')->insert([
+            'mid' => $mid, 'phone' => $phone, 'content' => $content, 'result' => $result
+        ]);
+        return intval($code) === 1;
+    }
+
+    /**
+     * 发送国内短信验证码
+     * @param string $mid 会员ID
+     * @param string $phone 目标手机
+     * @param integer $wait 等待时间
+     * @param string $type 短信模板
+     * @return array
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public static function sendChinaSmsByCode($mid, $phone, $wait = 120, $type = 'sms_reg_template')
+    {
+        $cache = cache($ckey = "{$type}_{$phone}");
+        if (is_array($cache) && isset($cache['time']) && $cache['time'] > time() - $wait) {
+            $dtime = ($cache['time'] + $wait < time()) ? 0 : ($wait - time() + $cache['time']);
+            return [1, '短信验证码已经发送!', ['time' => $dtime]];
+        }
+        list($code, $content) = [rand(1000, 9999), sysconf($type)];
+        if (empty($content) || stripos($content, '{code}') === false) {
+            $content = '您的验证码为{code},请在十分钟内完成操作!';
+        }
+        cache($ckey, $cache = ['phone' => $phone, 'code' => $code, 'time' => time()], 600);
+        if (self::sendChinaSms($mid, $phone, str_replace('{code}', $code, $content))) {
+            $dtime = ($cache['time'] + $wait < time()) ? 0 : ($wait - time() + $cache['time']);
+            return [1, '短信验证码发送成功!', ['time' => $dtime]];
+        } else {
+            return [0, '短信发送失败,请稍候再试!', []];
+        }
+    }
+
+    /**
+     * 验证手机短信验证码
+     * @param string $phone 目标手机
+     * @param string $code 短信验证码
+     * @param string $type 短信模板
+     * @return boolean
+     */
+    public static function checkChinaSmsByCode($phone, $code, $type = 'sms_reg_template')
+    {
+        $cache = cache($cachekey = "{$type}_{$phone}");
+        return is_array($cache) && isset($cache['code']) && $cache['code'] == $code;
+    }
+
+    /**
+     * 查询国内短信余额
+     * @return array
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public static function queryChinaSmsBalance()
+    {
+        $tkey = date("YmdHis");
+        $result = Http::post('http://www.ztsms.cn/balanceN.do', [
+            'username' => sysconf('sms_zt_username'), 'tkey' => $tkey,
+            'password' => md5(md5(sysconf('sms_zt_password')) . $tkey),
+        ]);
+        if ($result > -1) {
+            return ['code' => 1, 'num' => $result, 'msg' => '获取短信剩余条数成功!'];
+        } elseif ($result > -2) {
+            return ['code' => 0, 'num' => '0', 'msg' => '用户名或者密码不正确!'];
+        } elseif ($result > -3) {
+            return ['code' => 0, 'num' => '0', 'msg' => 'tkey不正确!'];
+        } elseif ($result > -4) {
+            return ['code' => 0, 'num' => '0', 'msg' => '用户不存在或用户停用!'];
+        }
+    }
+
+    /**
+     * 错误消息处理
+     * @var array
+     */
+    private static $globeMessageMap = [
+        2  => '用户账号为空',
+        3  => '用户账号错误',
+        4  => '授权密码为空',
+        5  => '授权密码错误',
+        6  => '当前时间为空',
+        7  => '当前时间错误',
+        8  => '用户类型错误',
+        9  => '用户鉴权错误',
+        10 => '请求IP已被列入黑名单',
+    ];
+
+    /**
+     * 发送国际短信内容
+     * @param string $mid 会员编号
+     * @param string $code 国家代码
+     * @param string $mobile 手机号码
+     * @param string $content 发送内容
+     * @return boolean
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public static function sendGlobeSms($mid, $code, $mobile, $content)
+    {
+        $tkey = date("YmdHis");
+        $result = Http::post('http://intl.zthysms.com/intSendSms.do', [
+            'tkey'     => $tkey, 'code' => $code, 'mobile' => $mobile,
+            'content'  => $content, 'username' => sysconf('sms_zt_username2'),
+            'password' => md5(md5(sysconf('sms_zt_password2')) . $tkey),
+        ]);
+        Db::name('StoreMemberSmsHistory')->insert([
+            'mid' => $mid, 'region' => $code, 'phone' => $mobile, 'content' => $content, 'result' => $result,
+        ]);
+        return intval($result) === 1;
+    }
+
+    /**
+     * 查询国际短信余额
+     * @return array
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public static function queryGlobeSmsBalance()
+    {
+        $tkey = date("YmdHis");
+        $result = Http::post('http://intl.zthysms.com/intBalance.do', [
+            'username' => sysconf('sms_zt_username2'), 'tkey' => $tkey,
+            'password' => md5(md5(sysconf('sms_zt_password2')) . $tkey),
+        ]);
+        if (!is_numeric($result) && ($state = intval($result)) && isset(self::$globeMessageMap[$state])) {
+            return ['code' => 0, 'num' => 0, 'msg' => self::$globeMessageMap[$state]];
+        } else {
+            return ['code' => 1, 'num' => $result, 'msg' => '查询成功'];
+        }
+    }
+
+    /**
+     * 获取国际地域编号
+     * @return array
+     */
+    public static function getGlobeRegionMap()
+    {
+        return [
+            ['title' => '中国 台湾', 'english' => 'Taiwan', 'code' => 886],
+            ['title' => '东帝汶民主共和国', 'english' => 'DEMOCRATIC REPUBLIC OF TIMORLESTE', 'code' => 670],
+            ['title' => '中非共和国', 'english' => 'Central African Republic', 'code' => 236],
+            ['title' => '丹麦', 'english' => 'Denmark', 'code' => 45],
+            ['title' => '乌克兰', 'english' => 'Ukraine', 'code' => 380],
+            ['title' => '乌兹别克斯坦', 'english' => 'Uzbekistan', 'code' => 998],
+            ['title' => '乌干达', 'english' => 'Uganda', 'code' => 256],
+            ['title' => '乌拉圭', 'english' => 'Uruguay', 'code' => 598],
+            ['title' => '乍得', 'english' => 'Chad', 'code' => 235],
+            ['title' => '也门', 'english' => 'Yemen', 'code' => 967],
+            ['title' => '亚美尼亚', 'english' => 'Armenia', 'code' => 374],
+            ['title' => '以色列', 'english' => 'Israel', 'code' => 972],
+            ['title' => '伊拉克', 'english' => 'Iraq', 'code' => 964],
+            ['title' => '伊朗', 'english' => 'Iran', 'code' => 98],
+            ['title' => '伯利兹', 'english' => 'Belize', 'code' => 501],
+            ['title' => '佛得角', 'english' => 'Cape Verde', 'code' => 238],
+            ['title' => '俄罗斯', 'english' => 'Russia', 'code' => 7],
+            ['title' => '保加利亚', 'english' => 'Bulgaria', 'code' => 359],
+            ['title' => '克罗地亚', 'english' => 'Croatia', 'code' => 385],
+            ['title' => '关岛', 'english' => 'Guam', 'code' => 1671],
+            ['title' => '冈比亚', 'english' => 'The Gambia', 'code' => 220],
+            ['title' => '冰岛', 'english' => 'Iceland', 'code' => 354],
+            ['title' => '几内亚', 'english' => 'Guinea', 'code' => 224],
+            ['title' => '几内亚比绍', 'english' => 'Guinea - Bissau', 'code' => 245],
+            ['title' => '列支敦士登', 'english' => 'Liechtenstein', 'code' => 423],
+            ['title' => '刚果共和国', 'english' => 'The Republic of Congo', 'code' => 242],
+            ['title' => '刚果民主共和国', 'english' => 'Democratic Republic of the Congo', 'code' => 243],
+            ['title' => '利比亚', 'english' => 'Libya', 'code' => 218],
+            ['title' => '利比里亚', 'english' => 'Liberia', 'code' => 231],
+            ['title' => '加拿大', 'english' => 'Canada', 'code' => 1],
+            ['title' => '加纳', 'english' => 'Ghana', 'code' => 233],
+            ['title' => '加蓬', 'english' => 'Gabon', 'code' => 241],
+            ['title' => '匈牙利', 'english' => 'Hungary', 'code' => 36],
+            ['title' => '南非', 'english' => 'South Africa', 'code' => 27],
+            ['title' => '博茨瓦纳', 'english' => 'Botswana', 'code' => 267],
+            ['title' => '卡塔尔', 'english' => 'Qatar', 'code' => 974],
+            ['title' => '卢旺达', 'english' => 'Rwanda', 'code' => 250],
+            ['title' => '卢森堡', 'english' => 'Luxembourg', 'code' => 352],
+            ['title' => '印尼', 'english' => 'Indonesia', 'code' => 62],
+            ['title' => '印度', 'english' => 'India', 'code' => 91918919],
+            ['title' => '危地马拉', 'english' => 'Guatemala', 'code' => 502],
+            ['title' => '厄瓜多尔', 'english' => 'Ecuador', 'code' => 593],
+            ['title' => '厄立特里亚', 'english' => 'Eritrea', 'code' => 291],
+            ['title' => '叙利亚', 'english' => 'Syria', 'code' => 963],
+            ['title' => '古巴', 'english' => 'Cuba', 'code' => 53],
+            ['title' => '吉尔吉斯斯坦', 'english' => 'Kyrgyzstan', 'code' => 996],
+            ['title' => '吉布提', 'english' => 'Djibouti', 'code' => 253],
+            ['title' => '哥伦比亚', 'english' => 'Colombia', 'code' => 57],
+            ['title' => '哥斯达黎加', 'english' => 'Costa Rica', 'code' => 506],
+            ['title' => '喀麦隆', 'english' => 'Cameroon', 'code' => 237],
+            ['title' => '图瓦卢', 'english' => 'Tuvalu', 'code' => 688],
+            ['title' => '土库曼斯坦', 'english' => 'Turkmenistan', 'code' => 993],
+            ['title' => '土耳其', 'english' => 'Turkey', 'code' => 90],
+            ['title' => '圣卢西亚', 'english' => 'Saint Lucia', 'code' => 1758],
+            ['title' => '圣基茨和尼维斯', 'english' => 'Saint Kitts and Nevis', 'code' => 1869],
+            ['title' => '圣多美和普林西比', 'english' => 'Sao Tome and Principe', 'code' => 239],
+            ['title' => '圣文森特和格林纳丁斯', 'english' => 'Saint Vincent and the Grenadines', 'code' => 1784],
+            ['title' => '圣皮埃尔和密克隆群岛', 'english' => 'Saint Pierre and Miquelon', 'code' => 508],
+            ['title' => '圣赫勒拿岛', 'english' => 'Saint Helena', 'code' => 290],
+            ['title' => '圣马力诺', 'english' => 'San Marino', 'code' => 378],
+            ['title' => '圭亚那', 'english' => 'Guyana', 'code' => 592],
+            ['title' => '坦桑尼亚', 'english' => 'Tanzania', 'code' => 255],
+            ['title' => '埃及', 'english' => 'Egypt', 'code' => 20],
+            ['title' => '埃塞俄比亚', 'english' => 'Ethiopia', 'code' => 251],
+            ['title' => '基里巴斯', 'english' => 'Kiribati', 'code' => 686],
+            ['title' => '塔吉克斯坦', 'english' => 'Tajikistan', 'code' => 992],
+            ['title' => '塞内加尔', 'english' => 'Senegal', 'code' => 221],
+            ['title' => '塞尔维亚', 'english' => 'Serbia and Montenegro', 'code' => 381],
+            ['title' => '塞拉利昂', 'english' => 'Sierra Leone', 'code' => 232],
+            ['title' => '塞浦路斯', 'english' => 'Cyprus', 'code' => 357],
+            ['title' => '塞舌尔', 'english' => 'Seychelles', 'code' => 248],
+            ['title' => '墨西哥', 'english' => 'Mexico', 'code' => 52],
+            ['title' => '多哥', 'english' => 'Togo', 'code' => 228],
+            ['title' => '多米尼克', 'english' => 'Dominica', 'code' => 1767],
+            ['title' => '奥地利', 'english' => 'Austria', 'code' => 43],
+            ['title' => '委内瑞拉', 'english' => 'Venezuela', 'code' => 58],
+            ['title' => '孟加拉', 'english' => 'Bangladesh', 'code' => 880],
+            ['title' => '安哥拉', 'english' => 'Angola', 'code' => 244],
+            ['title' => '安圭拉岛', 'english' => 'Anguilla', 'code' => 1264],
+            ['title' => '安道尔', 'english' => 'Andorra', 'code' => 376],
+            ['title' => '密克罗尼西亚', 'english' => 'Federated States of Micronesia', 'code' => 691],
+            ['title' => '尼加拉瓜', 'english' => 'Nicaragua', 'code' => 505],
+            ['title' => '尼日利亚', 'english' => 'Nigeria', 'code' => 234],
+            ['title' => '尼日尔', 'english' => 'Niger', 'code' => 227],
+            ['title' => '尼泊尔', 'english' => 'Nepal', 'code' => 977],
+            ['title' => '巴勒斯坦', 'english' => 'Palestine', 'code' => 970],
+            ['title' => '巴哈马', 'english' => 'The Bahamas', 'code' => 1242],
+            ['title' => '巴基斯坦', 'english' => 'Pakistan', 'code' => 92],
+            ['title' => '巴巴多斯', 'english' => 'Barbados', 'code' => 1246],
+            ['title' => '巴布亚新几内亚', 'english' => 'Papua New Guinea', 'code' => 675],
+            ['title' => '巴拉圭', 'english' => 'Paraguay', 'code' => 595],
+            ['title' => '巴拿马', 'english' => 'Panama', 'code' => 507],
+            ['title' => '巴林', 'english' => 'Bahrain', 'code' => 973],
+            ['title' => '巴西', 'english' => 'Brazil', 'code' => 55],
+            ['title' => '布基纳法索', 'english' => ' Burkina Faso', 'code' => 226],
+            ['title' => '布隆迪', 'english' => 'Burundi', 'code' => 257],
+            ['title' => '希腊', 'english' => ' Greece', 'code' => 30],
+            ['title' => '帕劳', 'english' => 'Palau', 'code' => 680],
+            ['title' => '库克群岛', 'english' => ' Cook Islands', 'code' => 682],
+            ['title' => '开曼群岛', 'english' => 'Cayman Islands', 'code' => 1345],
+            ['title' => '德国', 'english' => ' Germany', 'code' => 49],
+            ['title' => '意大利', 'english' => 'Italy', 'code' => 39],
+            ['title' => '所罗门群岛', 'english' => ' Solomon Islands', 'code' => 677],
+            ['title' => '托克劳', 'english' => 'Tokelau', 'code' => 690],
+            ['title' => '拉脱维亚', 'english' => 'Latvia', 'code' => 371],
+            ['title' => '挪威', 'english' => 'Norway', 'code' => 47],
+            ['title' => '捷克共和国', 'english' => 'Czech Republic', 'code' => 420],
+            ['title' => '摩尔多瓦', 'english' => 'Moldova', 'code' => 373],
+            ['title' => '摩洛哥', 'english' => 'Morocco', 'code' => 212],
+            ['title' => '摩纳哥', 'english' => 'Monaco', 'code' => 377],
+            ['title' => '文莱', 'english' => 'Brunei Darussalam', 'code' => 673],
+            ['title' => '斐济', 'english' => 'Fiji', 'code' => 679],
+            ['title' => '斯威士兰王国', 'english' => 'The Kingdom of Swaziland', 'code' => 268],
+            ['title' => '斯洛伐克', 'english' => 'Slovakia', 'code' => 421],
+            ['title' => '斯洛文尼亚', 'english' => 'Slovenia', 'code' => 386],
+            ['title' => '斯里兰卡', 'english' => 'Sri Lanka', 'code' => 94],
+            ['title' => '新加坡', 'english' => 'Singapore ', 'code' => 65],
+            ['title' => '新喀里多尼亚', 'english' => 'New Caledonia', 'code' => 687],
+            ['title' => '新西兰', 'english' => 'New Zealand', 'code' => 64],
+            ['title' => '日本', 'english' => 'Japan', 'code' => 81],
+            ['title' => '智利', 'english' => 'Chile', 'code' => 56],
+            ['title' => '朝鲜', 'english' => 'Korea, North', 'code' => 850],
+            ['title' => '柬埔寨 ', 'english' => 'Cambodia', 'code' => 855],
+            ['title' => '格林纳达', 'english' => 'Grenada', 'code' => 1473],
+            ['title' => '格陵兰', 'english' => 'Greenland', 'code' => 299],
+            ['title' => '格鲁吉亚', 'english' => 'Georgia', 'code' => 995],
+            ['title' => '比利时', 'english' => 'Belgium', 'code' => 32],
+            ['title' => '毛里塔尼亚', 'english' => 'Mauritania', 'code' => 222],
+            ['title' => '毛里求斯', 'english' => 'Mauritius', 'code' => 230],
+            ['title' => '汤加', 'english' => 'Tonga', 'code' => 676],
+            ['title' => '沙特阿拉伯', 'english' => 'Saudi Arabia', 'code' => 966],
+            ['title' => '法国', 'english' => 'France', 'code' => 33],
+            ['title' => '法属圭亚那', 'english' => 'French Guiana', 'code' => 594],
+            ['title' => '法属波利尼西亚', 'english' => 'French Polynesia', 'code' => 689],
+            ['title' => '法属西印度群岛', 'english' => 'french west indies', 'code' => 596],
+            ['title' => '法罗群岛', 'english' => 'Faroe Islands', 'code' => 298],
+            ['title' => '波兰', 'english' => 'Poland', 'code' => 48],
+            ['title' => '波多黎各', 'english' => 'The Commonwealth of Puerto Rico', 'code' => 17871939],
+            ['title' => '波黑', 'english' => 'Bosnia and Herzegovina ', 'code' => 387],
+            ['title' => '泰国', 'english' => 'Thailand', 'code' => 66],
+            ['title' => '津巴布韦', 'english' => 'Zimbabwe', 'code' => 263],
+            ['title' => '洪都拉斯', 'english' => 'Honduras', 'code' => 504],
+            ['title' => '海地', 'english' => 'Haiti', 'code' => 509],
+            ['title' => '澳大利亚', 'english' => 'Australia', 'code' => 61],
+            ['title' => '澳门', 'english' => 'Macao', 'code' => 853],
+            ['title' => '爱尔兰', 'english' => 'Ireland', 'code' => 353],
+            ['title' => '爱沙尼亚', 'english' => 'Estonia', 'code' => 372],
+            ['title' => '牙买加 ', 'english' => 'Jamaica', 'code' => 1876],
+            ['title' => '特克斯和凯科斯群岛', 'english' => 'Turks and Caicos Islands', 'code' => 1649],
+            ['title' => '特立尼达和多巴哥', 'english' => 'Trinidad and Tobago', 'code' => 1868],
+            ['title' => '玻利维亚', 'english' => 'Bolivia', 'code' => 591],
+            ['title' => '瑙鲁', 'english' => 'Nauru', 'code' => 674],
+            ['title' => '瑞典', 'english' => 'Sweden', 'code' => 46],
+            ['title' => '瑞士', 'english' => 'Switzerland', 'code' => 41],
+            ['title' => '瓜德罗普', 'english' => 'Guadeloupe', 'code' => 590],
+            ['title' => '瓦利斯和富图纳群岛', 'english' => 'Wallis et Futuna', 'code' => 681],
+            ['title' => '瓦努阿图', 'english' => 'Vanuatu', 'code' => 678],
+            ['title' => '留尼汪 ', 'english' => 'Reunion', 'code' => 262],
+            ['title' => '白俄罗斯', 'english' => 'Belarus', 'code' => 375],
+            ['title' => '百慕大', 'english' => 'Bermuda', 'code' => 1441],
+            ['title' => '直布罗陀', 'english' => 'Gibraltar', 'code' => 350],
+            ['title' => '福克兰群岛', 'english' => 'Falkland', 'code' => 500],
+            ['title' => '科威特', 'english' => 'Kuwait', 'code' => 965],
+            ['title' => '科摩罗和马约特', 'english' => 'Comoros', 'code' => 269],
+            ['title' => '科特迪瓦', 'english' => 'Cote d’Ivoire', 'code' => 225],
+            ['title' => '秘鲁', 'english' => 'Peru', 'code' => 51],
+            ['title' => '突尼斯', 'english' => 'Tunisia', 'code' => 216],
+            ['title' => '立陶宛', 'english' => 'Lithuania', 'code' => 370],
+            ['title' => '索马里', 'english' => 'Somalia', 'code' => 252],
+            ['title' => '约旦', 'english' => 'Jordan', 'code' => 962],
+            ['title' => '纳米比亚', 'english' => 'Namibia', 'code' => 264],
+            ['title' => '纽埃岛', 'english' => 'Island of Niue', 'code' => 683],
+            ['title' => '缅甸  ', 'english' => 'Burma', 'code' => 95],
+            ['title' => '罗马尼亚', 'english' => 'Romania', 'code' => 40],
+            ['title' => '美国', 'english' => 'United States of America', 'code' => 1],
+            ['title' => '美属维京群岛', 'english' => 'Virgin Islands', 'code' => 1340],
+            ['title' => '美属萨摩亚', 'english' => 'American Samoa', 'code' => 1684],
+            ['title' => '老挝', 'english' => 'Laos', 'code' => 856],
+            ['title' => '肯尼亚', 'english' => 'Kenya', 'code' => 254],
+            ['title' => '芬兰', 'english' => 'Finland', 'code' => 358],
+            ['title' => '苏丹', 'english' => 'Sudan', 'code' => 249],
+            ['title' => '苏里南', 'english' => 'Suriname', 'code' => 597],
+            ['title' => '英国', 'english' => 'United Kingdom', 'code' => 44],
+            ['title' => '英属维京群岛', 'english' => 'British Virgin Islands', 'code' => 1284],
+            ['title' => '荷兰', 'english' => 'Netherlands', 'code' => 31],
+            ['title' => '荷属安的列斯', 'english' => 'Netherlands Antilles', 'code' => 599],
+            ['title' => '莫桑比克', 'english' => 'Mozambique', 'code' => 258],
+            ['title' => '莱索托', 'english' => 'Lesotho', 'code' => 266],
+            ['title' => '菲律宾', 'english' => 'Philippines', 'code' => 63],
+            ['title' => '萨尔瓦多', 'english' => 'El Salvador', 'code' => 503],
+            ['title' => '萨摩亚', 'english' => 'Samoa', 'code' => 685],
+            ['title' => '葡萄牙', 'english' => 'Portugal', 'code' => 351],
+            ['title' => '蒙古', 'english' => 'Mongolia', 'code' => 976],
+            ['title' => '西班牙', 'english' => 'Spain', 'code' => 34],
+            ['title' => '贝宁', 'english' => 'Benin', 'code' => 229],
+            ['title' => '赞比亚', 'english' => 'Zambia', 'code' => 260],
+            ['title' => '赤道几内亚', 'english' => 'Equatorial Guinea', 'code' => 240],
+            ['title' => '越南', 'english' => 'Vietnam', 'code' => 84],
+            ['title' => '阿塞拜疆', 'english' => 'Azerbaijan', 'code' => 994],
+            ['title' => '阿富汗', 'english' => 'Afghanistan', 'code' => 93],
+            ['title' => '阿尔及利亚', 'english' => 'Algeria', 'code' => 213],
+            ['title' => '阿尔巴尼亚', 'english' => 'Albania', 'code' => 355],
+            ['title' => '阿拉伯联合酋长国', 'english' => 'United Arab Emirates', 'code' => 971],
+            ['title' => '阿曼', 'english' => 'Oman', 'code' => 968],
+            ['title' => '阿根廷', 'english' => 'Argentina', 'code' => 54],
+            ['title' => '阿鲁巴', 'english' => 'Aruba', 'code' => 297],
+            ['title' => '韩国', 'english' => 'Korea, South)', 'code' => 82],
+            ['title' => '香港', 'english' => 'Hong Kong(SAR)', 'code' => 852],
+            ['title' => '马其顿', 'english' => 'Macedonia', 'code' => 389],
+            ['title' => '马尔代夫', 'english' => 'Maldives  ', 'code' => 960],
+            ['title' => '马拉维', 'english' => ' Malawi', 'code' => 265],
+            ['title' => '马来西亚', 'english' => 'Malaysia', 'code' => 60],
+            ['title' => '马绍尔群岛', 'english' => 'Marshall Islands', 'code' => 692],
+            ['title' => '马耳他', 'english' => 'Malta', 'code' => 356],
+            ['title' => '马达加斯加', 'english' => 'Madagascar', 'code' => 261],
+            ['title' => '马里', 'english' => 'Mali', 'code' => 223],
+            ['title' => '黎巴嫩', 'english' => 'Lebanon', 'code' => 961],
+            ['title' => '黑山共和国', 'english' => 'The Republic of Montenegro', 'code' => 382],
+        ];
+    }
+
+}

+ 71 - 0
application/store/service/GoodsService.php

@@ -0,0 +1,71 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\service;
+
+use think\Db;
+
+/**
+ * 商品数据管理
+ * Class GoodsService
+ * @package app\store\logic
+ */
+class GoodsService
+{
+    /**
+     * 同步商品库存信息
+     * @param integer $goodsId
+     * @return boolean
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public static function syncStock($goodsId)
+    {
+        // 商品入库统计
+        $fields = "goods_id,goods_spec,ifnull(sum(number_stock),0) number_stock";
+        $stockList = Db::name('StoreGoodsStock')->field($fields)->where(['goods_id' => $goodsId])->group('goods_id,goods_spec')->select();
+        // 商品销量统计
+        $where = [['b.goods_id', 'eq', $goodsId], ['a.status', 'in', ['1', '2', '3', '4', '5']]];
+        $fields = 'b.goods_id,b.goods_spec,ifnull(sum(b.number_goods),0) number_sales';
+        $salesList = Db::table('store_order a')->field($fields)->leftJoin('store_order_list b', 'a.order_no=b.order_no')->where($where)->group('b.goods_id,b.goods_spec')->select();
+        // 组装更新数据
+        $dataList = [];
+        foreach (array_merge($stockList, $salesList) as $vo) {
+            $key = "{$vo['goods_id']}@@{$vo['goods_spec']}";
+            $dataList[$key] = isset($dataList[$key]) ? array_merge($dataList[$key], $vo) : $vo;
+            if (empty($dataList[$key]['number_sales'])) $dataList[$key]['number_sales'] = '0';
+            if (empty($dataList[$key]['number_stock'])) $dataList[$key]['number_stock'] = '0';
+        }
+        unset($salesList, $stockList);
+        // 更新商品规格销量及库存
+        foreach ($dataList as $vo) Db::name('StoreGoodsList')->where([
+            'goods_id'   => $goodsId,
+            'goods_spec' => $vo['goods_spec'],
+        ])->update([
+            'number_stock' => $vo['number_stock'],
+            'number_sales' => $vo['number_sales'],
+        ]);
+        // 更新商品主体销量及库存
+        Db::name('StoreGoods')->where(['id' => $goodsId])->update([
+            'number_stock' => intval(array_sum(array_column($dataList, 'number_stock'))),
+            'number_sales' => intval(array_sum(array_column($dataList, 'number_sales'))),
+        ]);
+        return true;
+    }
+
+}

+ 67 - 0
application/store/service/OrderService.php

@@ -0,0 +1,67 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\service;
+
+use think\Db;
+
+/**
+ * 订单服务管理器
+ * Class OrderService
+ * @package app\store\service
+ */
+class OrderService
+{
+    /**
+     * 根据订单号升级会员等级
+     * @param string $order_no 订单单号
+     * @return boolean
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public static function update($order_no)
+    {
+        // @todo 更新订单状态
+    }
+
+    /**
+     * 根据订单同步库存销量
+     * @param string $order_no
+     * @return boolean
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public static function syncStock($order_no)
+    {
+        $map = ['order_no' => $order_no];
+        $goodsIds = Db::name('StoreOrderList')->where($map)->column('goods_id');
+        foreach (array_unique($goodsIds) as $goodsId) if (!GoodsService::syncStock($goodsId)) return false;
+        return true;
+    }
+
+    /**
+     * 订单利润计算
+     * @param string $order_no
+     * @return boolean
+     */
+    public static function profit($order_no = '')
+    {
+        // @todo 计算订单返佣
+    }
+}

+ 19 - 0
application/store/sys.php

@@ -0,0 +1,19 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+// 注册系统指令
+\think\Console::addDefaultCommands([
+    'app\store\command\AutoRun',
+]);

+ 18 - 0
application/store/view/config/index-about-us.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">关于我们</span><span class="nowrap color-desc">AboutUs</span>
+            <textarea name="about_us">{:sysconf('about_us')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="about_us"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/index-agreement.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">使用条款</span><span class="nowrap color-desc">Agreement</span>
+            <textarea name="agreement">{:sysconf('agreement')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="agreement"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/index-chain_on_query.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">链上查询</span><span class="nowrap color-desc">ChainOnQuery</span>
+            <textarea name="chain_on_query">{:sysconf('chain_on_query')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="chain_on_query"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/index-registration_agreement.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">用户注册协议</span><span class="nowrap color-desc">RegistrationAgreement</span>
+            <textarea name="registration_agreement">{:sysconf('registration_agreement')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="registration_agreement"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/index-terms_service.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">联通统一认证服务条款</span><span class="nowrap color-desc">TermsService</span>
+            <textarea name="terms_service">{:sysconf('terms_service')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="terms_service"]', {height: 500});
+        })
+    </script>
+</form>

+ 40 - 0
application/store/view/config/index.html

@@ -0,0 +1,40 @@
+{extend name="admin@main"}
+
+{block name="content"}
+
+<div class="layui-tab layui-tab-card think-bg-white">
+    <ul class="layui-tab-title notselect">
+        <li data-type="store-config-type-sms1">系统设置</li>
+        <li data-type="store-config-type-sms2">使用条款</li>
+        <li data-type="store-config-type-sms2">隐私协议</li>
+        <li data-type="store-config-type-sms2">违规处罚</li>
+        <li data-type="store-config-type-sms2">用户注册协议</li>
+        <li data-type="store-config-type-sms2">关于我们</li>
+        <li data-type="store-config-type-sms2">联通统一认证服务条款</li>
+        <li data-type="store-config-type-sms2">链上查询</li>
+    </ul>
+    <div class="layui-tab-content">
+        <div class="layui-tab-item">{include file='config/platform-set'}</div>
+        <div class="layui-tab-item">{include file='config/index-agreement'}</div>
+        <div class="layui-tab-item">{include file='config/privacy'}</div>
+        <div class="layui-tab-item">{include file='config/platform-agreement'}</div>
+        <div class="layui-tab-item">{include file='config/index-registration_agreement'}</div>
+        <div class="layui-tab-item">{include file='config/index-about-us'}</div>
+        <div class="layui-tab-item">{include file='config/index-terms_service'}</div>
+        <div class="layui-tab-item">{include file='config/index-chain_on_query'}</div>
+    </div>
+</div>
+
+<script>
+    (function (storage) {
+        (function (type, $default, $checked) {
+            $default = $('.layui-tab ul.layui-tab-title li:first');
+            $checked = $('.layui-tab ul.layui-tab-title li[data-type="' + type + '"]');
+            ($checked.length > 0 ? $checked : $default).trigger('click');
+        })(layui.data(storage)['type'] || '');
+        $('.layui-tab ul.layui-tab-title li[data-type]').on('click', function () {
+            layui.data(storage, {key: 'type', value: this.getAttribute('data-type')});
+        });
+    })('store-config-type');
+</script>
+{/block}

+ 18 - 0
application/store/view/config/platform-agreement.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">违规处罚</span><span class="nowrap color-desc">PlatformAgreement</span>
+            <textarea name="platform_agreement">{:sysconf('platform_agreement')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="platform_agreement"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/platform-notice.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">平台消息</span><span class="nowrap color-desc">PlatformNotice</span>
+            <textarea name="platform_notice">{:sysconf('platform_notice')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="platform_notice"]', {height: 500});
+        })
+    </script>
+</form>

+ 100 - 0
application/store/view/config/platform-set.html

@@ -0,0 +1,100 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">自动取消订单时间(分)</span><span class="nowrap color-desc">CancelTime</span>
+            <input name="cancel_time" type="number" required placeholder="自动取消订单时间" value="{:sysconf('cancel_time')}" class="layui-input">
+            <p class="help-block">用户下单后??分之后未支付自动取消(正整数)</p>
+        </label>
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">创世勋章提前抢购分钟(分)</span><span class="nowrap color-desc">AdvanceMinutes</span>
+            <input name="advance_minutes" type="number" required placeholder="创世勋章提前抢购分钟" value="{:sysconf('advance_minutes')}" class="layui-input">
+            <p class="help-block">创世勋章提前抢购分钟(正整数)</p>
+        </label>
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">购买藏品获得积分(购买一个藏品)</span><span class="nowrap color-desc">ByCollectionIntegral</span>
+            <input name="by_collection_integral" type="number" required placeholder="购买藏品获得积分" value="{:sysconf('by_collection_integral')}" class="layui-input">
+            <p class="help-block">购买藏品成功后获得积分(正整数)</p>
+        </label>
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">签到获得积分</span><span class="nowrap color-desc">SignIntegral</span>
+            <input name="sign_integral" type="number" required placeholder="签到获得积分" value="{:sysconf('sign_integral')}" class="layui-input">
+            <p class="help-block">签到获得积分(正整数)</p>
+        </label>
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">邀请好友获得积分</span><span class="nowrap color-desc">InviteFriendsIntegral</span>
+            <input name="invite_friends_integral" type="number" required placeholder="邀请好友获得积分" value="{:sysconf('invite_friends_integral')}" class="layui-input">
+            <p class="help-block">邀请好友获得积分(正整数)</p>
+        </label>
+
+
+<!--        <label class="layui-form-item block relative">-->
+<!--            <span class="color-green margin-right-10">自定义名称</span><span class="nowrap color-desc">PlatName</span>-->
+<!--            <input name="plat_name" required placeholder="" value="{:sysconf('plat_name')}" class="layui-input">-->
+<!--        </label>-->
+
+<!--        <label class="layui-form-item block relative">-->
+<!--            <span class="color-green margin-right-10">关于发货</span><span class="nowrap color-desc">AboutDeliver</span>-->
+<!--            <input name="about_deliver"  placeholder="" value="{:sysconf('about_deliver')}" class="layui-input">-->
+<!--        </label>-->
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">转赠说明</span><span class="nowrap color-desc">ExamplesIllustrate</span>
+            <textarea placeholder="请输入转赠说明" required class="layui-textarea" name="examples_illustrate">{:sysconf('examples_illustrate')}</textarea>
+        </label>
+
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">安卓版本</span><span class="nowrap color-desc">AndroidVersion</span>
+            <input name="android_version"  required placeholder="安卓版本" value="{:sysconf('android_version')}" class="layui-input">
+            <p class="help-block">安卓当前版本号</p>
+        </label>
+
+
+        <label class="layui-form-item block relative">
+            <label class="layui-col-xs8 think-form-group-left">
+                <input name="android_package" required value="{:sysconf('android_package')}" placeholder="请上传安卓包" class="layui-input">
+            </label>
+            <a class="layui-col-xs2 layui-btn think-form-group-right" data-file="btn" data-field="android_package" data-type="apk">
+                <i class="layui-icon layui-icon-upload"></i> 上传
+            </a>
+        </label>
+
+        <label class="layui-form-item block relative">
+            <span class="color-green margin-right-10">ios地址</span><span class="nowrap color-desc">IosPackage</span>
+            <input name="ios_package"  required placeholder="ios地址" value="{:sysconf('ios_package')}" class="layui-input">
+            <p class="help-block">ios链接地址</p>
+        </label>
+
+
+
+
+
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+</form>
+<script>
+    layui.use('laydate', function(){
+        var laydate = layui.laydate;
+        //时间选择器
+        laydate.render({
+            elem: '#start_time_cost'
+            ,type: 'time'
+        });
+        laydate.render({
+            elem: '#end_time_cost'
+            ,type: 'time'
+        });
+    })
+
+
+
+
+</script>

+ 18 - 0
application/store/view/config/privacy.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">隐私协议</span><span class="nowrap color-desc">Privacy</span>
+            <textarea name="privacy">{:sysconf('privacy')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="privacy"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/purchase-notice.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">购买与转赠须知</span><span class="nowrap color-desc">PurchaseNotice</span>
+            <textarea name="purchase_notice">{:sysconf('purchase_notice')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="purchase_notice"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/self.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">自定义文字</span><span class="nowrap color-desc">Self</span>
+            <textarea name="self">{:sysconf('self')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="self"]', {height: 500});
+        })
+    </script>
+</form>

+ 18 - 0
application/store/view/config/service.html

@@ -0,0 +1,18 @@
+<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body padding-40">
+        <label class="layui-form-item margin-top-20 block relative">
+            <span class="color-green margin-right-10">客服配置</span><span class="nowrap color-desc">Service</span>
+            <textarea name="service">{:sysconf('service')}</textarea>
+        </label>
+        <div class="layui-form-item text-center margin-top-20">
+            <button class="layui-btn" type="submit">保存配置</button>
+        </div>
+    </div>
+    <script>
+        window.form.render();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="service"]', {height: 500});
+        })
+    </script>
+</form>

+ 28 - 0
application/store/view/exchange_code/form.html

@@ -0,0 +1,28 @@
+
+<div class="think-box-shadow">
+<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
+    <div class="layui-card-body">
+        <input type="hidden" name="goods_id" value="{$goods_id|default='0'}"/>
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">数量</label>
+            <div class="layui-input-block">
+                <select name="num" >
+                    <option value="1">1</option>
+                    <option value="10">10</option>
+                    <option value="50">50</option>
+                    <option value="100">100</option>
+                    <option value="500">500</option>
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item text-center" style="margin-top: 100px">
+            <button class="layui-btn" type='submit'>保 存</button>
+            <button class="layui-btn layui-btn-danger" type='button' data-close>取消</button>
+        </div>
+    </div>
+</form>
+    <script>
+        window.form.render();
+    </script>
+</div>

+ 61 - 0
application/store/view/exchange_code/index.html

@@ -0,0 +1,61 @@
+{extend name='admin@main'}
+
+{block name="button"}
+    <button data-modal='{:url("add")}?goods_id={$goods_id}' data-title="添加" class='layui-btn layui-btn-sm layui-btn-primary'>添加</button>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='exchange_code/index_search'}
+    <table class="layui-table margin-top-20" lay-skin="line">
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>兑换码</th>
+            <th class='text-left nowrap'>使用状态</th>
+            <th class='text-left nowrap'>会员</th>
+            <th class="text-left" style="width: 20%">操作</th>
+        </tr>
+        </thead>
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.code|default=''}</td>
+            <td class='text-left nowrap'>{$vo.status == 1 ? '未使用':'已使用'}</td>
+            <td class='text-left nowrap'>{$vo.user_name|default='--'}</td>
+            <td class='text-left' style="width: 20%">
+                <span class="layui-btn layui-btn-sm layui-btn-danger" onclick="btn_confirm('删除','del','{$vo.id}');">删 除</span>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/exchange_code/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+
+</script>
+{/block}
+
+
+

+ 25 - 0
application/store/view/exchange_code/index_search.html

@@ -0,0 +1,25 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">使用状态</label>
+            <div class="layui-input-inline">
+                <select class="layui-select" name="status">
+                    {foreach ['全部','未使用','已使用'] as $k=>$v}
+                        {if $Think.get.status eq $k}
+                            <option selected value="{$k}">{$v}</option>
+                        {else}
+                            <option  value="{$k}">{$v}</option>
+                        {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 55 - 0
application/store/view/goods/detail.html

@@ -0,0 +1,55 @@
+{extend name='admin@main'}
+
+
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>hash</th>
+            <th class='text-left nowrap'>ddcid</th>
+            <th class="text-left nowrap">铸造时间</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.hash|default=''}</td>
+            <td class='text-left nowrap'>{$vo.ddcid|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 214 - 0
application/store/view/goods/form.html

@@ -0,0 +1,214 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">藏品图片</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="cover" lay-verify="required" type="hidden" value="{$vo.covers|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="cover"]').uploadOneImage(), $('[name="covers"]').uploadMultipleImage()</script>
+        </div>
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品名称</span>
+                <input name="name" required class="layui-input" placeholder="请输入藏品名称" value="{$vo.name|default=''}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品标签</span>
+                <input name="label" required class="layui-input" placeholder="请输入藏品标签" value="{$vo.label|default=''}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品库存</span>
+                <input name="inventory" required type="number" class="layui-input" placeholder="请输入库存" value="{$vo.inventory|default='1'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品价格</span>
+                <input name="price" required type="number" step="1" class="layui-input" placeholder="请输入价格" value="{$vo.price|default='0'}">
+            </label>
+        </div>
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">发行日期</span>
+                <input name="sell_time" required id="sell_time" readonly value='{$vo.sell_time|default=""}' placeholder="" class="layui-input">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">限购数量(每人限购数量)</span>
+                <input name="buy_count" required type="number" class="layui-input" placeholder="请输入限购数量" value="{$vo.buy_count|default='1'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">转赠天数(第一次转赠限制天数,0为不限制)</span>
+                <input name="one_given_day" required type="number" class="layui-input" placeholder="请输入转赠天数(第一次转赠限制天数,0为不限制)" value="{$vo.one_given_day|default='0'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">转赠天数(后续转赠限制天数,0为不限制)</span>
+                <input name="other_given_day" required type="number" step="1" class="layui-input" placeholder="请输入转赠天数(后续转赠限制天数,0为不限制)" value="{$vo.other_given_day|default='0'}">
+            </label>
+        </div>
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">作者姓名</span>
+                <input name="auth_name" required class="layui-input" placeholder="请输入作者姓名" value="{$vo.auth_name|default=''}">
+            </label>
+
+        </div>
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">作者头像</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="auth_img" type="hidden" value="{$vo.auth_imgs|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="auth_img"]').uploadOneImage(), $('[name="auth_imgs"]').uploadMultipleImage()</script>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs4 relative">
+                <span class="color-green">权益说明</span>
+                <textarea placeholder="请输入权益说明" required class="layui-textarea" name="instructions">{$vo.instructions|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs4 relative">
+                <span class="color-green">购买须知</span>
+                <textarea placeholder="请输入购买须知" required class="layui-textarea" name="buy_notice">{$vo.buy_notice|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs4 relative">
+                <span class="color-green">温馨提示</span>
+                <textarea placeholder="请输入温馨提示" required class="layui-textarea" name="warm_prompt">{$vo.warm_prompt|default=""}</textarea>
+            </label>
+        </div>
+
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">商品描述(多张图片)</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <!--<td width="90px" class="text-center"><input name="logo" type="hidden" value="{$vo.logo|default=''}"></td>-->
+                    <td width="auto" class="text-left"><input name="describe" type="hidden" value="{$vo.describes|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="logo"]').uploadOneImage(), $('[name="describe"]').uploadMultipleImage()</script>
+        </div>
+
+<!--        <div class="layui-form-item">-->
+<!--            <span class="color-green label-required-prev">分享二维码</span>-->
+<!--            <table class="layui-table">-->
+<!--                <thead>-->
+<!--                <tr>-->
+<!--                    <td width="90px" class="text-left"><input name="share_img" type="hidden" value="{$vo.share_imgs|default=''}"></td>-->
+<!--                </tr>-->
+<!--                </thead>-->
+<!--            </table>-->
+<!--            <script>$('[name="share_img"]').uploadOneImage(), $('[name="share_imgs"]').uploadMultipleImage()</script>-->
+<!--        </div>-->
+
+        <div class="layui-form-item text-center">
+            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+<textarea class="layui-hide" id="goods-specs">{$vo.specs|raw|default=''}</textarea>
+<textarea class="layui-hide" id="goods-value">{$defaultValues|raw|default=''}</textarea>
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+        var form = layui.form
+            ,layer = layui.layer
+            ,layedit = layui.layedit
+            ,laydate = layui.laydate;
+
+        laydate.render({
+            elem: '#sell_time'
+            ,type: 'datetime'
+            ,min:new Date().toLocaleString()
+        });
+        form.render();
+        //日期
+        laydate.render({
+            elem: '#date'
+        });
+        laydate.render({
+            elem: '#date1'
+        });
+
+        form.on('select(province)', function (data) {
+            var val = data.value;
+            // console.log(val)
+            $.ajax({
+                type:"get",
+                url:"{:url('member/get_city')}",  //数据传输的控制器方法
+                data: {id:val},//这里data传递过去的是序列化以后的字符串
+                success:function(data){
+                   // console.log(data)
+                    var arr = data.data;
+                    //console.log(arr)
+                    if (arr.length>0){
+                        //$("#tow").attr("style","display:block;");//显示div
+                        var options='<option value="">请选择市</option>';
+                        for (var i = 0; i < arr.length; i++) {
+                            var tag = arr[i];
+                            options+=' <option value="'+tag.id+'">'+tag.name+'</option>';
+                        }
+                        $("select[name='city']").html(options)
+                        form.render('select');
+                    }else {
+                        var options='<option value="">请选择市</option>';
+                        $("select[name='city']").html(options)
+                        form.render('select');
+                    }
+                }
+            });
+        });
+
+        form.on('select(city)', function (data) {
+            var val = data.value;
+            // console.log(val)
+            $.ajax({
+                type:"get",
+                url:"{:url('member/get_area')}",  //数据传输的控制器方法
+                data: {id:val},//这里data传递过去的是序列化以后的字符串
+                success:function(data){
+                    //console.log(data)
+                    var arr = data.data;
+                   // console.log(arr)
+                    if (arr.length>0){
+                        var options='<option value="">请选择区</option>';
+                        for (var i = 0; i < arr.length; i++) {
+                            var tag = arr[i];
+                            options+=' <option value="'+tag.id+'">'+tag.name+'</option>';
+                        }
+                        $("select[name='area']").html(options)
+                        form.render('select');
+                    }else {
+                        var options='<option value="">请选择区</option>';
+                        $("select[name='area']").html(options)
+                        form.render('select');
+                    }
+                }
+            });
+        });
+
+
+
+    });
+</script>
+{/block}

+ 479 - 0
application/store/view/goods/form2.html

@@ -0,0 +1,479 @@
+
+<link rel="stylesheet" href="/static/plugs/layui/css/layui.css"  media="all">
+
+<style>
+    .layui-form-item {
+        width: 80%;
+        height: 90%;
+    }
+    .layui-form-radio{
+       width: 10px !important;
+    }
+
+</style>
+
+<div class="think-box-shadow" style="height: 100%">
+    <form class="layui-form layui-card" id="subForm" action="{:request()->url()}"  data-auto="true" method="post" autocomplete="off">
+        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
+            <legend>商品编辑</legend>
+        </fieldset>
+        <div class="layui-tab">
+            <ul class="layui-tab-title">
+                <li class="layui-this">基础设置</li>
+                <li >其他</li>
+            </ul>
+            <div class="layui-tab-content ">
+                <!--基础设置-->
+                <div class="layui-tab-item layui-show">
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品名称</label>
+                        <div class="layui-input-block">
+                            <input name="name" lay-verify="required" maxlength="50"  value='{$vo.name|default=""}' placeholder="请输入商品名称" class="layui-input">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item" style="display: none">
+                        <label class="layui-form-label">商品简介</label>
+                        <div class="layui-input-block">
+                            <input name="desc" maxlength="50"  value='{$vo.desc|default=""}' placeholder="请输入商品简介" class="layui-input">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品封面</label>
+                        <div class="layui-input-block">
+                            <input name="cover" type="hidden" value="{$vo.cover|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品类型</label>
+                        <div class="layui-input-inline">
+                            <input type="hidden" id="goods_type" value="{$vo.type|default='1'}"/>
+                            <select name="type" {if isset($vo.id)}disabled{/if} lay-filter ="type">
+                                {foreach  $goods_type as $gk=>$gv}
+                                    <option value="{$gk}"  {if isset($vo.id) && $vo.type ==  $gk}selected{/if}>{$gv}</option>
+                                {/foreach}
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="goods_type">
+                        <div class="layui-form-item type1">
+                            <label class="layui-form-label label-required">商品售价</label>
+                            <div class="layui-input-block">
+                                <input name="goods_price" type="number" step="1" class="layui-input"  value="{$vo.goods_price|default=''}">
+                            </div>
+                        </div>
+                        <div class="layui-form-item type3">
+                            <label class="layui-form-label">邀请人数</label>
+                            <div class="layui-input-block">
+                                <input name="invite_num" type="number" step="1" class="layui-input"  value="{$vo.invite_num|default='0'}">
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">是否转赠</label>
+
+                        <div class="layui-input-block">
+                            <input type="hidden" id="is_gift" value="{$vo.is_gift|default='0'}"/>
+                            <div>
+                                {foreach [0=>'否',1=>'是'] as $sk=>$sv}
+                                <!--{if (isset($vo.id) && $vo.is_gift eq $sk) || ($sk== 0 && !isset($vo.id)) }-->
+                                <label>
+                                    <input checked type="radio"  name="is_gift" value="{$sk}"  lay-filter="is_gift">
+                                </label>
+                                <!--{else}-->
+                                <label >
+                                    <input type="radio" name="is_gift" value="{$sk}"  lay-filter="is_gift" >
+                                </label>
+                                <!--{/if}-->
+                                <span class="" style="line-height: 22px">{$sv}</span>
+                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                                {/foreach}
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item type4 ">
+                        <label class="layui-form-label">转赠元石</label>
+                        <div class="layui-input-block">
+                            <input name="crystal" type="number" step="1" class="layui-input"  value="{$vo.crystal|default='0'}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item type4">
+                        <label class="layui-form-label">转赠时间限制(天)</label>
+                        <div class="layui-input-block">
+                            <input name="gift_day" type="number" step="1" class="layui-input"  value="{$vo.gift_day|default='0'}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品库存</label>
+                        <div class="layui-input-block">
+                            <input name="stock"type="number" step="1" class="layui-input"  value="{$vo.stock|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">收藏量</label>
+                        <div class="layui-input-block">
+                            <input name="vir_num"type="number" step="1" class="layui-input"  value="{$vo.vir_num|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">藏品介绍</label>
+                        <div class="layui-input-block">
+                            <input name="coll_intro"type=""  class="layui-input"  value="{$vo.coll_intro|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label ">上架时间</label>
+                        <div class="layui-input-block">
+                            <input name="sell_time" id="sell_time" value='{$vo.sell_time|default=""}' placeholder="" class="layui-input">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">展示类型</label>
+                        <div class="layui-input-inline">
+                            <input id="adv_type" type="hidden" value="{$vo.adv_type|default='1'}" />
+                            <select name="adv_type" lay-filter ="adv_type">
+                                <option value="1" {if isset($vo.adv_type) && $vo.adv_type == 1}selected{/if}>图片</option>
+                                <option value="3" {if isset($vo.adv_type) && $vo.adv_type == 3}selected{/if}>视频</option>
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="adv_box">
+                        <div class="layui-form-item adv_box1">
+                            <label class="layui-form-label">展示封面</label>
+                            <div class="layui-input-block">
+                                <input name="adv_cover" type="hidden" value="{$vo.adv_cover|default=''}">
+                            </div>
+                        </div>
+
+                        <div class="layui-form-item adv_box2">
+                            <label class="layui-form-label">展示音频</label>
+                            <div class="layui-input-block">
+                                <div class="audio_box" style="float:left;">
+                                    <audio   style='' controls>
+                                        <source  src="" >
+                                        <source id="mp3" src="{$vo.mp3_url|default=''}" >
+                                    </audio>
+                                </div>
+                                <div  class ='up_img' style='color: blue;line-height:50px;margin-left:30px;float: left; width: 60px ;'>选 择</div >
+                                <input  style="display: none"  type="file" name="file" accept="mp3" value="" onchange="upload_img(this)" class="layui-input"/>
+                                <input  style="display: none"  value="{$vo.mp3_url|default=''}" name="mp3_url" class="layui-input"/>
+                                <div></div>
+                            </div>
+                        </div>
+
+
+
+
+
+                        <div class="layui-form-item adv_box3">
+                            <label class="layui-form-label ">展示视频</label>
+                            <div class="layui-input-block">
+                                <input name="audio_url" type="hidden" value="{$vo.audio_url|default=''}">
+                            </div>
+                        </div>
+
+                        <div class="layui-form-item adv_box3">
+                            <label class="layui-form-label ">进度显示</label>
+                            <div class="layui-input-block">
+                                <input type="hidden" id="audio_line" value="{$vo.audio_line|default='0'}"/>
+                                <div>
+                                    {foreach [0=>'否',1=>'是'] as $sk=>$sv}
+                                    <!--{if (isset($vo.id) && $vo.audio_line eq $sk) || ($sk== 0 && !isset($vo.id)) }-->
+                                    <label>
+                                        <input checked type="radio"  name="audio_line" value="{$sk}"  lay-filter="audio_line">
+                                    </label>
+                                    <!--{else}-->
+                                    <label >
+                                        <input type="radio" name="audio_line" value="{$sk}"  lay-filter="audio_line" >
+                                    </label>
+                                    <!--{/if}-->
+                                    <span class="" style="line-height: 22px">{$sv}</span>
+                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                                    {/foreach}
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">购买须知</label>
+                        <div class="layui-input-block">
+                            <textarea name="buy_notice" style="height: 150px;width: 100%;border-color: #e6e6e6" >{$vo.buy_notice|default=""}</textarea>
+                        </div>
+                    </div>
+
+                </div>
+                <!--其他设置-->
+                <div class="layui-tab-item">
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">分享图片</label>
+                        <div class="layui-input-block">
+                            <input name="share_img" type="hidden" value="{$vo.share_img|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">支付图片</label>
+                        <div class="layui-input-block">
+                            <input name="pay_pic" type="hidden" value="{$vo.pay_pic|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">支付内容</label>
+                        <div class="layui-input-block">
+                            <input name="pay_content" maxlength="30" type=""  class="layui-input"  value="{$vo.pay_content|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">发行方头像</label>
+                        <div class="layui-input-block">
+                            <input name="auth_img" type="hidden" value="{$vo.auth_img|default=''}">
+                        </div>
+                    </div>
+
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">发行方</label>
+                        <div class="layui-input-block">
+                            <input name="issuer" class="layui-input"  value="{$vo.issuer|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">商品详情</label>
+                        <div class="layui-input-block">
+                            <textarea name="detail">{$vo.detail|default=""}</textarea>
+                        </div>
+                    </div>
+                    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+                    <div class="layui-form-item text-center">
+                        <span class="layui-btn" type='submit' id ="submit">保 存</span>
+                        <button class="layui-btn layui-btn-danger" type='button' onclick="history.go(-1);">取消编辑</button>
+                    </div>
+                </div>
+            </div>
+
+        </div>
+    </form>
+</div>
+<script src="/static/plugs/layui/layui.all.js" charset="utf-8"></script>
+<script>
+    window.form.render();
+    require(['ckeditor', 'angular'], function () {
+        window.createEditor('[name="detail"]', {height: 500,width:1000});
+    })
+    layui.use('laydate', function(){
+        var laydate = layui.laydate;
+        laydate.render({
+            elem: '#sell_time'
+            ,type: 'datetime'
+        });
+        laydate.render({
+            elem: '#end_time'
+            ,type: 'datetime'
+        });
+    })
+    $('[name="cover"]').uploadOneImage();
+    $('[name="share_img"]').uploadOneImage();
+    $('[name="adv_cover"]').uploadOneImage();
+    $('[name="auth_img"]').uploadOneImage();
+    $('[name="pay_pic"]').uploadOneImage();
+    $('[name="audio_url"]').uploadOneVideo()
+    /**
+     * 表单验证
+     */
+    $(document).on('click','#submit',function () {
+        if($('#submit').hasClass('is_sub')) {
+            return false;
+        }
+
+        var goods_name = $('input[name="name"]').val();
+        if(!goods_name){
+            layer.msg('请填写商品名称!')
+            return false;
+        }
+
+        var goods_cover = $('input[name="cover"]').val();
+        if(!goods_cover){
+            layer.msg('请上传商品封面!')
+            return false;
+        }
+
+        var goods_type = $('select[name="type"]').val();
+        var goods_price = $('input[name="goods_price"]').val();
+        if(!goods_type == 1 && !goods_price){
+            layer.msg('请输入商品价格!')
+            return false;
+        }
+
+        var  vir_num =  $('input[name="vir_num"]').val();
+        if(!vir_num){
+            layer.msg('请输入商品收藏量!')
+            return false;
+        }
+
+
+
+        $('#submit').addClass('is_sub');
+        $("#subForm").submit();
+    })
+    layui.use('element', function(){
+        var $ = layui.jquery
+            ,element = layui.element;
+        var active = {
+            tabAdd: function(){
+                element.tabAdd('demo', {
+                    title: '新选项'+ (Math.random()*1000|0)
+                    ,content: '内容'+ (Math.random()*1000|0)
+                    ,id: new Date().getTime()
+                })
+            }
+            ,tabDelete: function(othis){
+                element.tabDelete('demo', '44');
+                othis.addClass('layui-btn-disabled');
+            }
+            ,tabChange: function(){
+                element.tabChange('demo', '22');
+            }
+        };
+
+        $('.site-demo-active').on('click', function(){
+            var othis = $(this), type = othis.data('type');
+            active[type] ? active[type].call(this, othis) : '';
+        });
+
+        //Hash地址的定位
+        var layid = location.hash.replace(/^#test=/, '');
+        element.tabChange('test', layid);
+
+        element.on('tab(test)', function(elem){
+            location.hash = 'test='+ $(this).attr('lay-id');
+        });
+
+    });
+
+
+    // 商品类型
+    var goods_type = $("#goods_type").val();
+    type_listen(goods_type)
+    // 商品类型选择监听
+    form.on('select(type)', function(data){
+        type_listen(data.value)
+    })
+    function type_listen(val) {
+        $(".goods_type .layui-form-item").hide();
+        $(".type"+val).show();
+        window.form.render();
+    }
+    // 单选按钮
+    var  is_gift = $("#is_gift").val();
+    gift_listen(is_gift);
+    function gift_listen(is_gift){
+        if(is_gift == 1){
+            $(".type4").show();
+        }else{
+            $(".type4").hide();
+        }
+    }
+    form.on('radio(is_gift)', function(data){
+        if($("input[name='is_gift']:checked").val() == 1){
+            $(".type4").show();
+        }else{
+            $(".type4").hide();
+        }
+    })
+
+    // 广告
+    var adv_type = $("#adv_type").val();
+    sel_listen(adv_type)
+    // 分类选择监听
+    form.on('select(adv_type)', function(data){
+        sel_listen(data.value)
+    })
+    function sel_listen(val) {
+        $(".adv_box .layui-form-item").hide();
+        $(".adv_box"+val).show();
+        window.form.render();
+    }
+
+    //mp3上传
+    $(document).on("click",'.up_img',function () {
+        $(this).siblings('[name="file"]').click();
+    })
+
+    function upload_img(e,k) {
+        var file = e.files[0]; //获取图片资源
+        var fileTypes = ['mp3'];
+        var bTypeMatch = false
+        for (var i = 0; i < fileTypes.length; i++) {
+            var start = file.name.lastIndexOf(".");
+            var fileType = file.name.substring(start + 1);
+            if (fileType.toLowerCase() == fileTypes[i]) {
+                bTypeMatch = true;
+                break;
+            }
+        }
+        if (bTypeMatch) {
+            if (file.size <= 1024 * 1024 * 50) {
+                var farmData = new FormData();
+                farmData.append("file", file)
+                $.ajax("/api/Upload/upload", {
+                    data: farmData,
+                    processData: false,
+                    contentType: false,
+                    dataType: 'json',
+                    type: 'post', //HTTP请求类型
+                    headers: {
+                        'zbtoken': localStorage.getItem("token"),
+                        'enctype': 'multipart/form-data',
+                    },
+                    success: function (data) {
+                        console.log(data)
+                        if(data.code == 1) {
+                            $("#mp3").attr('src',data.data);
+                            $(".audio_box").html($(".audio_box").html());
+                            $("input[name='mp3_url']").attr('value',data.data)
+                            window.form.render();
+                        }
+                        layer.msg(data.msg);
+                    },
+                    error: function (xhr, type, errorThrown) {
+                        console.log(type);
+                    }
+                });
+            } else {
+                alert('仅支持不超过50M的MP3');
+                return false;
+            }
+        } else {
+            alert("格式有误!请上传mp3格式");
+            return false;
+        }
+    }
+
+
+
+</script>
+

+ 39 - 0
application/store/view/goods/hash.html

@@ -0,0 +1,39 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;"  action="{:url('hash')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">铸造数量</span>
+                <input name="number" required type="number" class="layui-input" placeholder="请输铸造数量" value="{$vo.inventory|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='id'}<input type="hidden" name="id" value="{$id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}

+ 96 - 0
application/store/view/goods/index.html

@@ -0,0 +1,96 @@
+{extend name='admin@main'}
+
+{block name="button"}
+<a data-dbclick class="layui-btn layui-btn-sm" data-open='{:url("add")}'>添加藏品</a>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='goods/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>商品名称</th>
+            <th class='text-left nowrap'>封面</th>
+            <th class='text-left nowrap'>售价</th>
+            <th class='text-left nowrap'>库存</th>
+            <th class='text-left nowrap'>剩余库存</th>
+            <th class='text-left nowrap'>铸造数量(成功数/总数)</th>
+            <th class="text-left nowrap">发行时间</th>
+            <th class="text-left nowrap">添加时间</th>
+            <th class="text-left nowrap">状态</th>
+            <th class="text-left nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.name|default=''}</td>
+            <td class='text-left nowrap'>
+                <img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px">
+            </td>
+            <td class='text-left nowrap'>{$vo.price|default=''}</td>
+            <td class='text-left nowrap'>{$vo.inventory|default=''}</td>
+            <td class='text-left nowrap'>{$vo.now_inventory|default=''}</td>
+            <td class='text-left nowrap'>{$vo.zz|default=''}/{$vo.casting_num|default=''}</td>
+            <td class='text-left nowrap'>{$vo.sell_time|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+            <td class='text-left nowrap'>
+                {if $vo.status eq 0}已下架{else/}
+                {eq name='vo.state' value='1'}抢购中{/eq}
+                {eq name='vo.state' value='2'}即将开售{/eq}
+                {eq name='vo.state' value='3'}已售罄{/eq}
+                {/if}
+            </td>
+            <td class='text-left nowrap'>
+                <a data-title="铸造明细" class="layui-btn layui-btn-sm" data-open='{:url("detail")}?id={$vo.id}'>铸造明细</a>
+                <a data-title="赠送" class="layui-btn layui-btn-sm" data-modal='{:url("send")}?id={$vo.id}'>赠送</a>
+                <a data-title="铸造" class="layui-btn layui-btn-sm" data-modal='{:url("hash")}?id={$vo.id}'>铸造</a>
+                {if $vo.is_save eq 1}
+                <a data-title="编辑商品" class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {/if}
+                {if $vo.status eq 1}
+                <span class="layui-btn layui-btn-sm layui-btn-warm"   onclick="btn_confirm('下架','down','{$vo.id}');">下 架</span>
+                {else}
+                <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('上架','up','{$vo.id}');">上 架</span>
+                {/if}
+
+                <span data-title="删除商品" class="layui-btn layui-btn-sm layui-btn-danger"   onclick="btn_confirm('删除','del','{$vo.id}');" >删 除</span>
+
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 16 - 0
application/store/view/goods/index_search.html

@@ -0,0 +1,16 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">藏品名称</label>
+            <div class="layui-input-inline">
+                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入藏品名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 52 - 0
application/store/view/goods/send.html

@@ -0,0 +1,52 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;"  action="{:url('send')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-row margin-bottom-15">
+            <label class=" relative">
+                <label class="layui-col-xs10">
+                    <span class="color-green">选择用户</span>
+                    <select class="layui-select" required name="mid" lay-search>
+                        <option selected value="">请选择用户</option>
+                        {foreach $user as $v}
+                          <option value="{$v.id}">{$v.name|default=''}({$v.phone})</option>
+                        {/foreach}
+                    </select>
+                </label>
+            </label>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">赠送数量</span>
+                <input name="number" required type="number" class="layui-input" placeholder="请输赠送数量" value="{$vo.inventory|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='id'}<input type="hidden" name="id" value="{$id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}

+ 115 - 0
application/store/view/integral_goods/form.html

@@ -0,0 +1,115 @@
+
+<link rel="stylesheet" href="/static/plugs/layui/css/layui.css"  media="all">
+
+<style>
+    .layui-form-item {
+        width: 80%;
+        height: 90%;
+    }
+
+</style>
+
+<div class="think-box-shadow" style="height: 100%">
+    <form class="layui-form layui-card" id="subForm" action="{:request()->url()}"  data-auto="true" method="post" autocomplete="off">
+        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
+            <legend>商品编辑</legend>
+        </fieldset>
+        <div class="layui-tab">
+            <ul class="layui-tab-title">
+                <li class="layui-this">基础设置</li>
+            </ul>
+            <div class="layui-tab-content">
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品名称</label>
+                        <div class="layui-input-block">
+                            <input name="name" lay-verify="required" maxlength="50"  value='{$vo.name|default=""}' placeholder="请输入商品名称" class="layui-input">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品简介</label>
+                        <div class="layui-input-block">
+                            <input name="desc" maxlength="50"  value='{$vo.desc|default=""}' placeholder="请输入商品简介" class="layui-input">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品分类</label>
+                        <div class="layui-input-inline">
+                            <select name="first_classify" lay-filter ="first_classify">
+                                <option value="0">请选择</option>
+                                {if !empty($goods_cate)}
+                                    {foreach $goods_cate as $ck=>$cv}
+                                        {if !empty($vo.first_classify) &&  $vo.first_classify == $cv['id'] }
+                                            <option selected data-cl_key="{$ck}" value="{$cv['id']}">{$cv['title']}</option>
+                                        {else}
+                                            <option data-cl_key="{$ck}" value="{$cv['id']}">{$cv['title']}</option>
+                                        {/if}
+                                    {/foreach}
+                                {/if}
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品封面</label>
+                        <div class="layui-input-block">
+                            <input name="cover" type="hidden" value="{$vo.cover|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">元石</label>
+                        <div class="layui-input-block">
+                            <input name="crystal" type="number" step="1" class="layui-input"  value="{$vo.crystal|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">库存</label>
+                        <div class="layui-input-block">
+                            <input name="stock"type="number" step="1" class="layui-input"  value="{$vo.stock|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">详情</label>
+                        <div class="layui-input-block">
+                            <textarea name="detail">{$vo.detail|default=""}</textarea>
+                        </div>
+                    </div>
+
+                    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+                    <div class="layui-form-item text-center">
+                        <span class="layui-btn" type='submit' id ="submit">保 存</span>
+                        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定取消编辑吗?" data-close>取消编辑</button>
+                    </div>
+            </div>
+        </div>
+    </form>
+</div>
+<script src="/static/plugs/layui/layui.all.js" charset="utf-8"></script>
+<script>
+    window.form.render();
+
+    require(['ckeditor', 'angular'], function () {
+        window.createEditor('[name="detail"]', {height: 500,width:1000});
+    })
+
+    $('[name="cover"]').uploadOneImage();
+
+    /**
+     * 表单验证
+     */
+    $(document).on('click','#submit',function () {
+        if($('#submit').hasClass('is_sub')) {
+            return false;
+        }
+        $('#submit').addClass('is_sub');
+        $("#subForm").submit();
+    })
+
+
+</script>

+ 108 - 0
application/store/view/integral_goods/index.html

@@ -0,0 +1,108 @@
+{extend name='admin@main'}
+
+{block name="button"}
+    <a data-open='{:url("add")}'   data-title="添加商品" class='layui-btn layui-btn-sm layui-btn-primary'>添加商品</a>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='integral_goods/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'>
+                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
+            </th>
+            <th class='list-table-sort-td'>
+                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
+            </th>
+            <th class='text-left nowrap'>商品名称</th>
+            <th class='text-left nowrap'>封面</th>
+            <th class='text-left nowrap'>元石</th>
+            <th class='text-left nowrap'>库存</th>
+            <th class="text-center">添加时间</th>
+            <th class="text-center">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'>
+                <input class="list-check-box" value='{$vo.id}' type='checkbox'>
+            </td>
+            <td class='list-table-sort-td'>
+                <input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input">
+            </td>
+            <td class='text-left nowrap'>
+                {$vo.name|default=''}
+            </td>
+
+            <td class='text-left nowrap'>
+                <img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px">
+            </td>
+
+            <td class='text-left nowrap'>
+                {$vo.crystal|default=''}
+            </td>
+            <td class='text-left nowrap'>
+                {$vo.stock|default=''}
+            </td>
+
+            <td class='text-center nowrap'>{$vo.create_at|format_datetime}</td>
+            <td class='text-center nowrap'>
+                <a data-title="编辑商品" class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {if $vo.status eq 1}
+                <span class="layui-btn layui-btn-sm layui-btn-warm"   onclick="btn_confirm('下架','down','{$vo.id}');">下 架</span>
+                {else}
+                <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('上架','up','{$vo.id}');">上 架</span>
+                {/if}
+                <span data-title="删除商品" class="layui-btn layui-btn-sm layui-btn-danger"   onclick="btn_confirm('删除','del','{$vo.id}');" >删 除</span>
+
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+    $('.video_player').click(function () {
+        vUrl = $(this).data('src');  //获取到播放的url
+        var loadstr = '<video width="100%" height="100%"  controls="controls" autobuffer="autobuffer"  autoplay="autoplay" loop="loop">' +
+            '<source src='+vUrl+' type="video/mp4"></source></video>';
+        layer.open({
+            type: 1,
+            title: false,
+            area: ['730px', '500px'],
+            shade: [0.8, 'rgb(14, 16, 22)'],
+            skin: 'demo-class',
+            content: loadstr
+        });
+    });
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/integral_goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 16 - 0
application/store/view/integral_goods/index_search.html

@@ -0,0 +1,16 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">商品名称</label>
+            <div class="layui-input-inline">
+                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入商品名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 39 - 0
application/store/view/message/form.html

@@ -0,0 +1,39 @@
+<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+    <div class="layui-card-body">
+
+
+        <div class="layui-row margin-bottom-15">
+            <label class="layui-col-xs2 think-form-label">标题</label>
+            <label class="layui-col-xs10">
+                <input name="title" required value='{$vo.title|default=""}' placeholder="请输入标题" class="layui-input">
+            </label>
+        </div>
+
+
+        <div class="layui-form-item">
+            <label class="layui-col-xs2 think-form-label">内容</label>
+            <label class="layui-col-xs10">
+                <textarea placeholder="请输入内容" required class="layui-textarea" name="content">{$vo.content|default=""}</textarea>
+            </label>
+        </div>
+
+
+    </div>
+
+    <div class="hr-line-dashed"></div>
+    <div class="layui-form-item text-center">
+        <input type='hidden' value="<?php echo date('Y-m-d H:i:s'); ?>" name='create_at'>
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <button class="layui-btn" type='submit'>保存数据</button>
+        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
+    </div>
+</form>
+<script>
+    window.form.render();
+    require(['ckeditor', 'angular'], function () {
+        window.createEditor('[name="answer"]', {height: 300});
+        var app = angular.module("GoodsForm", []).run(callback);
+        angular.bootstrap(document.getElementById(app.name), [app.name]);
+
+    })
+</script>

+ 60 - 0
application/store/view/message/index.html

@@ -0,0 +1,60 @@
+{extend name='admin@main'}
+
+{block name="button"}
+{if auth("store/message/add")}
+<button data-modal='{:url("add")}' data-title="添加消息" class='layui-btn layui-btn-sm layui-btn-primary'>添加</button>
+{/if}
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='message/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>标题</th>
+            <th class='text-left nowrap' width="50%">内容</th>
+            <th class="text-left">时间</th>
+            <th></th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='text-left nowrap'>
+                {$vo.title|default=''}
+            </td>
+            <td class='text-left' style="width: 50%">
+                {$vo.content|default=''}
+            </td>
+
+            <td class='text-left nowrap'>{$vo.create_at|default='--'}</td>
+            <td class='text-left nowrap'>
+
+                {if auth("store/message/edit")}
+                <a data-title="编辑消息" class="layui-btn layui-btn-sm" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {/if}
+                {if auth("store/message/del")}
+                <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除数据吗?" data-action="{:url('del')}" data-value="id#{$vo.id}">删 除</a>
+                {/if}
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+        function tankuang(url){
+            var loadstr = '<video width="100%" height="100%"  controls="controls" autobuffer="autobuffer"  autoplay="autoplay" loop="loop"><source src="'+ url +'" type="video/mp4"></source></video>'
+            layer.open({
+                type: 1,
+                title: '播放视频',
+                content: loadstr,
+            });
+        }
+</script>
+{/block}
+

+ 23 - 0
application/store/view/message/index_search.html

@@ -0,0 +1,23 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">标题</label>
+            <div class="layui-input-inline">
+                <input name="title" value="{$Think.get.title|default=''}" placeholder="请输入关键词" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">内容</label>
+            <div class="layui-input-inline">
+                <input name="content" value="{$Think.get.content|default=''}" placeholder="请输入关键词" class="layui-input">
+            </div>
+        </div>
+
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>