Explorar el Código

Merge branch 'master' of http://git.liuniu946.com/Kirin/mccs

cmy hace 2 años
padre
commit
50b0050597

+ 1 - 1
app/admin/controller/AdminException.php

@@ -28,7 +28,7 @@ class AdminException extends Handle
             return app('json')->make(422, $e->getError());
         }
         if ($e instanceof \Exception && request()->isAjax()) {
-            return app('json')->fail($e->getMessage(), ['code' => $e->getCode(), 'line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile()]);
+            return app('json')->fail($e->getMessage(), ['code' => $e->getCode(), 'line' => $e->getLine(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'trace' => $e->getTrace()]);
         }
 
         return parent::render($request, $e);

+ 73 - 88
app/admin/controller/store/Placeorder.php

@@ -43,16 +43,13 @@ class Placeorder extends AuthController
     public function index()
     {
         $store = [];
-        if($this->adminInfo['type']==0)
-        {
-            $store = SystemStore::where('is_del',0)->where('is_show',1)->field('id,name')->select()->toArray();
-        }
-        else
-        {
-            $store = SystemStore::where('id',$this->adminInfo['store_id'])->field('id,name')->select();
+        if ($this->adminInfo['type'] == 0) {
+            $store = SystemStore::where('is_del', 0)->where('is_show', 1)->field('id,name')->select()->toArray();
+        } else {
+            $store = SystemStore::where('id', $this->adminInfo['store_id'])->field('id,name')->select();
         }
-        $this->assign('store',$store);
-        $this->assign('type',$this->adminInfo['type']);
+        $this->assign('store', $store);
+        $this->assign('type', $this->adminInfo['type']);
         return $this->fetch();
     }
 
@@ -62,31 +59,26 @@ class Placeorder extends AuthController
      */
     public function getCardNo($card_no)
     {
-        if($card_no=='') return app('json')->fail('会员码不能为空');
-        if(intval($card_no)==1)
-        {
+        if ($card_no == '') return app('json')->fail('会员码不能为空');
+        if (intval($card_no) == 1) {
             $info['user'] = User::where('uid', $card_no)->field("uid,real_name,addres , phone, '' as nickname, now_money,integral")->find();
             $info['uid'] = $info['user']['uid'];
             return app('json')->successful($info);
         }
-        if(strlen($card_no) == 15)
-        {
-            $info = CardInfo::where(['type'=>1,'card_number'=>$card_no])->find();
-            if(!$info) return app('json')->fail('充值卡号不存在');
-            if($info['use_uid']==0) return app('json')->fail('充值卡未激活');
+        if (strlen($card_no) == 15) {
+            $info = CardInfo::where(['type' => 1, 'card_number' => $card_no])->find();
+            if (!$info) return app('json')->fail('充值卡号不存在');
+            if ($info['use_uid'] == 0) return app('json')->fail('充值卡未激活');
             $info['user'] = User::where('uid', $info['use_uid'])->field('uid,real_name,addres,phone,nickname,now_money,integral')->find();
             $info['uid'] = $info['user']['uid'];
             return app('json')->successful($info);
         }
-        if(strlen($card_no) == 8 || strlen($card_no)==11)
-        {
-            if(!User::where('SN|phone', $card_no)->find()) return app('json')->fail('会员码不存在');
+        if (strlen($card_no) == 8 || strlen($card_no) == 11) {
+            if (!User::where('SN|phone', $card_no)->find()) return app('json')->fail('会员码不存在');
             $info['user'] = User::where('SN|phone', $card_no)->field('uid,real_name,addres,phone,nickname,now_money,integral')->find();
             $info['uid'] = $info['user']['uid'];
-        }
-        else
-        {
-            if(!SystemStoreMember::be(['card_no'=>$card_no])) return app('json')->fail('会员码不存在');
+        } else {
+            if (!SystemStoreMember::be(['card_no' => $card_no])) return app('json')->fail('会员码不存在');
             $info = SystemStoreMember::where('card_no', $card_no)->find()->toArray();
             $info['user'] = User::where('uid', $info['uid'])->field('real_name,addres,phone,nickname,now_money,integral')->find();
         }
@@ -101,24 +93,18 @@ class Placeorder extends AuthController
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getBarCode($bar_code='')
+    public function getBarCode($bar_code = '')
     {
-        if($bar_code=='') return $this->failed('条形码不存在');
-        $info =  SystemStoreStock::alias('a')->join("StoreProduct b","a.product_id=b.id","left")->where('a.bar_code',$bar_code)->field('a.price,a.unique,a.in_stock,a.is_consumer,a.product_id,b.store_name,b.image')->find();
-        if($info)
-        {
-           $info = $info->toArray();
-           $info['suk'] = StoreProductAttrValue::where('unique',$info['unique'])->value('suk');
-        }
-        else
-        {
-            $info =  StoreProductAttrValue::alias('a')->join("StoreProduct b","a.product_id=b.id","left")->where('a.bar_code',$bar_code)->field('a.price,a.unique,0 as in_stock,b.is_consumer,a.product_id,b.store_name,b.image')->find();
-            if($info)
-            {
+        if ($bar_code == '') return $this->failed('条形码不存在');
+        $info = SystemStoreStock::alias('a')->join("StoreProduct b", "a.product_id=b.id", "left")->where('a.bar_code', $bar_code)->field('a.price,a.unique,a.in_stock,a.is_consumer,a.product_id,b.store_name,b.image')->find();
+        if ($info) {
+            $info = $info->toArray();
+            $info['suk'] = StoreProductAttrValue::where('unique', $info['unique'])->value('suk');
+        } else {
+            $info = StoreProductAttrValue::alias('a')->join("StoreProduct b", "a.product_id=b.id", "left")->where('a.bar_code', $bar_code)->where('a.type', 0)->field('a.price,a.unique,0 as in_stock,b.is_consumer,a.product_id,b.store_name,b.image')->find();
+            if ($info) {
                 $info = $info->toArray();
-            }
-            else
-            {
+            } else {
                 $info = [];
             }
         }
@@ -132,17 +118,17 @@ class Placeorder extends AuthController
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function  add_cart()
+    public function add_cart()
     {
-        list($productId, $cartNum, $uniqueId, $combinationId, $secKillId, $bargainId, $new,$uid) = UtilService::postMore([
-            ['productId',0],//普通产品编号
-            ['cartNum',1], //购物车数量
-            ['uniqueId',''],//属性唯一值
-            ['combinationId',0],//拼团产品编号
-            ['secKillId',0],//秒杀产品编号
-            ['bargainId',0],//砍价产品编号
-            ['new',1], // 1 加入购物车直接购买  0 加入购物车
-            ['uid',0],//用户编号
+        list($productId, $cartNum, $uniqueId, $combinationId, $secKillId, $bargainId, $new, $uid) = UtilService::postMore([
+            ['productId', 0],//普通产品编号
+            ['cartNum', 1], //购物车数量
+            ['uniqueId', ''],//属性唯一值
+            ['combinationId', 0],//拼团产品编号
+            ['secKillId', 0],//秒杀产品编号
+            ['bargainId', 0],//砍价产品编号
+            ['new', 1], // 1 加入购物车直接购买  0 加入购物车
+            ['uid', 0],//用户编号
         ], $this->request, true);
         $request = $this->request;
         if (!$productId || !is_numeric($productId)) return app('json')->fail('参数错误');
@@ -160,10 +146,10 @@ class Placeorder extends AuthController
     public function clear_cart()
     {
         list($uid) = UtilService::postMore([
-            ['uid',0],//用户编号
+            ['uid', 0],//用户编号
         ], $this->request, true);
         $is_pay = 0;
-        StoreCart::where(compact('uid','is_pay'))->delete();
+        StoreCart::where(compact('uid', 'is_pay'))->delete();
         return app('json')->successful('清空完成!');
     }
 
@@ -174,16 +160,17 @@ class Placeorder extends AuthController
      */
     public function del(Request $request)
     {
-        list($ids,$uid) = UtilService::postMore([
-            ['ids',[]],//购物车编号
-            ['uid',0],
+        list($ids, $uid) = UtilService::postMore([
+            ['ids', []],//购物车编号
+            ['uid', 0],
         ], $request, true);
         if (!count($ids))
             return app('json')->fail('参数错误!');
-        if(StoreCart::removeUserCart($uid, $ids))
+        if (StoreCart::removeUserCart($uid, $ids))
             return app('json')->successful();
         return app('json')->fail('清除失败!');
     }
+
     /**
      * 购物车 修改产品数量
      * @param Request $request
@@ -195,14 +182,14 @@ class Placeorder extends AuthController
      */
     public function num(Request $request)
     {
-        list($id, $number,$uid) = UtilService::postMore([
-            ['id',0],//购物车编号
-            ['number',0],//购物车编号
-            ['uid',0],
+        list($id, $number, $uid) = UtilService::postMore([
+            ['id', 0],//购物车编号
+            ['number', 0],//购物车编号
+            ['uid', 0],
         ], $request, true);
         if (!$id || !$number || !is_numeric($id) || !is_numeric($number)) return app('json')->fail('参数错误!');
         $res = StoreCart::changeUserCartNum($id, $number, $uid);
-        if ($res)  return app('json')->successful();
+        if ($res) return app('json')->successful();
         else return app('json')->fail(StoreCart::getErrorInfo('修改失败'));
     }
 
@@ -221,7 +208,7 @@ class Placeorder extends AuthController
         if (!$temp) return app('json')->fail('默认模板未配置,无法下单');
         list($cartId) = UtilService::postMore(['cartId'], $request, true);
         if (!is_string($cartId) || !$cartId) return app('json')->fail('请提交购买的商品');
-        $uid = input('uid',0);
+        $uid = input('uid', 0);
         $cartGroup = StoreCart::getUserProductCartList($uid, $cartId, 1);
         if (count($cartGroup['invalid'])) return app('json')->fail($cartGroup['invalid'][0]['productInfo']['store_name'] . '已失效!');
         if (!$cartGroup['valid']) return app('json')->fail('请提交购买的商品');
@@ -271,6 +258,7 @@ class Placeorder extends AuthController
         $data['system_store'] = ($res = \app\models\system\SystemStore::getStoreDispose()) ? $res : [];//门店信息
         return app('json')->successful($data);
     }
+
     /**
      * 计算订单金额
      * @param Request $request
@@ -285,8 +273,8 @@ class Placeorder extends AuthController
     {
 
         $request = $this->request;
-        $uid = input('uid',0);
-        if (!$key) return app('json')->fail('参数错误!');      
+        $uid = input('uid', 0);
+        if (!$key) return app('json')->fail('参数错误!');
         if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
         list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type) = UtilService::postMore([
@@ -304,8 +292,8 @@ class Placeorder extends AuthController
             StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
         }
         if ($pinkId) {
-            $cache_pink = Cache::get(md5('store_pink_'.$pinkId));
-            if($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0){
+            $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
+            if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
                 return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
             }
             if (StorePink::getIsPinkUid($pinkId, $uid))
@@ -319,6 +307,7 @@ class Placeorder extends AuthController
         else
             return app('json')->fail(StoreOrder::getErrorInfo('计算失败'));
     }
+
     /**
      * 订单创建
      * @param Request $request
@@ -332,16 +321,16 @@ class Placeorder extends AuthController
     public function create($key)
     {
         $request = $this->request;
-        $uid = input('uid',0);
-        if (!$key) return app('json')->fail('参数错误!');      
+        $uid = input('uid', 0);
+        if (!$key) return app('json')->fail('参数错误!');
         if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
-        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId,$auth_code) = UtilService::postMore([
+        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId, $auth_code) = UtilService::postMore([
             'addressId', 'couponId', 'payType', ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''], ['from', 'weixin'],
-            ['shipping_type', 1], ['real_name', '散户'], ['phone', '18700010001'], ['store_id', 0],['auth_code',''],
+            ['shipping_type', 1], ['real_name', '散户'], ['phone', '18700010001'], ['store_id', 0], ['auth_code', ''],
         ], $request, true);
-        if(empty($real_name))$real_name='散户';
-        if(empty($phone))$phone='18700010001';
+        if (empty($real_name)) $real_name = '散户';
+        if (empty($phone)) $phone = '18700010001';
         $payType = strtolower($payType);
         if ($bargainId) {
             $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
@@ -353,8 +342,8 @@ class Placeorder extends AuthController
             StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
         }
         if ($pinkId) {
-            $cache_pink = Cache::get(md5('store_pink_'.$pinkId));
-            if($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0){
+            $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
+            if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
                 return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
             }
             if (StorePink::getIsPinkUid($pinkId, $uid))
@@ -393,7 +382,7 @@ class Placeorder extends AuthController
                     } else {
                         try {
 
-                                $jsConfig = OrderRepository::barcodePay($orderId,$auth_code); //创建订单jspay
+                            $jsConfig = OrderRepository::barcodePay($orderId, $auth_code); //创建订单jspay
 
                         } catch (\Exception $e) {
                             return app('json')->status('pay_error', $e->getMessage(), $info);
@@ -411,8 +400,7 @@ class Placeorder extends AuthController
                         $orderInfo = StoreOrder::where('order_id', $orderId)->find();
                         $this->verify($orderInfo['id']);
                         return app('json')->status('success', '余额支付成功', $info);
-                    }
-                    else {
+                    } else {
                         $errorinfo = StoreOrder::getErrorInfo();
                         if (is_array($errorinfo))
                             return app('json')->status($errorinfo['status'], $errorinfo['msg'], $info);
@@ -431,18 +419,13 @@ class Placeorder extends AuthController
                     if (!$orderInfo || !isset($orderInfo['paid'])) return app('json')->fail('支付订单不存在!');
                     $orderInfo = $orderInfo->toArray();
                     if ($orderInfo['paid']) return app('json')->fail('支付已支付!');
-                    $rs  = OrderRepository::jialiePay($orderId,$auth_code); //支付结果
-                    if($rs['ret_code']=="00" && $rs['status']=="2")
-                    {
+                    $rs = OrderRepository::jialiePay($orderId, $auth_code); //支付结果
+                    if ($rs['ret_code'] == "00" && $rs['status'] == "2") {
                         $this->verify($orderInfo['id']);
-                        StoreOrder::paySuccess($orderId,'jialie');
-                    }
-                    elseif($rs['ret_code']=="00" && $rs['status']==1)
-                    {
-                        StoreOrder::edit(['jialie_do'=>1],$orderInfo['id']);
-                    }
-                    else
-                    {
+                        StoreOrder::paySuccess($orderId, 'jialie');
+                    } elseif ($rs['ret_code'] == "00" && $rs['status'] == 1) {
+                        StoreOrder::edit(['jialie_do' => 1], $orderInfo['id']);
+                    } else {
                         return app('json')->fail($rs['ret_msg']);
                     }
                     return app('json')->status('success', '订单创建成功', $info);
@@ -450,6 +433,7 @@ class Placeorder extends AuthController
             }
         } else return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败!'));
     }
+
     public function verify($id)
     {
         StoreOrderModel::beginTrans();
@@ -469,6 +453,7 @@ class Placeorder extends AuthController
             return false;
         }
     }
+
     /**
      * 立即支付
      * @param $id

+ 24 - 12
app/admin/controller/store/StoreProduct.php

@@ -22,9 +22,7 @@ use crmeb\services\{
 };
 use crmeb\traits\CurdControllerTrait;
 use think\facade\Route as Url;
-use app\admin\model\system\{
-    SystemAttachment, ShippingTemplates
-};
+use app\admin\model\system\{SystemAttachment, ShippingTemplates, SystemStore};
 
 
 /**
@@ -39,6 +37,20 @@ class StoreProduct extends AuthController
 
     protected $bindModel = ProductModel::class;
 
+    protected $store;
+
+    protected $main_where = [];
+
+    public function initialize()
+    {
+        parent::initialize(); // TODO: Change the autogenerated stub
+        $store_id = $this->adminInfo['store_id'];
+        $this->store = SystemStore::where('id', $store_id)->find();
+        if ($this->store && $this->store['is_triple']) {
+            $this->main_where['store_id'] = $store_id;
+        }
+    }
+
     /**
      * 显示资源列表
      *
@@ -50,17 +62,17 @@ class StoreProduct extends AuthController
         //获取分类
         $this->assign('cate', CategoryModel::getTierList(null, 1));
         //出售中产品
-        $onsale = ProductModel::where('is_del', 0)->where('is_consumer', 0)->where('is_show', 1)->count();
+        $onsale = ProductModel::where('is_del', 0)->where($this->main_where)->where('is_consumer', 0)->where('is_show', 1)->count();
         //待上架产品
-        $forsale = ProductModel::where('is_del', 0)->where('is_consumer', 0)->where('is_show', 0)->count();
+        $forsale = ProductModel::where('is_del', 0)->where($this->main_where)->where('is_consumer', 0)->where('is_show', 0)->count();
         //仓库中产品
-        $warehouse = ProductModel::where('is_del', 0)->where('is_consumer', 0)->count();
+        $warehouse = ProductModel::where('is_del', 0)->where($this->main_where)->where('is_consumer', 0)->count();
         //已经售馨产品
-        $outofstock = ProductModel::getModelObject(['type' => 4])->where('is_consumer', 0)->count();
+        $outofstock = ProductModel::getModelObject(['type' => 4])->where($this->main_where)->where('is_consumer', 0)->count();
         //警戒库存
-        $policeforce = ProductModel::getModelObject(['type' => 5])->where('is_consumer', 0)->count();
+        $policeforce = ProductModel::getModelObject(['type' => 5])->where($this->main_where)->where('is_consumer', 0)->count();
         //回收站
-        $recycle = ProductModel::where('is_del', 1)->where('is_consumer', 0)->count();
+        $recycle = ProductModel::where('is_del', 1)->where($this->main_where)->where('is_consumer', 0)->count();
         $this->assign(compact('type', 'onsale', 'forsale', 'warehouse', 'outofstock', 'policeforce', 'recycle'));
         return $this->fetch();
     }
@@ -103,7 +115,7 @@ class StoreProduct extends AuthController
             [['type', 'd'], $this->request->param('type/d')],
             ['is_consumer', 0]
         ]);
-        return Json::successlayui(ProductModel::ProductList($where));
+        Json::successlayui(ProductModel::ProductList(array_merge($where, $this->main_where)));
     }
 
     /**
@@ -414,9 +426,9 @@ class StoreProduct extends AuthController
         $info['in_stock'] = $where['in_stock'];
         $info['admin_id'] = $this->adminId;
         if (SystemStockBill::order_create($info)) {
-            return Json::successful('入库成功');
+            return Json::successful('入库审核提交成功');
         } else {
-            return Json::fail('入库失败');
+            return Json::fail('入库审核提交失败');
         }
     }
 

+ 549 - 0
app/admin/controller/store/StoreProductCheck.php

@@ -0,0 +1,549 @@
+<?php
+
+namespace app\admin\controller\store;
+
+use app\admin\controller\AuthController;
+use app\models\store\SystemStockBill;
+use app\models\system\SystemStoreStock;
+use app\admin\model\store\{StoreDescription,
+    StoreProductAttrValue,
+    StoreProductAttr,
+    StoreProductAttrResult,
+    StoreCategory as CategoryModel,
+    StoreProductCate,
+    StoreProductCheck as ProductModel
+};
+use crmeb\services\{JsonService,
+    JsonService as Json,
+    UtilService as Util,
+    FormBuilder as Form,
+    UtilService
+};
+use crmeb\traits\CurdControllerTrait;
+use think\facade\Route as Url;
+use app\admin\model\system\{ShippingTemplates, SystemStore};
+use think\Model;
+
+
+/**
+ * 产品管理
+ * Class StoreProduct
+ * @package app\admin\controller\store
+ */
+class StoreProductCheck extends AuthController
+{
+
+    use CurdControllerTrait;
+
+    protected $bindModel = ProductModel::class;
+
+    protected $store;
+
+    protected $main_where = [];
+
+    public function initialize()
+    {
+        parent::initialize(); // TODO: Change the autogenerated stub
+        $store_id = $this->adminInfo['store_id'];
+        $this->store = SystemStore::where('id', $store_id)->find();
+        if ($this->store && $this->store['is_triple']) {
+            $this->main_where['store_id'] = $store_id;
+        }
+    }
+
+    /**
+     * 显示资源列表
+     *
+     * @return \think\Response
+     */
+    public function index()
+    {
+        $type = $this->request->param('type', 1);
+        //获取分类
+        $this->assign('cate', CategoryModel::getTierList(null, 1));
+        $checking = ProductModel::getModelObject(['type' => 2])->where($this->main_where)->count();
+        $checkok = ProductModel::getModelObject(['type' => 3])->where($this->main_where)->count();
+        $checkno = ProductModel::getModelObject(['type' => 4])->where($this->main_where)->count();
+        $this->assign('user_store', $this->adminInfo['store_id']);
+        $this->assign(compact('type', 'checking', 'checkok', 'checkno'));
+        return $this->fetch();
+    }
+
+
+    /**
+     * 异步查找产品
+     *
+     * @return void
+     */
+    public function product_ist()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['store_name', ''],
+            ['cate_id', ''],
+            ['excel', 0],
+            ['order', ''],
+            [['type', 'd'], $this->request->param('type/d')],
+        ]);
+        Json::successlayui(ProductModel::ProductList($where));
+    }
+
+    /**
+     * 设置单个产品上架|下架
+     *
+     * @return void
+     */
+    public function check($id = '')
+    {
+        ($id == '') && Json::fail('缺少参数');
+        $res = ProductModel::where($this->main_where)->where(['id' => $id])->update(['status' => 0]);
+        if ($res) {
+            Json::successful('提交成功');
+        } else {
+            Json::fail('提交失败');
+        }
+    }
+
+
+    /**
+     * 设置批量产品上架
+     *
+     * @return void
+     */
+    public function take_products()
+    {
+        $post = Util::postMore([
+            ['ids', []]
+        ]);
+        if (empty($post['ids'])) {
+            Json::fail('请选择需要提交的产品');
+        } else {
+            $res = ProductModel::where($this->main_where)->where('id', 'in', $post['ids'])->update(['status' => 0]);
+            if ($res)
+                Json::successful('提交成功');
+            else
+                Json::fail('提交失败');
+        }
+    }
+
+    /**
+     * 显示创建资源表单页.
+     *
+     * @param int $id
+     * @param int $consumer
+     * @return \think\Response
+     * @throws \Exception
+     */
+    public function create($id = 0)
+    {
+        $this->assign('id', (int)$id);
+        return $this->fetch();
+    }
+
+
+    /**
+     * 获取产品详细信息
+     * @param int $id
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function get_product_info($id = 0, $type = 0)
+    {
+        $list = CategoryModel::getTierList(null, 1, $type);
+        $menus = [];
+        foreach ($list as $menu) {
+            $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['cate_name'], 'disabled' => $menu['pid'] == 0 ? 0 : 1];//,'disabled'=>$menu['pid']== 0];
+        }
+        $data['tempList'] = ShippingTemplates::order('sort', 'desc')->field(['id', 'name'])->select()->toArray();
+        $data['cateList'] = $menus;
+        $data['productInfo'] = [];
+        if ($id) {
+            $productInfo = ProductModel::where($this->main_where)->where('id', $id)->find();
+            if (!$productInfo) {
+                return Json::fail('修改的产品不存在');
+            }
+            $productInfo['cate_id'] = explode(',', $productInfo['cate_id']);
+            $productInfo['description'] = htmlspecialchars_decode(StoreDescription::getDescription($id, 8));
+            $productInfo['slider_image'] = is_string($productInfo['slider_image']) ? json_decode($productInfo['slider_image'], true) : [];
+            if ($productInfo['spec_type'] == 1) {
+                $result = StoreProductAttrResult::getResult($id, 8);
+                foreach ($result['value'] as $k => $v) {
+                    $num = 1;
+                    foreach ($v['detail'] as $dv) {
+                        $result['value'][$k]['value' . $num] = $dv;
+                        $num++;
+                    }
+                }
+                $productInfo['items'] = $result['attr'];
+                $productInfo['attrs'] = $result['value'];
+                $productInfo['attr'] = ['pic' => '', 'price' => 0, 'cost' => 0, 'ot_price' => 0, 'stock' => 0, 'bar_code' => '', 'weight' => 0, 'volume' => 0, 'brokerage' => 0, 'brokerage_two' => 0];
+            } else {
+                $result = StoreProductAttrValue::where('product_id', $id)->where('type', 8)->find();
+                if ($result) {
+                    $single = $result->toArray();
+                } else {
+                    $single = [];
+                }
+                $productInfo['items'] = [];
+                $productInfo['attrs'] = [];
+                $productInfo['attr'] = [
+                    'pic' => $single['image'] ?? '',
+                    'price' => $single['price'] ?? 0,
+                    'cost' => $single['cost'] ?? 0,
+                    'ot_price' => $single['ot_price'] ?? 0,
+                    'stock' => $single['stock'] ?? 0,
+                    'bar_code' => $single['bar_code'] ?? '',
+                    'weight' => $single['weight'] ?? 0,
+                    'volume' => $single['volume'] ?? 0,
+                    'brokerage' => $single['brokerage'] ?? 0,
+                    'brokerage_two' => $single['brokerage_two'] ?? 0,
+                ];
+            }
+            if ($productInfo['activity']) {
+                $activity = explode(',', $productInfo['activity']);
+                foreach ($activity as $k => $v) {
+                    if ($v == 1) {
+                        $activity[$k] = '秒杀';
+                    } elseif ($v == 2) {
+                        $activity[$k] = '砍价';
+                    } elseif ($v == 3) {
+                        $activity[$k] = '拼团';
+                    }
+                }
+                $productInfo['activity'] = $activity;
+            } else {
+                $productInfo['activity'] = ['秒杀', '砍价', '拼团'];
+            }
+            $data['productInfo'] = $productInfo;
+        }
+        return JsonService::successful($data);
+    }
+
+    /**
+     * 保存新建的资源
+     *
+     *
+     */
+    public function save($id)
+    {
+//        if (!isset($this->store['is_triple']) || !$this->store['is_triple']) Json::fail('第三方门店专用通道');
+        $data = Util::postMore([
+            ['cate_id', []],
+            'store_name',
+            'store_info',
+            'keyword',
+            ['unit_name', '件'],
+            ['image', []],
+            ['slider_image', []],
+            ['postage', 0],
+            ['is_sub', 0],
+            ['sort', 0],
+            ['sales', 0],
+            ['ficti', 100],
+            ['give_integral', 0],
+            ['max_use_integral', 0],
+            ['is_show', 0],
+            ['temp_id', 0],
+            ['is_hot', 0],
+            ['is_benefit', 0],
+            ['is_suit', 0],
+            ['is_award', 0],
+            ['is_best', 0],
+            ['is_new', 0],
+            ['mer_use', 0],
+            ['is_postage', 0],
+            ['is_good', 0],
+            ['description', ''],
+            ['spec_type', 0],
+            ['video_link', ''],
+            ['items', []],
+            ['attrs', []],
+            ['activity', []],
+            ['is_consumer', 0],
+            ['bar_code', ''],
+        ]);
+        $data['store_id'] = $this->store['id'];
+        foreach ($data['activity'] as $k => $v) {
+            if ($v == '秒杀') {
+                $data['activity'][$k] = 1;
+            } elseif ($v == '砍价') {
+                $data['activity'][$k] = 2;
+            } else {
+                $data['activity'][$k] = 3;
+            }
+        }
+        $data['activity'] = implode(',', $data['activity']);
+        $detail = $data['attrs'];
+        $data['price'] = min(array_column($detail, 'price'));
+        $data['ot_price'] = min(array_column($detail, 'ot_price'));
+        $data['cost'] = min(array_column($detail, 'cost'));
+        $attr = $data['items'];
+        unset($data['items'], $data['video'], $data['attrs']);
+        if (count($data['cate_id']) < 1) return Json::fail('请选择产品分类');
+        $cate_id = $data['cate_id'];
+        $data['cate_id'] = implode(',', $data['cate_id']);
+        if (!$data['store_name']) return Json::fail('请输入产品名称');
+        if (count($data['image']) < 1) return Json::fail('请上传产品图片');
+        if (count($data['slider_image']) < 1) return Json::fail('请上传产品轮播图');
+        $data['image'] = $data['image'][0];
+        $data['slider_image'] = json_encode($data['slider_image']);
+        $data['stock'] = array_sum(array_column($detail, 'stock'));
+        ProductModel::beginTrans();
+        foreach ($detail as &$item) {
+            if (($item['brokerage'] + $item['brokerage_two']) > $item['price']) {
+                return Json::fail('一二级返佣相加不能大于商品售价');
+            }
+        }
+        if ($id) {
+            $info = ProductModel::get($id);
+            if ($info['status'] != 2) $data['status'] = 0;
+            unset($data['sales']);
+            ProductModel::edit($data, $id);
+            $description = $data['description'];
+            unset($data['description']);
+            StoreDescription::saveDescription($description, $id, 8);
+            if ($data['spec_type'] == 0) {
+                $attr = [
+                    [
+                        'value' => '规格',
+                        'detailValue' => '',
+                        'attrHidden' => '',
+                        'detail' => ['默认']
+                    ]
+                ];
+                $detail[0]['value1'] = '规格';
+                $detail[0]['detail'] = ['规格' => '默认'];
+            }
+
+            $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $id, 8);
+            if ($attr_res) {
+                ProductModel::commitTrans();
+                return Json::success('修改成功!');
+            } else {
+                ProductModel::rollbackTrans();
+                return Json::fail(StoreProductAttr::getErrorInfo());
+            }
+        } else {
+            $data['add_time'] = time();
+            $data['code_path'] = '';
+            $data['status'] = 0;
+            $res = ProductModel::create($data);
+            $description = $data['description'];
+            StoreDescription::saveDescription($description, $res['id'], 8);
+            if ($data['spec_type'] == 0) {
+                $attr = [
+                    [
+                        'value' => '规格',
+                        'detailValue' => '',
+                        'attrHidden' => '',
+                        'detail' => ['默认']
+                    ]
+                ];
+                $detail[0]['value1'] = '规格';
+                $detail[0]['detail'] = ['规格' => '默认'];
+            }
+            $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $res['id'], 8);
+            if ($attr_res) {
+                ProductModel::commitTrans();
+                return Json::success('添加产品成功!');
+            } else {
+                ProductModel::rollbackTrans();
+                return Json::fail(StoreProductAttr::getErrorInfo());
+            }
+        }
+    }
+
+    public function attr_save()
+    {
+        $where = Util::getMore([
+            ['bar_code', 20],
+            ['in_stock', 0],
+        ]);
+        if ($where['in_stock'] < 1) return app('json')->fail('补货数量不能少于1');
+        $info = StoreProductAttrValue::alias('a')->join("StoreProduct b", "a.product_id=b.id", "left")->where('a.bar_code', $where['bar_code'])->field('a.price,a.unique,a.stock as in_stock,a.product_id,b.store_name,b.image,a.bar_code')->find();
+        if (!$info) return app('json')->fail('商品条形码不存在');
+        $info = $info->toarray();
+        $info['in_stock'] = $where['in_stock'];
+        $info['admin_id'] = $this->adminId;
+        if (SystemStockBill::order_create($info)) {
+            return Json::successful('入库成功');
+        } else {
+            return Json::fail('入库失败');
+        }
+    }
+
+    /**
+     * 生成属性
+     * @param int $id
+     */
+    public function is_format_attr($id = 0, $type = 0)
+    {
+        $data = Util::postMore([
+            ['attrs', []],
+            ['items', []]
+        ]);
+        $attr = $data['attrs'];
+        $value = attr_format($attr)[1];
+        $valueNew = [];
+        $count = 0;
+        foreach ($value as $key => $item) {
+            $detail = $item['detail'];
+            sort($item['detail'], SORT_STRING);
+            $suk = implode(',', $item['detail']);
+            $types = 1;
+            if ($id) {
+                $sukValue = StoreProductAttrValue::where('product_id', $id)->where('type', 8)->where('suk', $suk)->column('bar_code,cost,price,ot_price,stock,image as pic,weight,volume,brokerage,brokerage_two', 'suk');
+                if (!count($sukValue)) {
+                    if ($type == 0) $types = 0; //编辑商品时,将没有规格的数据不生成默认值
+                    $sukValue[$suk]['pic'] = '';
+                    $sukValue[$suk]['price'] = 0;
+                    $sukValue[$suk]['cost'] = 0;
+                    $sukValue[$suk]['ot_price'] = 0;
+                    $sukValue[$suk]['stock'] = 0;
+                    $sukValue[$suk]['bar_code'] = '';
+                    $sukValue[$suk]['weight'] = 0;
+                    $sukValue[$suk]['volume'] = 0;
+                    $sukValue[$suk]['brokerage'] = 0;
+                    $sukValue[$suk]['brokerage_two'] = 0;
+                }
+            } else {
+                $sukValue[$suk]['pic'] = '';
+                $sukValue[$suk]['price'] = 0;
+                $sukValue[$suk]['cost'] = 0;
+                $sukValue[$suk]['ot_price'] = 0;
+                $sukValue[$suk]['stock'] = 0;
+                $sukValue[$suk]['bar_code'] = '';
+                $sukValue[$suk]['weight'] = 0;
+                $sukValue[$suk]['volume'] = 0;
+                $sukValue[$suk]['brokerage'] = 0;
+                $sukValue[$suk]['brokerage_two'] = 0;
+            }
+            if ($types) { //编辑商品时,将没有规格的数据不生成默认值
+                foreach (array_keys($detail) as $k => $title) {
+                    $header[$k]['title'] = $title;
+                    $header[$k]['align'] = 'center';
+                    $header[$k]['minWidth'] = 130;
+                }
+                foreach (array_values($detail) as $k => $v) {
+                    $valueNew[$count]['value' . ($k + 1)] = $v;
+                    $header[$k]['key'] = 'value' . ($k + 1);
+                }
+                $valueNew[$count]['detail'] = $detail;
+                $valueNew[$count]['pic'] = $sukValue[$suk]['pic'] ?? '';
+                $valueNew[$count]['price'] = $sukValue[$suk]['price'] ? floatval($sukValue[$suk]['price']) : 0;
+                $valueNew[$count]['cost'] = $sukValue[$suk]['cost'] ? floatval($sukValue[$suk]['cost']) : 0;
+                $valueNew[$count]['ot_price'] = isset($sukValue[$suk]['ot_price']) ? floatval($sukValue[$suk]['ot_price']) : 0;
+                $valueNew[$count]['stock'] = $sukValue[$suk]['stock'] ? intval($sukValue[$suk]['stock']) : 0;
+                $valueNew[$count]['bar_code'] = $sukValue[$suk]['bar_code'] ?? '';
+                $valueNew[$count]['weight'] = $sukValue[$suk]['weight'] ?? 0;
+                $valueNew[$count]['volume'] = $sukValue[$suk]['volume'] ?? 0;
+                $valueNew[$count]['brokerage'] = $sukValue[$suk]['brokerage'] ?? 0;
+                $valueNew[$count]['brokerage_two'] = $sukValue[$suk]['brokerage_two'] ?? 0;
+                $count++;
+            }
+        }
+        $header[] = ['title' => '图片', 'slot' => 'pic', 'align' => 'center', 'minWidth' => 80];
+        $header[] = ['title' => '售价', 'slot' => 'price', 'align' => 'center', 'minWidth' => 120];
+        $header[] = ['title' => '成本价', 'slot' => 'cost', 'align' => 'center', 'minWidth' => 140];
+        $header[] = ['title' => '原价', 'slot' => 'ot_price', 'align' => 'center', 'minWidth' => 140];
+        $header[] = ['title' => '库存', 'slot' => 'stock', 'align' => 'center', 'minWidth' => 140];
+        $header[] = ['title' => '产品编号', 'slot' => 'bar_code', 'align' => 'center', 'minWidth' => 140];
+        $header[] = ['title' => '重量(KG)', 'slot' => 'weight', 'align' => 'center', 'minWidth' => 140];
+        $header[] = ['title' => '体积(m³)', 'slot' => 'volume', 'align' => 'center', 'minWidth' => 140];
+        $header[] = ['title' => '操作', 'slot' => 'action', 'align' => 'center', 'minWidth' => 70];
+        $info = ['attr' => $attr, 'value' => $valueNew, 'header' => $header];
+        return Json::successful($info);
+    }
+
+    public function check_no($id)
+    {
+        $info = ProductModel::get($id);
+        if (!$info || $info['status'] != 0 || $this->adminInfo['store_id'] != 0) {
+            $this->failed('参数或身份错误');
+        }
+        $from = [];
+        $from['reason'] = Form::textarea('reason', '驳回原因', '')->rows(10);
+        $form = Form::make_post_form('添加用户通知', $from, Url::buildUrl('save_check_no', array('id' => $id)));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+    }
+
+    public function save_check_no($id)
+    {
+        $info = ProductModel::get($id);
+        if (!$info || $info['status'] != 0 || $this->adminInfo['store_id'] != 0) {
+            Json::fail('参数或身份错误');
+        }
+        $data = UtilService::postMore([
+            ['reason', ''],
+        ]);
+        if (ProductModel::where('id', $id)->update(['reason' => $data['reason'], 'status' => 2])) {
+            JsonService::success('驳回成功');
+        } else {
+            JsonService::fail('驳回失败');
+        }
+    }
+
+    public function check_ok($id)
+    {
+        $info = ProductModel::get($id);
+
+        if (!$info || $info['status'] != 0 || $this->adminInfo['store_id'] != 0) {
+            Json::fail('参数或身份错误');
+        }
+        $info = $info->toArray();
+        $description = StoreDescription::getDescription($id, 8);
+        $cate_id = explode(',', $info['cate_id']);
+        ProductModel::beginTrans();
+        $product = \app\admin\model\store\StoreProduct::where('check_id', $id)->find();
+        try {
+            if ($product) {
+                unset($info['id']);
+                unset($info['add_time']);
+                \app\admin\model\store\StoreProduct::edit($info, $product['id']);
+                StoreDescription::saveDescription($description, $product['id'], 0);
+                StoreProductCate::where('product_id', $product['id'])->delete();
+                $cateData = [];
+                foreach ($cate_id as $cid) {
+                    $cateData[] = ['product_id' => $product['id'], 'cate_id' => $cid, 'add_time' => time()];
+                }
+                StoreProductCate::insertAll($cateData);
+                $attr_res = StoreProductAttr::reSaveFromOtherType($id, $product['id'], 8, 0);
+                if ($attr_res) {
+                    ProductModel::where('id', $id)->update(['status' => 1]);
+                    ProductModel::commitTrans();
+                    Json::success('审核完成');
+                } else {
+                    ProductModel::rollbackTrans();
+                    Json::fail(StoreProductAttr::getErrorInfo());
+                }
+            } else {
+                //新增
+                unset($info['id']);
+                $info['check_id'] = $id;
+                $info['add_time'] = time();
+                $res = \app\admin\model\store\StoreProduct::create($info);
+                StoreDescription::saveDescription($description, $res['id'], 0);
+                $cateData = [];
+                foreach ($cate_id as $cid) {
+                    $cateData[] = ['product_id' => $res['id'], 'cate_id' => $cid, 'add_time' => time()];
+                }
+                StoreProductCate::insertAll($cateData);
+                $attr_res = StoreProductAttr::reSaveFromOtherType($id, $res['id'], 8, 0);
+                if ($attr_res) {
+                    ProductModel::where('id', $id)->update(['status' => 1]);
+                    ProductModel::commitTrans();
+                    Json::success('审核完成');
+                } else {
+                    ProductModel::rollbackTrans();
+                    Json::fail(StoreProductAttr::getErrorInfo());
+                }
+            }
+        } catch (\Exception $e) {
+            ProductModel::rollbackTrans();
+            Json::fail($e->getMessage());
+        }
+    }
+}

+ 10 - 11
app/admin/model/store/StoreProduct.php

@@ -6,6 +6,7 @@
 
 namespace app\admin\model\store;
 
+use app\admin\model\system\SystemStore;
 use crmeb\basic\BaseModel;
 use app\models\store\StoreCart;
 use crmeb\services\PHPExcelService;
@@ -83,19 +84,15 @@ class StoreProduct extends BaseModel
             if (isset($where['store_name']) && $where['store_name'] != '') {
                 $model = $model->where('store_name|keyword|id', 'LIKE', "%$where[store_name]%");
             }
-            if(isset($where['bar_code']) && $where['bar_code'] != '')
-            {
-                $product_id = StoreProductAttrValue::where('bar_code',$where['bar_code'])->value('product_id');
-                if($product_id)
-                {
-                    $where['product_id'] =$product_id;
-                }
-                else
-                {
+            if (isset($where['bar_code']) && $where['bar_code'] != '') {
+                $product_id = StoreProductAttrValue::where('bar_code', $where['bar_code'])->value('product_id');
+                if ($product_id) {
+                    $where['product_id'] = $product_id;
+                } else {
                     $where['product_id'] = 0;
                 }
             }
-            if(isset($where['is_consumer']) && $where['is_consumer']>-1)   $model = $model->where(['is_consumer' => $where['is_consumer']]);
+            if (isset($where['is_consumer']) && $where['is_consumer'] > -1) $model = $model->where(['is_consumer' => $where['is_consumer']]);
             if (isset($where['cate_id']) && trim($where['cate_id']) != '') {
                 $model = $model->whereIn('id', function ($query) use ($where) {
                     $query->name('store_product_cate')->where('cate_id', $where['cate_id'])->field('product_id')->select();
@@ -145,6 +142,7 @@ class StoreProduct extends BaseModel
     public static function ProductList($where)
     {
         $model = self::getModelObject($where);
+        if (isset($where['store_id'])) $model = $model->where('store_id', $where['store_id']);
         if ($where['excel'] == 0) $model = $model->page((int)$where['page'], (int)$where['limit']);
         $data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
         foreach ($data as &$item) {
@@ -155,6 +153,7 @@ class StoreProduct extends BaseModel
             $item['stock'] = self::getStock($item['id']) > 0 ? self::getStock($item['id']) : $item['stock'];//库存
             $item['stock_attr'] = self::getStock($item['id']) > 0 ? true : false;//库存
             $item['sales_attr'] = self::getSales($item['id']);//属性销量
+            $item['from_store_name'] = SystemStore::where('id', $item['store_id'])->value('name') ?: '自营';
             $item['visitor'] = StoreVisit::where('product_id', $item['id'])->where('product_type', 'product')->count();
         }
         unset($item);
@@ -173,7 +172,7 @@ class StoreProduct extends BaseModel
                     $item['collect']
                 ];
             }
-            PHPExcelService::setExcelHeader(['产品名称', '产品简介', '产品分类', '价格','成本', '库存', '销量', '点赞人数', '收藏人数'])
+            PHPExcelService::setExcelHeader(['产品名称', '产品简介', '产品分类', '价格', '成本', '库存', '销量', '点赞人数', '收藏人数'])
                 ->setExcelTile('产品导出', '产品信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
                 ->setExcelContent($export)
                 ->ExcelSave();

+ 43 - 0
app/admin/model/store/StoreProductAttr.php

@@ -156,4 +156,47 @@ class StoreProductAttr extends BaseModel
         return self::where('product_id', $productId)->select()->toArray();
     }
 
+    public static function reSaveFromOtherType($product_id_origin, $product_id_to, $type_origin, $type_to)
+    {
+        //修改规格
+        $attrGroupOrigin = self::where('product_id', $product_id_origin)->where('type', $type_origin)->select()->toArray();
+        $valueGroupOrigin = StoreProductAttrValue::where('product_id', $product_id_origin)->where('type', $type_origin)->select()->toArray();
+        $result = StoreProductAttrResult::where('product_id', $product_id_origin)->where('type', $type_origin)->find()->toArray();
+        $attrGroup = [];
+        $valueGroup = [];
+        foreach ($valueGroupOrigin as $v) {
+            $info = $v;
+            $info['type'] = $type_to;
+            $info['product_id'] = $product_id_to;
+            $info['unique'] = StoreProductAttrValue::where(['product_id' => $product_id_to, 'suk' => $v['suk'], 'type' => $type_to])->value('unique') ?: '';
+            $valueGroup[$v['suk']] = $info;
+        }
+        foreach ($attrGroupOrigin as $v) {
+            $attrGroup[] = [
+                'product_id' => $product_id_to,
+                'attr_name' => $v['attr_name'],
+                'attr_values' => $v['attr_values'],
+                'type' => $type_to
+            ];
+        }
+        $res = true;
+        $attrModel = new StoreProductAttr();
+        $attrValueModel = new StoreProductAttrValue;
+        if (!self::clearProductAttr($product_id_to, $type_to)) return false;
+        $res = $res
+            && false !== $attrModel->saveAll($attrGroup)
+            && false !== $attrValueModel->saveAll($valueGroup)
+            && false !== StoreProductAttrResult::setResult($result['result'], $product_id_to, $type_to);
+        foreach ($valueGroup as $v) {
+            if ($v['bar_code']) {
+                SystemStoreStock::where('bar_code', $v['bar_code'])->update(['price' => $v['price']]);
+            }
+        }
+        if ($res)
+            return true;
+        else
+            return self::setErrorInfo('编辑商品属性失败!');
+
+    }
+
 }

+ 695 - 0
app/admin/model/store/StoreProductCheck.php

@@ -0,0 +1,695 @@
+<?php
+/**
+ * @author: xaboy<365615158@qq.com>
+ * @day: 2017/11/11
+ */
+
+namespace app\admin\model\store;
+
+use app\admin\model\system\SystemStore;
+use crmeb\basic\BaseModel;
+use app\models\store\StoreCart;
+use crmeb\services\PHPExcelService;
+use crmeb\traits\ModelTrait;
+use app\admin\model\order\StoreOrder;
+use app\admin\model\store\StoreCategory as CategoryModel;
+use app\admin\model\ump\{
+    StoreBargain, StoreCombination, StoreSeckill
+};
+
+/**
+ * 产品管理 model
+ * Class StoreProduct
+ * @package app\admin\model\store
+ */
+class StoreProductCheck extends BaseModel
+{
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'store_product_check';
+
+    use ModelTrait;
+
+    public function getDescriptionAttr($value)
+    {
+        return htmlspecialchars_decode($value);
+    }
+
+
+    /**
+     * 获取连表MOdel
+     * @param $model
+     * @return object
+     */
+    public static function getModelObject($where = [])
+    {
+        $model = new self();
+        if (!empty($where)) {
+            $type = $where['type'] ?? 0;
+            switch ((int)$type) {
+                case 1:
+                    break;
+                case 2:
+                    $model = $model->where(['status' => 0]);
+                    break;
+                case 3:
+                    $model = $model->where(['status' => 1]);
+                    break;
+                case 4:
+                    $model = $model->where(['status' => 2]);
+                    break;
+            };
+            if (isset($where['store_name']) && $where['store_name'] != '') {
+                $model = $model->where('store_name|keyword|id', 'LIKE', "%$where[store_name]%");
+            }
+            if (isset($where['bar_code']) && $where['bar_code'] != '') {
+                $product_id = StoreProductAttrValue::where('bar_code', $where['bar_code'])->value('product_id');
+                if ($product_id) {
+                    $where['product_id'] = $product_id;
+                } else {
+                    $where['product_id'] = 0;
+                }
+            }
+            if (isset($where['cate_id']) && trim($where['cate_id']) != '') {
+                $model = $model->whereIn('id', function ($query) use ($where) {
+                    $query->name('store_product_cate')->where('cate_id', $where['cate_id'])->field('product_id')->select();
+                });
+            }
+            if (isset($where['order']) && $where['order'] != '') {
+                $model = $model->order(self::setOrder($where['order']));
+            } else {
+                $model = $model->order('sort desc,id desc');
+            }
+        }
+        return $model;
+    }
+
+    /**根据cateid查询产品 拼sql语句
+     * @param $cateid
+     * @return string
+     */
+    protected static function getCateSql($cateid)
+    {
+        $lcateid = $cateid . ',%';//匹配最前面的cateid
+        $ccatid = '%,' . $cateid . ',%';//匹配中间的cateid
+        $ratidid = '%,' . $cateid;//匹配后面的cateid
+        return " `cate_id` LIKE '$lcateid' OR `cate_id` LIKE '$ccatid' OR `cate_id` LIKE '$ratidid' OR `cate_id`=$cateid";
+    }
+
+    /** 如果有子分类查询子分类获取拼接查询sql
+     * @param $cateid
+     * @return string
+     */
+    protected static function getPidSql($cateid)
+    {
+
+        $sql = self::getCateSql($cateid);
+        $ids = CategoryModel::where('pid', $cateid)->column('id', 'id');
+        //查询如果有子分类获取子分类查询sql语句
+        if ($ids) foreach ($ids as $v) $sql .= " OR " . self::getcatesql($v);
+        return $sql;
+    }
+
+
+    /**
+     * 获取产品列表
+     * @param $where
+     * @return array
+     */
+    public static function ProductList($where)
+    {
+        $model = self::getModelObject($where);
+        if (isset($where['store_id'])) $model = $model->where('store_id', $where['store_id']);
+        if ($where['excel'] == 0) $model = $model->page((int)$where['page'], (int)$where['limit']);
+        $data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
+        foreach ($data as &$item) {
+            $cateName = CategoryModel::where('id', 'IN', $item['cate_id'])->column('cate_name', 'id');
+            $item['cate_name'] = is_array($cateName) ? implode(',', $cateName) : '';
+            $item['collect'] = StoreProductRelation::where('product_id', $item['id'])->where('type', 'collect')->count();//收藏
+            $item['like'] = StoreProductRelation::where('product_id', $item['id'])->where('type', 'like')->count();//点赞
+            $item['stock'] = self::getStock($item['id']) > 0 ? self::getStock($item['id']) : $item['stock'];//库存
+            $item['stock_attr'] = self::getStock($item['id']) > 0 ? true : false;//库存
+            $item['sales_attr'] = self::getSales($item['id']);//属性销量
+            $item['from_store_name'] = SystemStore::where('id', $item['store_id'])->value('name') ?: '自营';
+            $item['visitor'] = StoreVisit::where('product_id', $item['id'])->where('product_type', 'product')->count();
+        }
+        unset($item);
+        if ($where['excel'] == 1) {
+            $export = [];
+            foreach ($data as $index => $item) {
+                $export[] = [
+                    $item['store_name'],
+                    $item['store_info'],
+                    $item['cate_name'],
+                    '¥' . $item['price'],
+                    '¥' . $item['cost'],
+                    $item['stock'],
+                    $item['sales'],
+                    $item['like'],
+                    $item['collect']
+                ];
+            }
+            PHPExcelService::setExcelHeader(['产品名称', '产品简介', '产品分类', '价格', '成本', '库存', '销量', '点赞人数', '收藏人数'])
+                ->setExcelTile('产品导出', '产品信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+                ->setExcelContent($export)
+                ->ExcelSave();
+        }
+        $count = self::getModelObject($where)->count();
+        return compact('count', 'data');
+    }
+
+    public static function getChatrdata($type, $data)
+    {
+        $legdata = ['销量', '数量', '点赞', '收藏'];
+        $model = self::setWhereType(self::order('un_time asc,id desc'), $type);
+        $list = self::getModelTime(compact('data'), $model)
+            ->field('FROM_UNIXTIME(add_time,"%Y-%c-%d") as un_time,count(id) as count,sum(sales) as sales')
+            ->group('un_time')
+            ->distinct(true)
+            ->select()
+            ->each(function ($item) use ($data) {
+                $item['collect'] = self::getModelTime(compact('data'), new StoreProductRelation)->where('type', 'collect')->count();
+                $item['like'] = self::getModelTime(compact('data'), new StoreProductRelation)->where('type', 'like')->count();
+            })->toArray();
+        $chatrList = [];
+        $datetime = [];
+        $data_item = [];
+        $itemList = [0 => [], 1 => [], 2 => [], 3 => []];
+        foreach ($list as $item) {
+            $itemList[0][] = $item['sales'];
+            $itemList[1][] = $item['count'];
+            $itemList[2][] = $item['like'];
+            $itemList[3][] = $item['collect'];
+            array_push($datetime, $item['un_time']);
+        }
+        foreach ($legdata as $key => $leg) {
+            $data_item['name'] = $leg;
+            $data_item['type'] = 'line';
+            $data_item['data'] = $itemList[$key];
+            $chatrList[] = $data_item;
+            unset($data_item);
+        }
+        unset($leg);
+        $badge = self::getbadge(compact('data'), $type);
+        $count = self::setWhereType(self::getModelTime(compact('data'), new self()), $type)->count();
+        return compact('datetime', 'chatrList', 'legdata', 'badge', 'count');
+
+    }
+
+    //获取 badge 内容
+    public static function getbadge($where, $type)
+    {
+        $replenishment_num = sys_config('replenishment_num');
+        $replenishment_num = $replenishment_num > 0 ? $replenishment_num : 20;
+        $sum = [];
+        $lack = 0;
+
+        //获取普通产品缺货
+        $stock1 = self::getModelTime($where, new self())->where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $sum_stock = self::where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $stk = [];
+        foreach ($stock1 as $item) {
+            $stk[] = $replenishment_num - $item;
+        }
+        $lack = bcadd($lack, array_sum($stk), 0);
+        foreach ($sum_stock as $val) {
+            $sum[] = $replenishment_num - $val;
+        }
+        unset($stk, $sum_stock, $stock1);
+
+        //获取砍价缺货产品
+        $stock1 = self::getModelTime($where, new StoreBargain())->where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $sum_stock = StoreBargain::where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $stk = [];
+        foreach ($stock1 as $item) {
+            $stk[] = $replenishment_num - $item;
+        }
+        $lack = bcadd($lack, array_sum($stk), 0);
+        foreach ($sum_stock as $val) {
+            $sum[] = $replenishment_num - $val;
+        }
+        unset($stk, $sum_stock, $stock1);
+
+        //获取拼团缺货产品
+        $stock1 = self::getModelTime($where, new StoreCombination())->where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $sum_stock = StoreCombination::where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $stk = [];
+        foreach ($stock1 as $item) {
+            $stk[] = $replenishment_num - $item;
+        }
+        $lack = bcadd($lack, array_sum($stk), 0);
+        foreach ($sum_stock as $val) {
+            $sum[] = $replenishment_num - $val;
+        }
+        unset($stk, $sum_stock, $stock1);
+
+        return [
+            [
+                'name' => '商品种类',
+                'field' => '件',
+                'count' => self::setWhereType(new self(), $type)->where('add_time', '<', mktime(0, 0, 0, date('m'), date('d'), date('Y')))->count(),
+                'content' => '商品数量总数',
+                'background_color' => 'layui-bg-blue',
+                'sum' => self::count(),
+                'class' => 'fa fa fa-ioxhost',
+            ],
+            [
+                'name' => '商品总数',
+                'field' => '件',
+                'count' => self::setWhereType(self::getModelTime($where, new self), $type)->sum('stock'),
+                'content' => '商品总数',
+                'background_color' => 'layui-bg-cyan',
+                'sum' => self::where('is_new', 1)->sum('stock'),
+                'class' => 'fa fa-line-chart',
+            ],
+            [
+                'name' => '活动商品',
+                'field' => '件',
+                'count' => self::getActivityProductSum($where),
+                'content' => '活动商品总数',
+                'background_color' => 'layui-bg-green',
+                'sum' => self::getActivityProductSum(),
+                'class' => 'fa fa-bar-chart',
+            ],
+            [
+                'name' => '缺货商品',
+                'field' => '件',
+                'count' => $lack,
+                'content' => '总商品数量',
+                'background_color' => 'layui-bg-orange',
+                'sum' => array_sum($sum),
+                'class' => 'fa fa-cube',
+            ],
+        ];
+    }
+
+    /*
+     * 获取活动产品总和
+     * @param array $where 查询条件
+     * */
+    public static function getActivityProductSum($where = false)
+    {
+        if ($where) {
+            $bargain = self::getModelTime($where, new StoreBargain())->sum('stock');
+            $pink = self::getModelTime($where, new StoreCombination())->sum('stock');
+            $seckill = self::getModelTime($where, new StoreSeckill())->sum('stock');
+        } else {
+            $bargain = StoreBargain::sum('stock');
+            $pink = StoreCombination::sum('stock');
+            $seckill = StoreSeckill::sum('stock');
+        }
+        return bcadd(bcadd($bargain, $pink, 0), $seckill, 0);
+    }
+
+    public static function setWhereType($model, $type)
+    {
+        switch ($type) {
+            case 1:
+                $data = ['is_show' => 1, 'is_del' => 0];
+                break;
+            case 2:
+                $data = ['is_show' => 0, 'is_del' => 0];
+                break;
+            case 3:
+                $data = ['is_del' => 0];
+                break;
+            case 4:
+                $data = ['is_show' => 1, 'is_del' => 0, 'stock' => 0];
+                break;
+            case 5:
+                $data = ['is_show' => 1, 'is_del' => 0, 'stock' => ['elt', 1]];
+                break;
+            case 6:
+                $data = ['is_del' => 1];
+                break;
+        }
+        if (isset($data)) $model = $model->where($data);
+        return $model;
+    }
+
+    /*
+     * layui-bg-red 红 layui-bg-orange 黄 layui-bg-green 绿 layui-bg-blue 蓝 layui-bg-cyan 黑
+     * 销量排行 top 10
+     */
+    public static function getMaxList($where)
+    {
+        $classs = ['layui-bg-red', 'layui-bg-orange', 'layui-bg-green', 'layui-bg-blue', 'layui-bg-cyan'];
+        $model = StoreOrder::alias('a')->join('StoreOrderCartInfo c', 'a.id=c.oid')->join('store_product b', 'b.id=c.product_id');
+        $list = self::getModelTime($where, $model, 'a.add_time')
+            ->group('c.product_id')
+            ->order('p_count desc')
+            ->limit(10)
+            ->field(['count(c.product_id) as p_count', 'b.store_name', 'sum(b.price) as sum_price'])
+            ->select();
+        if (count($list)) $list = $list->toArray();
+        $maxList = [];
+        $sum_count = 0;
+        $sum_price = 0;
+        foreach ($list as $item) {
+            $sum_count += $item['p_count'];
+            $sum_price = bcadd($sum_price, $item['sum_price'], 2);
+        }
+        unset($item);
+        foreach ($list as $key => &$item) {
+            $item['w'] = bcdiv($item['p_count'], $sum_count, 2) * 100;
+            $item['class'] = isset($classs[$key]) ? $classs[$key] : (isset($classs[$key - count($classs)]) ? $classs[$key - count($classs)] : '');
+            $item['store_name'] = self::getSubstrUTf8($item['store_name']);
+        }
+        $maxList['sum_count'] = $sum_count;
+        $maxList['sum_price'] = $sum_price;
+        $maxList['list'] = $list;
+        return $maxList;
+    }
+
+    //获取利润
+    public static function ProfityTop10($where)
+    {
+        $classs = ['layui-bg-red', 'layui-bg-orange', 'layui-bg-green', 'layui-bg-blue', 'layui-bg-cyan'];
+        $model = StoreOrder::alias('a')
+            ->join('StoreOrderCartInfo c', 'a.id=c.oid')
+            ->join('store_product b', 'b.id=c.product_id')
+            ->where('b.is_show', 1)
+            ->where('b.is_del', 0);
+        $list = self::getModelTime($where, $model, 'a.add_time')
+            ->group('c.product_id')
+            ->order('profity desc')
+            ->limit(10)
+            ->field(['count(c.product_id) as p_count', 'b.store_name', 'sum(b.price) as sum_price', '(b.price-b.cost) as profity'])
+            ->select();
+        if (count($list)) $list = $list->toArray();
+        $maxList = [];
+        $sum_count = 0;
+        $sum_price = 0;
+        foreach ($list as $item) {
+            $sum_count += $item['p_count'];
+            $sum_price = bcadd($sum_price, $item['sum_price'], 2);
+        }
+        foreach ($list as $key => &$item) {
+            $item['w'] = bcdiv($item['sum_price'], $sum_price, 2) * 100;
+            $item['class'] = isset($classs[$key]) ? $classs[$key] : (isset($classs[$key - count($classs)]) ? $classs[$key - count($classs)] : '');
+            $item['store_name'] = self::getSubstrUTf8($item['store_name'], 30);
+        }
+        $maxList['sum_count'] = $sum_count;
+        $maxList['sum_price'] = $sum_price;
+        $maxList['list'] = $list;
+        return $maxList;
+    }
+
+    //获取缺货
+    public static function getLackList($where)
+    {
+        $replenishment_num = sys_config('replenishment_num');
+        $replenishment_num = $replenishment_num > 0 ? $replenishment_num : 20;
+        $list = self::where('stock', '<', $replenishment_num)->field(['id', 'store_name', 'stock', 'price'])->page((int)$where['page'], (int)$where['limit'])->order('stock asc')->select();
+        if (count($list)) $list = $list->toArray();
+        $count = self::where('stock', '<', $replenishment_num)->count();
+        return ['count' => $count, 'data' => $list];
+    }
+
+    //获取差评
+    public static function getnegativelist($where)
+    {
+        $list = self::alias('s')->join('StoreProductReply r', 's.id=r.product_id')
+            ->field('s.id,s.store_name,s.price,count(r.product_id) as count')
+            ->page((int)$where['page'], (int)$where['limit'])
+            ->where('r.product_score', 1)
+            ->order('count desc')
+            ->group('r.product_id')
+            ->select();
+        if (count($list)) $list = $list->toArray();
+        $count = self::alias('s')->join('StoreProductReply r', 's.id=r.product_id')->group('r.product_id')->where('r.product_score', 1)->count();
+        return ['count' => $count, 'data' => $list];
+    }
+
+    public static function TuiProductList()
+    {
+        $perd = StoreOrder::alias('s')->join('StoreOrderCartInfo c', 's.id=c.oid')
+            ->field('count(c.product_id) as count,c.product_id as id')
+            ->group('c.product_id')
+            ->where('s.status', -1)
+            ->order('count desc')
+            ->limit(10)
+            ->select();
+        if (count($perd)) $perd = $perd->toArray();
+        foreach ($perd as &$item) {
+            $item['store_name'] = self::where(['id' => $item['id']])->value('store_name');
+            $item['price'] = self::where(['id' => $item['id']])->value('price');
+        }
+        return $perd;
+    }
+
+    //编辑库存
+    public static function changeStock($stock, $productId)
+    {
+        return self::edit(compact('stock'), $productId);
+    }
+
+    //获取库存数量
+    public static function getStock($productId)
+    {
+        return StoreProductAttrValue::where(['product_id' => $productId, 'type' => 0])->sum('stock');
+    }
+
+    //获取总销量
+    public static function getSales($productId)
+    {
+        return StoreProductAttrValue::where(['product_id' => $productId, 'type' => 0])->sum('sales');
+    }
+
+    public static function getTierList($model = null)
+    {
+        if ($model === null) $model = new self();
+        return $model->field('id,store_name')->where('is_del', 0)->select()->toArray();
+    }
+
+    /**
+     * 设置查询条件
+     * @param array $where
+     * @return array
+     */
+    public static function setWhere($where)
+    {
+        $time['data'] = '';
+        if (isset($where['start_time']) && $where['start_time'] != '' && isset($where['end_time']) && $where['end_time'] != '') {
+            $time['data'] = $where['start_time'] . ' - ' . $where['end_time'];
+        } else {
+            $time['data'] = isset($where['data']) ? $where['data'] : '';
+        }
+        $model = self::getModelTime($time, StoreCart::alias('a')->join('store_product b', 'a.product_id=b.id'), 'a.add_time');
+        if (isset($where['title']) && $where['title'] != '') {
+            $model = $model->where('b.store_name|b.id', 'like', "%$where[title]%");
+        }
+        return $model;
+    }
+
+    /**
+     * 获取真实销量排行
+     * @param array $where
+     * @return array
+     */
+    public static function getSaleslists($where)
+    {
+        $data = self::setWhere($where)
+            ->where('a.is_pay', 1)
+            ->group('a.product_id')
+            ->field(['sum(a.cart_num) * b.price as sum_price', 'sum(a.cart_num) as num_product', 'b.store_name',
+                'b.image', 'b.price', 'b.id'])
+            ->order('num_product desc')
+            ->whereIn('a.product_id', function ($query) {
+                $query->name('store_order_cart_info')->alias('k')->join('store_order q', 'q.id = k.oid')
+                    ->where(['q.paid' => 1, 'q.refund_status' => 0])->field('k.product_id')->select();
+            })
+            ->page((int)$where['page'], (int)$where['limit'])
+            ->select();
+        $count = self::setWhere($where)->where('a.is_pay', 1)->group('a.product_id')->count();
+        $data = count($data) ? $data->toArray() : [];
+        return compact('data', 'count');
+    }
+
+    public static function SaveProductExport($where)
+    {
+        $list = self::setWhere($where)
+            ->where('a.is_pay', 1)
+            ->field(['sum(a.cart_num) as num_product', 'b.store_name', 'b.image', 'b.price', 'b.id'])
+            ->order('num_product desc')
+            ->group('a.product_id')
+            ->select();
+        $export = [];
+        foreach ($list as $item) {
+            $export[] = [
+                $item['id'],
+                $item['store_name'],
+                $item['price'],
+                bcmul($item['num_product'], $item['price'], 2),
+                $item['num_product'],
+            ];
+        }
+        PHPExcelService::setExcelHeader(['商品编号', '商品名称', '商品售价', '销售额', '销量'])
+            ->setExcelTile('产品销量排行', '产品销量排行', ' 生成时间:' . date('Y-m-d H:i:s', time()))
+            ->setExcelContent($export)
+            ->ExcelSave();
+    }
+
+    /*
+     *  单个商品详情的头部查询
+     *  $id 商品id
+     *  $where 条件
+     */
+    public static function getProductBadgeList($id, $where)
+    {
+        $data['data'] = $where;
+        $list = self::setWhere($data)
+            ->field(['sum(a.cart_num) as num_product', 'b.id', 'b.price'])
+            ->where('a.is_pay', 1)
+            ->group('a.product_id')
+            ->order('num_product desc')
+            ->select();
+        //排名
+        $ranking = 0;
+        //销量
+        $xiaoliang = 0;
+        //销售额 数组
+        $list_price = [];
+        foreach ($list as $key => $item) {
+            if ($item['id'] == $id) {
+                $ranking = $key + 1;
+                $xiaoliang = $item['num_product'];
+            }
+            $value['sum_price'] = $item['price'] * $item['num_product'];
+            $value['id'] = $item['id'];
+            $list_price[] = $value;
+        }
+        //排序
+        $list_price = self::my_sort($list_price, 'sum_price', SORT_DESC);
+        //销售额排名
+        $rank_price = 0;
+        //当前销售额
+        $num_price = 0;
+        if ($list_price !== false && is_array($list_price)) {
+            foreach ($list_price as $key => $item) {
+                if ($item['id'] == $id) {
+                    $num_price = $item['sum_price'];
+                    $rank_price = $key + 1;
+                    continue;
+                }
+            }
+        }
+        return [
+            [
+                'name' => '销售额排名',
+                'field' => '名',
+                'count' => $rank_price,
+                'background_color' => 'layui-bg-blue',
+            ],
+            [
+                'name' => '销量排名',
+                'field' => '名',
+                'count' => $ranking,
+                'background_color' => 'layui-bg-blue',
+            ],
+            [
+                'name' => '商品销量',
+                'field' => '名',
+                'count' => $xiaoliang,
+                'background_color' => 'layui-bg-blue',
+            ],
+            [
+                'name' => '点赞次数',
+                'field' => '个',
+                'count' => StoreProductRelation::where('product_id', $id)->where('type', 'like')->count(),
+                'background_color' => 'layui-bg-blue',
+            ],
+            [
+                'name' => '销售总额',
+                'field' => '元',
+                'count' => $num_price,
+                'background_color' => 'layui-bg-blue',
+                'col' => 12,
+            ],
+        ];
+    }
+
+    /*
+     * 处理二维数组排序
+     * $arrays 需要处理的数组
+     * $sort_key 需要处理的key名
+     * $sort_order 排序方式
+     * $sort_type 类型 可不填写
+     */
+    public static function my_sort($arrays, $sort_key, $sort_order = SORT_ASC, $sort_type = SORT_NUMERIC)
+    {
+        if (is_array($arrays)) {
+            foreach ($arrays as $array) {
+                if (is_array($array)) {
+                    $key_arrays[] = $array[$sort_key];
+                } else {
+                    return false;
+                }
+            }
+        }
+        if (isset($key_arrays)) {
+            array_multisort($key_arrays, $sort_order, $sort_type, $arrays);
+            return $arrays;
+        }
+        return false;
+    }
+
+    /*
+     * 查询单个商品的销量曲线图
+     *
+     */
+    public static function getProductCurve($where)
+    {
+        $list = self::setWhere($where)
+            ->where('a.product_id', $where['id'])
+            ->where('a.is_pay', 1)
+            ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time', 'sum(a.cart_num) as num'])
+            ->group('_add_time')
+            ->order('_add_time asc')
+            ->select();
+        $seriesdata = [];
+        $date = [];
+        $zoom = '';
+        foreach ($list as $item) {
+            $date[] = $item['_add_time'];
+            $seriesdata[] = $item['num'];
+        }
+        if (count($date) > $where['limit']) $zoom = $date[$where['limit'] - 5];
+        return compact('seriesdata', 'date', 'zoom');
+    }
+
+    /*
+     * 查询单个商品的销售列表
+     *
+     */
+    public static function getSalelList($where)
+    {
+        return self::setWhere($where)
+            ->where('a.product_id', $where['id'])
+            ->where('a.is_pay', 1)
+            ->join('user c', 'c.uid=a.uid')
+            ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time', 'c.nickname', 'b.price', 'a.id', 'a.cart_num as num'])
+            ->page((int)$where['page'], (int)$where['limit'])
+            ->select();
+    }
+
+    /**
+     * TODO 获取某个字段值
+     * @param $id
+     * @param string $field
+     * @return mixed
+     */
+    public static function getProductField($id, $field = 'store_name')
+    {
+        return self::where('id', $id)->value($field);
+    }
+}

+ 3 - 0
app/admin/view/store/store_product/index.php

@@ -149,6 +149,7 @@
             case 1:case 3:case 4:case 5:
                 join=[
                     {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
+                    {field: 'from_store_name', title: '所属门店', width: '6%'},
                     {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
                     {field: 'store_name', title: '商品名称',templet:'#store_name'},
                     {field: 'ficti', title: '虚拟销量',edit:'ficti',width:'8%'},
@@ -164,6 +165,7 @@
                 join=[
                     {type:'checkbox'},
                     {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
+                    {field: 'from_store_name', title: '所属门店', width: '6%'},
                     {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
                     {field: 'store_name', title: '商品名称',templet:'#store_name'},
                     {field: 'price', title: '价格',edit:'price',width:'8%'},
@@ -178,6 +180,7 @@
             case 6:
                 join=[
                     {field: 'id', title: '商品ID', sort: true,event:'id'},
+                    {field: 'from_store_name', title: '所属门店', width: '6%'},
                     {field: 'image', title: '商品图片',templet:'#image'},
                     {field: 'store_name', title: '商品名称',templet:'#store_name'},
                     {field: 'price', title: '商品价格',edit:'price'},

+ 397 - 0
app/admin/view/store/store_product_check/attr.php

@@ -0,0 +1,397 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    {include file="public/head"}
+    <title>{$title|default=''}</title>
+    <style>
+        .check{color: #f00}
+        .demo-upload{
+            display: block;
+            height: 33px;
+            text-align: center;
+            border: 1px solid transparent;
+            border-radius: 4px;
+            overflow: hidden;
+            background: #fff;
+            position: relative;
+            box-shadow: 0 1px 1px rgba(0,0,0,.2);
+            margin-right: 4px;
+        }
+        .demo-upload img{
+            width: 100%;
+            height: 100%;
+            display: block;
+        }
+        .demo-upload-cover{
+            display: none;
+            position: absolute;
+            top: 0;
+            bottom: 0;
+            left: 0;
+            right: 0;
+            background: rgba(0,0,0,.6);
+        }
+        .demo-upload:hover .demo-upload-cover{
+            display: block;
+        }
+        .demo-upload-cover i{
+            color: #fff;
+            font-size: 20px;
+            cursor: pointer;
+            margin: 0 2px;
+        }
+    </style>
+    <script>
+        window.test=1;
+    </script>
+</head>
+<body>
+<div id="store-attr" class="mp-form" v-cloak="">
+    <i-Form :label-width="80" style="width: 100%" v-show="hidden == false">
+        <Form-Item>
+            <Row>
+                <i-Col span="5">
+                    <i-Button type="dashed" long @click="hiddenBool" icon="plus-round">添加新规则</i-Button>
+                </i-Col>
+            </Row>
+        </Form-Item>
+    </i-Form>
+    <i-Form :label-width="80" style="width: 100%" v-show="hidden == true">
+        <Form-Item
+                :label="'规则名称:'">
+            <Row>
+                <i-Col style="position: relative;margin-right: 6px"  span="5"
+                       v-for="(item, index) in items"
+                       :key="index">
+                    <i-Input type="text" v-model="item.value" placeholder="设置名称"></i-Input>
+                    <i-Button style="position: absolute;top:0;right:0;margin-top:1px;border: none;font-size: 8px;line-height: 1.8" type="ghost" @click="handleRemove(index)" v-show="item.attrHidden == true"><Icon type="close-round" /></i-Button>
+                    <i-Button style="position: absolute;top:0;right:0;margin-top:1px;border: none;font-size: 8px;line-height: 1.8" type="ghost" @click="attrHiddenBool(item)" v-show="item.attrHidden == false"><Icon type="checkmark-round"></Icon></i-Button>
+                </i-Col>
+                <i-Col span="5">
+                    <i-Button type="dashed" long @click="handleAdd" icon="plus-round">添加新规则</i-Button>
+                </i-Col>
+            </Row>
+        </Form-Item>
+        <Form-Item v-show="item.attrHidden == true"
+                v-for="(item, index) in items"
+                :key="index"
+                :label="''+item.value+':'" >
+            <Row>
+                <i-Col span="3"
+                       v-for="(attr,k) in item.detail"
+                       :key="attr"
+                       :name="attr">
+                    <Tag type="border" closable color="blue" @on-close="attrRemove(item,k)">{{ attr }}</Tag>
+                </i-Col>
+                <i-Col span="5">
+                    <i-Input type="text" v-model="item.detailValue" placeholder="设置属性"></i-Input>
+                </i-Col>
+                <i-Col span="5">
+                    <i-Button type="primary" style="margin-left: 6px" @click="attrAdd(item)">添加</i-Button>
+                </i-Col>
+            </Row>
+        </Form-Item>
+        <Form-Item v-show="hidden == true" style="width: 100%;">
+            <Row style="margin: 0 88px 0 20px">
+                <i-Col span="24">
+                    <i-Button type="primary" long @click="addGoods(true)">生成</i-Button>
+                </i-Col>
+            </Row>
+        </Form-Item>
+
+        <template v-if="items[0].value!='' && items[0].detail.length>0 && attrs.length">
+            <template v-for="(attr,index) in attrs">
+                <Form-Item>
+                    <Row>
+                        <template v-for="(item,index) in attr.detail">
+                            <i-Col span="3" style="margin-right: 2px">
+                                {{index}}:{{item}}
+                            </i-Col>
+                        </template>
+                        <i-Col span="4">
+                            <span :class="attr.check ? 'check':''">金额:</span>&nbsp;&nbsp;<i-Input placeholder="金额" v-model="attr.price" style="width: 60%"
+                                     :number="true"></i-Input>
+                        </i-Col>
+                        <i-Col span="4">
+                            <span :class="attr.check ? 'check':''">库存:</span>&nbsp;&nbsp;<i-Input placeholder="库存" v-model="attr.sales" style="width: 60%"
+                                                                                                  :number="true"></i-Input>
+                        </i-Col>
+                        <i-Col span="6">
+                            <span :class="attr.check ? 'check':''">成本价:</span>&nbsp;&nbsp;<i-Input placeholder="成本价" v-model="attr.cost" style="width: 60%"
+                                                                                                   :number="true"></i-Input>
+                        </i-Col>
+                        <i-Col span="6">
+                            <span :class="attr.check ? 'check':''">产品条码:</span>&nbsp;&nbsp;<i-Input placeholder="产品条码" v-model="attr.bar_code" style="width: 60%"
+                                                                                                   :number="true"></i-Input>
+                        </i-Col>
+                        <i-Col span="2" offset="1" style="margin-right: 2px">
+                            <div class="demo-upload">
+                                <img :src="attr.pic">
+                                <div class="demo-upload-cover">
+                                    <Icon type="ios-eye-outline" @click.native="openPic(attr.pic)" ></Icon>
+                              <!--      <Upload
+                                            :show-upload-list="false"
+                                            :on-success="uploadSuccess(attr)"
+                                            :on-error="uploadError"
+                                            :format="['jpg','jpeg','png']"
+                                            :max-size="2048"
+                                            accept="image/*"
+                                            :on-format-error="uploadFormatError"
+                                            action="{:Url('upload')}"
+                                            style="display: inline-block"
+                                            :goods="attr"
+                                    >
+                                    </Upload>-->
+                                    <Icon type="ios-cloud-upload-outline"  @click.native="getAttrPic(index)"></Icon>
+
+
+                                </div>
+                            </div>
+                        </i-Col>
+                        <i-Col span="2" style="margin-right: 3px">
+                            <i-Button type="ghost" @click="removeGoods(index)">删除</i-Button>
+                        </i-Col>
+                    </Row>
+                </Form-Item>
+            </template>
+            <Form-Item>
+                <Row>
+<!--                    <i-Col span="10">-->
+<!--                        <i-Button type="dashed" long @click="addGoods" icon="plus-round">添加新商品</i-Button>-->
+<!--                    </i-Col>-->
+                    <i-Col span="2" offset="2">
+                        <i-Button type="primary" @click="submit">提交</i-Button>
+                    </i-Col>
+                    <i-Col span="2" offset="1">
+                        <i-Button type="error" @click="clear">清空所有属性</i-Button>
+                    </i-Col>
+                </Row>
+            </Form-Item>
+        </template>
+    </i-Form>
+    <Spin fix v-show="submiting == true">保存中...</Spin>
+</div>
+<script>
+    var _vm ;
+    mpFrame.start(function(Vue){
+        new Vue({
+            data () {
+                return {
+                    hidden:false,
+                    attrHidden:false,
+                    submiting :false,
+                    items: <?php echo $result && isset($result['attr']) && !empty($result['attr']) ? json_encode($result['attr']) : 'false'; ?> || [
+                        {
+                            value: '',
+                            detailValue:'',
+                            attrHidden:false,
+                            detail:[]
+                        }
+                    ],
+                    attrs:<?php echo $result && isset($result['value']) && !empty($result['value']) ? json_encode($result['value']) : '[]'; ?>
+                }
+            },
+            watch:{
+                items:{
+                    handler:function(){
+//                        this.attrs = [];
+                    },
+                    deep:true
+                }
+            },
+            methods: {
+                getAttrPic(index){
+                    this.createFrame('选择图片','/admin/widget.images/index/fodder/'+index+'.html',{h:500});
+                },
+                createFrame:function(title,src,opt){
+                    opt === undefined && (opt = {});
+                    var h = parent.document.body.clientHeight - 100;
+                    return layer.open({
+                        type: 2,
+                        title:title,
+                        area: [(opt.w || 700)+'px', (opt.h || h)+'px'],
+                        fixed: false, //不固定
+                        maxmin: true,
+                        moveOut:false,//true  可以拖出窗外  false 只能在窗内拖
+                        anim:5,//出场动画 isOutAnim bool 关闭动画
+                        offset:'auto',//['100px','100px'],//'auto',//初始位置  ['100px','100px'] t[ 上 左]
+                        shade:0,//遮罩
+                        resize:true,//是否允许拉伸
+                        content: src,//内容
+                        move:'.layui-layer-title'
+                    });
+                },
+                setAttrPic(index,pic){
+                    this.$set(this.attrs[index],'pic',pic);
+                },
+                attrHiddenBool(item){
+                    if(item.value == ''){
+                        $eb.message('error','请填写规则名称');
+                    }else{
+                        item.attrHidden = true;
+                    }
+                },
+                hiddenBool(){
+                    this.hidden = true;
+                },
+                handleAdd () {
+                    if(!this.checkAttr())return ;
+                    this.items.push({
+                        value: '',
+                        detailValue:'',
+                        attrHidden:false,
+                        detail:[]
+                    });
+                },
+                checkAttr(){
+                    var bool = true;
+                    this.items.map(function(item){
+                        if(!bool) return;
+                        if(!item.value){
+                            $eb.message('error','请填写规则名称');
+                            bool = false;
+                        }else if(!item.detail.length){
+                            $eb.message('error','请设置规则属性');
+                            bool = false;
+                        }
+                    });
+                    return bool;
+                },
+                attrAdd (item) {
+                    if(!item.detailValue) return false;
+                    item.detail.push(item.detailValue);
+                    item.detailValue = '';
+                },
+                handleRemove (index) {
+                    if(this.items.length > 1)
+                        this.items.splice(index,1);
+                    else
+                        $eb.message('error','请设置至少一个规则');
+                },
+                attrRemove(item,k){
+                    if(1==item.detail.length){
+                        $eb.message('error','请设置至少一个属性');
+                        return false;
+                    }
+                    item.detail.splice(k,1);
+                },
+                removeGoods(index){
+                    this.attrs.splice(index,1);
+                },
+                checkGoods(){
+                    var bool = true;
+                    this.attrs.map(function(attr){
+                        if(!bool) return ;
+                        if(!Object.keys(attr.detail).length){
+                            $eb.message('error','请选择至少一个属性');
+                            bool = false;
+                        }else if(attr.price != parseFloat(attr.price) || attr.price < 0){
+                            $eb.message('error','请输入正确的商品价格');
+                            bool = false;
+                        }else if(attr.sales != parseInt(attr.sales) || attr.sales < 0){
+                            $eb.message('error','请输入正确的商品库存');
+                            bool = false;
+                        }
+                    });
+                    return bool;
+                },
+                addGoods(type){
+                    if(this.attrs.length){
+                        if(!this.checkGoods())return ;
+                    }
+                    var that = this;
+                    $eb.axios.post("{:Url('is_format_attr',array('id'=>$id))}",{items:this.items,attrs:this.attrs}).then(function(res){
+                        if(res.data.code == 200){
+                            that.attrs = res.data.data
+                        }else{
+                            $eb.message('error',res.data.msg);
+                        }
+                    }).catch(function(err){
+                        if(res.data.code == 200){
+                            that.attrs = res.data.data
+                        }else{
+                            $eb.message('error',res.data.msg);
+                        }
+                    })
+                },
+                openPic(src){
+                    $eb.openImage(src);
+                },
+                uploadSuccess(data){
+                    return function(response, file, fileList){
+                        if(response.code == 200){
+                            data.pic = response.data.url;
+                        }else{
+                            $eb.message('error',response.data.msg || '图片上传失败!');
+                        }
+                    }
+                },
+                uploadError(error, file, fileList){
+                    $eb.message('error',error);
+                },
+                uploadFormatError(file, fileList){
+                    $eb.message('error','图片格式错误');
+                },
+                submit(){
+                    var that = this;
+                    that.submiting = true;
+                    if(!this.checkAttr() || !this.checkGoods()) return ;
+                    for(let attr in that.attrs){
+                        that.attrs[attr].check = false;
+                    }
+                    $eb.axios.post("{:Url('set_attr',array('id'=>$id))}",{items:this.items,attrs:this.attrs}).then(function(res){
+                        that.submiting = false;
+                        if(res.status == 200 && res.data.code == 200){
+                            $eb.message('success',res.data.msg || '编辑成功!');
+                            $eb.closeModalFrame(window.name);
+                        }else{
+                            $eb.message('error',res.data.msg || '请求失败!');
+                        }
+                    }).catch(function(err){
+                        $eb.message('error',err);
+                    })
+                },
+                clear(){
+                    var that = this;
+                    requirejs(['sweetalert'], function (swel) {
+                        swel({
+                            title: "您确定要清空产品属性吗",
+                            text: "删除后将无法恢复,请谨慎操作!",
+                            type: "warning",
+                            showCancelButton: true,
+                            confirmButtonColor: "#DD6B55",
+                            confirmButtonText: "是的,我要清空!",
+                            cancelButtonText: "让我再考虑一下…",
+                            closeOnConfirm: false,
+                            closeOnCancel: false
+                        }).then(function () {
+                            $eb.axios.post("{:Url('clear_attr',array('id'=>$id))}", {
+                                items: that.items,
+                                attrs: that.attrs
+                            }).then(function (res) {
+                                if (res.status == 200 && res.data.code == 200) {
+                                    $eb.message('success', res.data.msg || '清空成功!');
+                                    window.location.reload();
+                                } else {
+                                    $eb.message('error', res.data.msg || '清空失败!');
+                                }
+                            }).catch(function (err) {
+                                $eb.message('error', err);
+                            })
+                        }).catch(console.log);
+                    });
+                }
+            },
+            mounted (){
+                _vm = this;
+                var resultAdmin = <?php echo $result && isset($result['attr']) && !empty($result['attr']) ? json_encode($result['attr']) : 'false'; ?>;
+                if(resultAdmin) this.hidden = true;
+
+                window.changeIMG = (index,pic)=>{
+                    _vm.setAttrPic(index,pic);
+                };
+            }
+        }).$mount(document.getElementById('store-attr'));
+    });
+</script>
+</body>

+ 233 - 0
app/admin/view/store/store_product_check/bill.php

@@ -0,0 +1,233 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="layui-fluid" style="background: #fff;margin-top: -10px;">
+
+    <div class="layui-row layui-col-space15"  id="app">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-form-item">
+                            <div class="layui-inline">
+                                <label class="layui-form-label">状态:</label>
+                                <div class="layui-input-inline">
+                                    <select name="status" lay-verify="status">
+                                        <option value="-2">全部</option>
+                                        <option value="0">待审核</option>
+                                        <option value="1">通过</option>
+                                        <option value="-1">拒绝</option>
+                                    </select>
+                                </div>
+                            </div>
+
+                            <div class="layui-inline">
+                                <label class="layui-form-label">商品条型码</label>
+                                <div class="layui-input-block">
+                                    <input type="text" name="key" class="layui-input" placeholder="条型码">
+                          
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <div class="layui-input-inline">
+                                    <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
+                                        <i class="layui-icon layui-icon-search"></i>搜索</button>
+                                </div>
+                            </div>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
+        </div>
+        <div class="layui-btn-group conrelTable">
+            <button class="layui-btn layui-btn-sm layui-btn-normal" type="button" data-type="set_group"><i class="fa fa-check-circle-o" ></i>批量审核</button>
+        </div>
+        <!--商品列表-->
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <!--图片-->
+                    <script type="text/html" id="image">
+                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    </script>
+                    <!--商品名称-->
+                    <script type="text/html" id="store_name">
+                        <h4>{{d.store_name}}</h4>
+                        <p>价格:<font color="red">{{d.price}}</font> </p>
+                    </script>
+                    <!--操作-->
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='auth'>
+                                    <i class="fa fa-trash"></i> 审核
+                                </a>
+                            </li>
+                        </ul>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+<script>
+
+    //实例化form
+    layList.form.render();
+    //加载列表
+    layList.tableList('List',"{:Url('bill_lst')}",function (){
+        var join=new Array();
+        join=[
+                    {type:'checkbox'},
+                    {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
+                    {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
+                    {field: 'store_name', title: '商品名称',templet:'#store_name'},
+                    {field: 'in_stock', title: '入库',width:'8%'},
+                    {field: 'add_time', title: '入库时间',width:'8%'},
+                    {field: 'status', title: '状态',templet:"#checkboxstatus",width:'8%'},
+                    {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
+                ];
+        
+        return join;
+    })
+
+
+    //下拉框
+    $(document).click(function (e) {
+        $('.layui-nav-child').hide();
+    })
+    function dropdown(that){
+        var oEvent = arguments.callee.caller.arguments[0] || event;
+        oEvent.stopPropagation();
+        var offset = $(that).offset();
+        var top=offset.top-$(window).scrollTop();
+        var index = $(that).parents('tr').data('index');
+        $('.layui-nav-child').each(function (key) {
+            if (key != index) {
+                $(this).hide();
+            }
+        })
+        if($(document).height() < top+$(that).next('ul').height()){
+            $(that).next('ul').css({
+                'padding': 10,
+                'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        }else{
+            $(that).next('ul').css({
+                'padding': 10,
+                'top':$(that).parent('td').height() / 2 + $(that).height(),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        }
+    }
+    //快速编辑
+    layList.edit(function (obj) {
+        var id=obj.data.id,value=obj.value;
+        switch (obj.field) {
+            case 'price':
+                action.set_product('price',id,value);
+                break;
+            case 'stock':
+                action.set_product('stock',id,value);
+                break;
+            case 'sort':
+                action.set_product('sort',id,value);
+                break;
+            case 'ficti':
+                action.set_product('ficti',id,value);
+                break;
+        }
+    });
+    //上下加商品
+    layList.switch('is_show',function (odj,value) {
+        if(odj.elem.checked==true){
+            layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:1,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }else{
+            layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:0,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }
+    });
+    //点击事件绑定
+    layList.tool(function (event,data,obj) {
+        switch (event) {
+
+            case 'auth':
+                $eb.createModalFrame('编辑',layList.Url({a:'audit',p:{id:data.id}}));
+                break;
+
+        }
+    })
+    //排序
+    layList.sort(function (obj) {
+        var type = obj.type;
+        switch (obj.field){
+            case 'id':
+                layList.reload({order: layList.order(type,'id')},true,null,obj);
+                break;
+            case 'sales':
+                layList.reload({order: layList.order(type,'sales')},true,null,obj);
+                break;
+        }
+    });
+    //查询
+    layList.search('search',function(where){
+        layList.reload(where,true);
+    });
+    //自定义方法
+    var action={
+        set_product:function(field,id,value){
+            layList.baseGet(layList.Url({c:'store.store_product',a:'set_product',q:{field:field,id:id,value:value}}),function (res) {
+                layList.msg(res.msg);
+            });
+        },
+        show:function(){
+            var ids=layList.getCheckData().getIds('id');
+            if(ids.length){
+                layList.basePost(layList.Url({c:'store.store_product',a:'product_show'}),{ids:ids},function (res) {
+                    layList.msg(res.msg);
+                    layList.reload();
+                });
+            }else{
+                layList.msg('请选择要上架的商品');
+            }
+        },
+        "set_group":function () {
+            var ids=layList.getCheckData().getIds('id');
+            if(ids.length){
+                var str = ids.join(',');
+                $eb.createModalFrame('批量设置分组',layList.Url({a:'batch_audit',p:{id:str}}),{w:500,h:300});
+            }else{
+                layList.msg('请选择要批量设置分组的会员');
+            }
+        }
+    };
+    //多选事件绑定
+    $('.layui-btn-container').find('button').each(function () {
+        var type=$(this).data('type');
+        $(this).on('click',function(){
+            action[type] && action[type]();
+        })
+    });
+    $('.conrelTable').find('button').each(function () {
+        var type=$(this).data('type');
+        $(this).on('click',function () {
+            action[type] && action[type]();
+        })
+    })
+
+</script>
+{/block}

+ 34 - 0
app/admin/view/store/store_product_check/collect.php

@@ -0,0 +1,34 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox">
+            <div class="ibox-content">
+                <div class="table-responsive">
+                    <table class="table table-striped  table-bordered">
+                        <thead>
+                        <tr>
+                            <th class="text-center">点赞人</th>
+                            <th class="text-center">点赞时间</th>
+                        </tr>
+                        </thead>
+                        <tbody class="">
+                        {volist name="list" id="vo"}
+                        <tr>
+                            <td class="text-center">
+                                {$vo.nickname}
+                            </td>
+                            <td class="text-center">
+                                {$vo.add_time|date='Y-m-d H:i:s'}
+                            </td>
+                        </tr>
+                        {/volist}
+                        </tbody>
+                    </table>
+                </div>
+                {include file="public/inner_page"}
+            </div>
+        </div>
+    </div>
+</div>
+{/block}

+ 333 - 0
app/admin/view/store/store_product_check/consumer.php

@@ -0,0 +1,333 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="layui-fluid" style="background: #fff;margin-top: -10px;">
+    <div class="layui-tab layui-tab-brief" lay-filter="tab">
+        <ul class="layui-tab-title">
+            <li lay-id="list" {eq name='type' value='1'}class="layui-this" {/eq} >
+                <a href="{eq name='type' value='1'}javascript:;{else}{:Url('index',['type'=>1])}{/eq}">出售中商品({$onsale})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='2'}class="layui-this" {/eq}>
+                <a href="{eq name='type' value='2'}javascript:;{else}{:Url('index',['type'=>2])}{/eq}">仓库中商品({$forsale})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='4'}class="layui-this" {/eq}>
+                <a href="{eq name='type' value='4'}javascript:;{else}{:Url('index',['type'=>4])}{/eq}">已经售馨商品({$outofstock})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='5'}class="layui-this" {/eq}>
+                <a href="{eq name='type' value='5'}javascript:;{else}{:Url('index',['type'=>5])}{/eq}">警戒库存({$policeforce})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='6'}class="layui-this" {/eq}>
+                <a href="{eq name='type' value='6'}javascript:;{else}{:Url('index',['type'=>6])}{/eq}">商品回收站({$recycle})</a>
+            </li>
+        </ul>
+    </div>
+    <div class="layui-row layui-col-space15"  id="app">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-form-item">
+                            <div class="layui-inline">
+                                <label class="layui-form-label">所有分类</label>
+                                <div class="layui-input-block">
+                                    <select name="cate_id">
+                                        <option value=" ">全部</option>
+                                        {volist name='cate' id='vo'}
+                                        <option value="{$vo.id}">{$vo.html}{$vo.cate_name}</option>
+                                        {/volist}
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <label class="layui-form-label">商品名称</label>
+                                <div class="layui-input-block">
+                                    <input type="text" name="store_name" class="layui-input" placeholder="请输入商品名称,关键字,编号">
+                                    <input type="hidden" name="type" value="{$type}">
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <div class="layui-input-inline">
+                                    <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
+                                        <i class="layui-icon layui-icon-search"></i>搜索</button>
+                                    <button class="layui-btn layui-btn-primary layui-btn-sm export"  lay-submit="export" lay-filter="export">
+                                        <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出</button>
+                                </div>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+        </div>
+        <!--商品列表-->
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="alert alert-info" role="alert">
+                        列表[虚拟销量],[库存],[排序]可进行快速修改,双击或者单击进入编辑模式,失去焦点可进行自动保存
+                        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                    </div>
+                    <div class="layui-btn-container">
+                        {switch name='type'}
+                            {case value="1"}
+                                <a class="layui-btn layui-btn-sm" href="{:Url('create',['consumer'=>1])}">添加商品</a>
+                            {/case}
+                            {case value="2"}
+                                <button class="layui-btn layui-btn-sm" data-type="show">批量上架</button>
+                            {/case}
+                        {/switch}
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <!--图片-->
+                    <script type="text/html" id="image">
+                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    </script>
+                    <!--上架|下架-->
+                    <script type="text/html" id="checkboxstatus">
+                        <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='上架|下架'  {{ d.is_show == 1 ? 'checked' : '' }}>
+                    </script>
+                    <!--收藏-->
+                    <script type="text/html" id="like">
+                        <span><i class="layui-icon layui-icon-praise"></i> {{d.like}}</span>
+                    </script>
+                    <!--点赞-->
+                    <script type="text/html" id="collect">
+                        <span><i class="layui-icon layui-icon-star"></i> {{d.collect}}</span>
+                    </script>
+                    <!--商品名称-->
+                    <script type="text/html" id="store_name">
+                        <h4>{{d.store_name}}</h4>
+                        <p>价格:<font color="red">{{d.price}}</font> </p>
+                        {{# if(d.cate_name!=''){ }}
+                        <p>分类:{{d.cate_name}}</p>
+                        {{# } }}
+                    </script>
+                    <!--操作-->
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
+                            编辑
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            {{# if(d.is_del){ }}
+                            <li>
+                                <a href="javascript:void(0);" lay-event='delstor'>
+                                    <i class="fa fa-trash"></i> 恢复商品
+                                </a>
+                            </li>
+                            {{# }else{ }}
+                            <li>
+                                <a href="javascript:void(0);" lay-event='delstor'>
+                                    <i class="fa fa-trash"></i> 移到回收站
+                                </a>
+                            </li>
+                            {{# } }}
+                            <li>
+                                <a href="{:Url('store.storeProductReply/index')}?product_id={{d.id}}">
+                                    <i class="fa fa-warning"></i> 评论查看
+                                </a>
+                            </li>
+                        </ul>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+<script>
+    var type=<?=$type?>;
+    //实例化form
+    layList.form.render();
+    //加载列表
+    layList.tableList('List',"{:Url('product_ist',['type'=>$type,'is_consumer'=>1])}",function (){
+        var join=new Array();
+        switch (parseInt(type)){
+            case 1:case 3:case 4:case 5:
+                join=[
+                    {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
+                    {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
+                    {field: 'store_name', title: '商品名称',templet:'#store_name'},
+                    {field: 'ficti', title: '虚拟销量',edit:'ficti',width:'8%'},
+                    {field: 'stock', title: '库存',width:'8%'},
+                    {field: 'sort', title: '排序',edit:'sort',width:'6%'},
+                    {field: 'sales', title: '销量',sort: true,event:'sales',width:'8%'},
+                    {field: 'status', title: '状态',templet:"#checkboxstatus",width:'8%'},
+                    {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
+                ];
+                break;
+            case 2:
+                join=[
+                    {type:'checkbox'},
+                    {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
+                    {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
+                    {field: 'store_name', title: '商品名称',templet:'#store_name'},
+                    {field: 'price', title: '价格',edit:'price',width:'8%'},
+                    {field: 'ficti', title: '虚拟销量',edit:'ficti',width:'8%'},
+                    {field: 'stock', title: '库存',width:'6%'},
+                    {field: 'sort', title: '排序',edit:'sort',width:'6%'},
+                    {field: 'sales', title: '销量',sort: true,event:'sales',width:'6%'},
+                    {field: 'status', title: '状态',templet:"#checkboxstatus",width:'8%'},
+                    {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
+                ];
+                break;
+            case 6:
+                join=[
+                    {field: 'id', title: '商品ID', sort: true,event:'id'},
+                    {field: 'image', title: '商品图片',templet:'#image'},
+                    {field: 'store_name', title: '商品名称',templet:'#store_name'},
+                    {field: 'price', title: '商品价格',edit:'price'},
+                    {field: 'ficti', title: '虚拟销量',edit:'ficti'},
+                    {field: 'stock', title: '库存'},
+                    {field: 'sort', title: '排序',edit:'sort'},
+                    {field: 'sales', title: '销量',sort: true,event:'sales'},
+//                    {field: 'status', title: '状态',templet:"#checkboxstatus"},
+                    {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
+                ];
+                break;
+        }
+        return join;
+    })
+    //excel下载
+    layList.search('export',function(where){
+        where.excel = 1;
+        location.href=layList.U({c:'store.store_product',a:'product_ist',q:where});
+    })
+    //下拉框
+    $(document).click(function (e) {
+        $('.layui-nav-child').hide();
+    })
+    function dropdown(that){
+        var oEvent = arguments.callee.caller.arguments[0] || event;
+        oEvent.stopPropagation();
+        var offset = $(that).offset();
+        var top=offset.top-$(window).scrollTop();
+        var index = $(that).parents('tr').data('index');
+        $('.layui-nav-child').each(function (key) {
+            if (key != index) {
+                $(this).hide();
+            }
+        })
+        if($(document).height() < top+$(that).next('ul').height()){
+            $(that).next('ul').css({
+                'padding': 10,
+                'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        }else{
+            $(that).next('ul').css({
+                'padding': 10,
+                'top':$(that).parent('td').height() / 2 + $(that).height(),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        }
+    }
+    //快速编辑
+    layList.edit(function (obj) {
+        var id=obj.data.id,value=obj.value;
+        switch (obj.field) {
+            case 'price':
+                action.set_product('price',id,value);
+                break;
+            case 'stock':
+                action.set_product('stock',id,value);
+                break;
+            case 'sort':
+                action.set_product('sort',id,value);
+                break;
+            case 'ficti':
+                action.set_product('ficti',id,value);
+                break;
+        }
+    });
+    //上下加商品
+    layList.switch('is_show',function (odj,value) {
+        if(odj.elem.checked==true){
+            layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:1,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }else{
+            layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:0,id:value}}),function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }
+    });
+    //点击事件绑定
+    layList.tool(function (event,data,obj) {
+        switch (event) {
+            case 'delstor':
+                var url=layList.U({c:'store.store_product',a:'delete',q:{id:data.id}});
+                if(data.is_del) var code = {title:"操作提示",text:"确定恢复商品操作吗?",type:'info',confirm:'是的,恢复该商品'};
+                else var code = {title:"操作提示",text:"确定将该商品移入回收站吗?",type:'info',confirm:'是的,移入回收站'};
+                $eb.$swal('delete',function(){
+                    $eb.axios.get(url).then(function(res){
+                        if(res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success',res.data.msg);
+                            obj.del();
+                            location.reload();
+                        }else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function(err){
+                        $eb.$swal('error',err);
+                    });
+                },code)
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'edit':
+                location.href = layList.U({a:'create',q:{id:data.id}});
+                break;
+            case 'attr':
+                $eb.createModalFrame(data.store_name+'-属性',layList.U({a:'attr',q:{id:data.id}}),{h:600,w:800})
+                break;
+        }
+    })
+    //排序
+    layList.sort(function (obj) {
+        var type = obj.type;
+        switch (obj.field){
+            case 'id':
+                layList.reload({order: layList.order(type,'id')},true,null,obj);
+                break;
+            case 'sales':
+                layList.reload({order: layList.order(type,'sales')},true,null,obj);
+                break;
+        }
+    });
+    //查询
+    layList.search('search',function(where){
+        layList.reload(where,true);
+    });
+    //自定义方法
+    var action={
+        set_product:function(field,id,value){
+            layList.baseGet(layList.Url({c:'store.store_product',a:'set_product',q:{field:field,id:id,value:value}}),function (res) {
+                layList.msg(res.msg);
+            });
+        },
+        show:function(){
+            var ids=layList.getCheckData().getIds('id');
+            if(ids.length){
+                layList.basePost(layList.Url({c:'store.store_product',a:'product_show'}),{ids:ids},function (res) {
+                    layList.msg(res.msg);
+                    layList.reload();
+                });
+            }else{
+                layList.msg('请选择要上架的商品');
+            }
+        }
+    };
+    //多选事件绑定
+    $('.layui-btn-container').find('button').each(function () {
+        var type=$(this).data('type');
+        $(this).on('click',function(){
+            action[type] && action[type]();
+        })
+    });
+</script>
+{/block}

+ 1780 - 0
app/admin/view/store/store_product_check/create.php

@@ -0,0 +1,1780 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+    <link href="{__FRAME_PATH}css/font-awesome.min.css" rel="stylesheet">
+    <link href="{__ADMIN_PATH}plug/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
+    <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/jquery.min.js"></script>
+    <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/template.min.js"></script>
+    <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.config.js"></script>
+    <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.min.js"></script>
+    <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/lang/zh-cn/zh-cn.js"></script>
+    <link rel="stylesheet" href="/static/plug/layui/css/layui.css">
+    <script src="/static/plug/layui/layui.js"></script>
+    <script src="{__PLUG_PATH}vue/dist/vue.min.js"></script>
+    <script src="/static/plug/axios.min.js"></script>
+    <script src="{__MODULE_PATH}widget/aliyun-oss-sdk-4.4.4.min.js"></script>
+    <script src="{__MODULE_PATH}widget/cos-js-sdk-v5.min.js"></script>
+    <script src="{__MODULE_PATH}widget/qiniu-js-sdk-2.5.5.js"></script>
+    <script src="{__MODULE_PATH}widget/plupload.full.min.js"></script>
+    <script src="{__MODULE_PATH}widget/videoUpload.js"></script>
+    <style>
+        .layui-form-item {
+            margin-bottom: 0px;
+        }
+
+        .pictrueBox {
+            display: inline-block !important;
+        }
+
+        .pictrue {
+            width: 60px;
+            height: 60px;
+            border: 1px dotted rgba(0, 0, 0, 0.1);
+            margin-right: 15px;
+            display: inline-block;
+            position: relative;
+            cursor: pointer;
+        }
+
+        .pictrue img {
+            width: 100%;
+            height: 100%;
+        }
+
+        .upLoad {
+            width: 58px;
+            height: 58px;
+            line-height: 58px;
+            border: 1px dotted rgba(0, 0, 0, 0.1);
+            border-radius: 4px;
+            background: rgba(0, 0, 0, 0.02);
+            cursor: pointer;
+            display: flex;
+            justify-content: center;
+            align-items: center;
+        }
+
+        .rulesBox {
+            display: flex;
+            flex-wrap: wrap;
+            margin-left: 10px;
+        }
+
+        .layui-tab-content {
+            margin-top: 15px;
+        }
+
+        .ml110 {
+            margin: 18px 0 4px 110px;
+        }
+
+        .rules {
+            display: flex;
+        }
+
+        .rules-btn-sm {
+            height: 30px;
+            line-height: 30px;
+            font-size: 12px;
+            width: 109px;
+        }
+
+        .rules-btn-sm input {
+            width: 79% !important;
+            height: 84% !important;
+            padding: 0 10px;
+        }
+
+        .ml10 {
+            margin-left: 10px !important;
+        }
+
+        .ml40 {
+            margin-left: 40px !important;
+        }
+
+        .closes {
+            position: absolute;
+            left: 86%;
+            top: -18%;
+        }
+
+        .red {
+            color: red;
+        }
+
+        .layui-input-block .layui-video-box {
+            width: 22%;
+            height: 180px;
+            border-radius: 10px;
+            background-color: #707070;
+            margin-top: 10px;
+            position: relative;
+            overflow: hidden;
+        }
+
+        .layui-input-block .layui-video-box i {
+            color: #fff;
+            line-height: 180px;
+            margin: 0 auto;
+            width: 50px;
+            height: 50px;
+            display: inherit;
+            font-size: 50px;
+        }
+
+        .layui-input-block .layui-video-box .mark {
+            position: absolute;
+            width: 100%;
+            height: 30px;
+            top: 0;
+            background-color: rgba(0, 0, 0, .5);
+            text-align: center;
+        }
+
+        .store_box {
+            display: flex;
+        }
+
+        .info {
+            color: #c9c9c9;
+            padding-left: 10px;
+            line-height: 30px;
+        }
+    </style>
+</head>
+<body>
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15" id="app" v-cloak="">
+        <div class="layui-card">
+            <div class="layui-card-header">
+                <span class="">{{id ? '商品修改' : '商品添加' }}</span>
+                <button style="margin-left: 20px" type="button" class="layui-btn layui-btn-primary layui-btn-xs"
+                        @click="goBack">返回列表
+                </button>
+            </div>
+            <div class="layui-card-body">
+                <form class="layui-form" action="" v-cloak="">
+                    <div class="layui-tab layui-tab-brief" lay-filter="docTabBrief">
+                        <ul class="layui-tab-title">
+                            <li class="layui-this" lay-id='1'>基础信息</li>
+                            <li lay-id='2'>商品详情</li>
+                            <li lay-id='3'>其他设置</li>
+                        </ul>
+                        <div class="layui-tab-content">
+                            <div class="layui-tab-item layui-show">
+                                <div class="layui-row layui-col-space15">
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品分类<i class="red">*</i></label>
+                                                <div class="layui-input-block" id="cate_id">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品名称<i class="red">*</i></label>
+                                                <div class="layui-input-block">
+                                                    <input type="text" name="store_name" lay-verify="title"
+                                                           autocomplete="off"
+                                                           placeholder="请输入商品名称" class="layui-input"
+                                                           v-model="formData.store_name" maxlength="100">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品关键字</label>
+                                                <div class="layui-input-block">
+                                                    <input style="width: 40%" type="text" name="keyword"
+                                                           lay-verify="title" autocomplete="off"
+                                                           placeholder="请输入商品关键字" class="layui-input"
+                                                           v-model="formData.keyword">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">单位</label>
+                                                <div class="layui-input-block">
+                                                    <input style="width: 40%" type="text" name="unit_name"
+                                                           lay-verify="title" autocomplete="off"
+                                                           placeholder="请输入单位" class="layui-input"
+                                                           v-model="formData.unit_name">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item layui-form-text">
+                                                <label class="layui-form-label">商品简介</label>
+                                                <div class="layui-input-block">
+                                                    <textarea name="store_info" v-model="formData.store_info"
+                                                              placeholder="请输入商品简介" class="layui-textarea"></textarea>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-form-item submit">
+                                        <label class="layui-form-label">主图视频</label>
+                                        <div class="layui-input-block">
+                                            <input type="text" name="link_key" v-model="videoLink"
+                                                   style="width:50%;display:inline-block;margin-right: 10px;"
+                                                   autocomplete="off" placeholder="请输入视频链接" class="layui-input">
+                                            <button type="button" @click="uploadVideo"
+                                                    class="layui-btn layui-btn-sm layui-btn-normal">
+                                                {{videoLink ? '确认添加' : '上传视频'}}
+                                            </button>
+                                            <input ref="filElem" type="file" style="display: none">
+                                        </div>
+                                        <div class="layui-input-block video_show" style="width: 30%;margin-top: 20px;"
+                                             v-if="upload.videoIng">
+                                            <div class="layui-progress" style="margin-bottom: 10px">
+                                                <div class="layui-progress-bar layui-bg-blue"
+                                                     :style="'width:'+progress+'%'"></div>
+                                            </div>
+                                            <button type="button"
+                                                    class="layui-btn layui-btn-sm layui-btn-danger percent">
+                                                {{progress}}%
+                                            </button>
+                                        </div>
+                                        <div class="layui-input-block" v-if="formData.video_link">
+                                            <div class="layui-video-box" v-if="formData.video_link">
+                                                <video style="width:100%;height: 100%!important;border-radius: 10px;"
+                                                       :src="formData.video_link" controls="controls">
+                                                    您的浏览器不支持 video 标签。
+                                                </video>
+                                                <div class="mark" @click="delVideo">
+                                                    <span class="layui-icon layui-icon-delete"
+                                                          style="font-size: 30px; color: #1E9FFF;"></span>
+                                                </div>
+
+                                            </div>
+                                            <div class="layui-video-box" v-else>
+                                                <i class="layui-icon layui-icon-play"></i>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品封面图<i class="red">*</i></label>
+                                                <div class="pictrueBox">
+                                                    <div class="pictrue" v-if="formData.image"
+                                                         @click="uploadImage('image')">
+                                                        <img :src="formData.image"></div>
+                                                    <div class="upLoad" @click="uploadImage('image')" v-else>
+                                                        <i class="layui-icon layui-icon-camera" class="iconfont"
+                                                           style="font-size: 26px;"></i>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品轮播图<i class="red">*</i></label>
+                                                <div class="pictrueBox pictrue"
+                                                     v-for="(item,index) in formData.slider_image">
+                                                    <img :src="item">
+                                                    <i class="layui-icon closes"
+                                                       @click="deleteImage('slider_image',index)">&#x1007</i>
+                                                </div>
+                                                <div class="pictrueBox">
+                                                    <div class="upLoad" @click="uploadImage('slider_image')"
+                                                         v-if="formData.slider_image.length <= rule.slider_image.maxLength">
+                                                        <i class="layui-icon layui-icon-camera" class="iconfont"
+                                                           style="font-size: 26px;"></i>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品规格<i class="red">*</i></label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="spec_type" value="0" title="单规格"
+                                                           lay-filter="spec_type"
+                                                           :checked="formData.spec_type == 0 ? true : false">
+                                                    <input type="radio" name="spec_type" value="1" title="多规格"
+                                                           lay-filter="spec_type"
+                                                           :checked="formData.spec_type == 1 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
+                                         v-if="formData.spec_type == 0">
+
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label"></label>
+                                                <div class="layui-input-block">
+                                                    <table class="layui-table">
+                                                        <thead>
+                                                        <tr>
+                                                            <th>图片<i class="red">*</i></th>
+                                                            <th>售价<i class="red">*</i></th>
+                                                            <th>成本价</th>
+                                                            <th>原价<i class="red">*</i></th>
+                                                            <th>库存<i class="red">*</i></th>
+                                                            <th>产品编号</th>
+                                                            <th>重量(KG)</th>
+                                                            <th>体积(m³)</th>
+                                                        </tr>
+                                                        </thead>
+                                                        <tr>
+                                                            <td>
+                                                                <div class="pictrueBox">
+                                                                    <div class="pictrue" v-if="formData.attr.pic"
+                                                                         @click="uploadImage('attr.pic')"><img
+                                                                                :src="formData.attr.pic"></div>
+                                                                    <div class="upLoad" @click="uploadImage('attr.pic')"
+                                                                         v-else>
+                                                                        <i class="layui-icon layui-icon-camera"
+                                                                           class="iconfont"
+                                                                           style="font-size: 26px;"></i>
+                                                                    </div>
+                                                                </div>
+                                                            </td>
+                                                            <td><input type="text" v-model="formData.attr.price"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.cost"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.ot_price"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.stock"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.bar_code"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.weight"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.volume"
+                                                                       class="layui-input"></td>
+                                                        </tr>
+                                                    </table>
+                                                </div>
+                                            </div>
+                                        </div>
+
+                                    </div>
+                                    <!-- 多规格-->
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
+                                         v-if="formData.spec_type == 1">
+                                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
+                                            <div class="grid-demo grid-demo-bg1" style="margin-bottom: 10px;">
+                                                <div class="layui-form-item">
+                                                    <label class="layui-form-label">选择规格<i class="red">*</i></label>
+                                                    <div class="layui-input-block selected store_box">
+                                                        <select name="ruleIndex" lay-filter="rule_index">
+                                                            <option value="-1">请选择</option>
+                                                            <option :value="index" v-for="(item,index) in ruleList">
+                                                                {{item.rule_name}}
+                                                            </option>
+                                                        </select>
+                                                        <button type="button" style="height: 38px;border-left: 0;"
+                                                                class="layui-btn layui-btn-sm" @click="allRule">确认
+                                                        </button>
+                                                        <button type="button" style="height: 38px;"
+                                                                class="layui-btn layui-btn-sm layui-btn-primary"
+                                                                @click="addRule">添加规则
+                                                        </button>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </div>
+                                        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                            <div class="grid-demo grid-demo-bg1" v-for="(item,index) in formData.items">
+                                                <div class="ml110"><span>{{item.value}}</span><i class="layui-icon"
+                                                                                                 @click="deleteItem(index)">&#x1007;</i>
+                                                </div>
+                                                <div class="layui-form-item rules">
+                                                    <!--                                                    <label class="layui-form-label"></label>-->
+                                                    <div class="layui-input-block">
+                                                        <div style="overflow: visible;text-overflow: inherit;white-space: normal;border-left: 0;">
+                                                            <button type="button"
+                                                                    class="layui-btn layui-btn-primary layui-btn-sm"
+                                                                    v-for="(val,inx) in item.detail">
+                                                                {{val}}
+                                                                <i class="layui-icon layui-icon-close"
+                                                                   @click="deleteValue(item,inx)"></i>
+                                                            </button>
+                                                        </div>
+                                                        <div class="rules rulesBox">
+                                                            <div class="rules-btn-sm">
+                                                                <input type="text" v-model="item.detailValue"
+                                                                       name="title"
+                                                                       autocomplete="off" placeholder="请输入">
+                                                            </div>
+                                                            <button class="layui-btn layui-btn-sm" type="button"
+                                                                    @click="addDetail(item)">添加
+                                                            </button>
+                                                        </div>
+                                                    </div>
+
+                                                </div>
+                                            </div>
+                                            <div class="grid-demo grid-demo-bg1 rules" style="margin-top: 24px;"
+                                                 v-if="newRule">
+                                                <div class="layui-form-item layui-form-text rules">
+                                                    <label class="layui-form-label">规格:</label>
+                                                    <div class="rules-btn-sm">
+                                                        <input type="text" name="title" v-model="formDynamic.attrsName"
+                                                               autocomplete="off" placeholder="请输入规格">
+                                                    </div>
+                                                </div>
+                                                <div class="layui-form-item layui-form-text rules">
+                                                    <label class="layui-form-label">规格值:</label>
+                                                    <div class="rules-btn-sm">
+                                                        <input type="text" name="title" v-model="formDynamic.attrsVal"
+                                                               autocomplete="off" placeholder="请输入规格值">
+                                                    </div>
+                                                </div>
+                                                <button class="layui-btn layui-btn-sm ml40" type="button"
+                                                        @click="createAttrName">添加
+                                                </button>
+                                                <button class="layui-btn layui-btn-sm ml10" type="button"
+                                                        @click="newRule = false">取消
+                                                </button>
+                                            </div>
+                                            <div class="grid-demo grid-demo-bg1"
+                                                 style="margin-top: 20px;margin-bottom: 10px;"
+                                                 v-if="newRule == false && ruleBool">
+                                                <div class="layui-form-item">
+                                                    <label class="layui-form-label"></label>
+                                                    <button class="layui-btn layui-btn-sm" type="button"
+                                                            @click="newRule = true">
+                                                        添加新规格
+                                                    </button>
+                                                    <button class="layui-btn layui-btn-sm" type="button"
+                                                            @click="generates">立即生成
+                                                    </button>
+                                                </div>
+                                            </div>
+                                        </div>
+                                        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
+                                             v-if="formData.attrs.length && formHeader.length">
+
+                                            <div class="grid-demo grid-demo-bg1" style="margin-top: 20px">
+                                                <div class="layui-form-item">
+                                                    <label class="layui-form-label">批量设置:</label>
+                                                    <div class="layui-input-block">
+                                                        <table class="layui-table">
+                                                            <thead>
+                                                            <tr>
+                                                                <th>图片<i class="red">*</i></th>
+                                                                <th>售价<i class="red">*</i></th>
+                                                                <th>成本价</th>
+                                                                <th>原价<i class="red">*</i></th>
+                                                                <th>库存<i class="red">*</i></th>
+                                                                <th>产品编号</th>
+                                                                <th>重量(KG)</th>
+                                                                <th>体积(m³)</th>
+                                                                <th width="15%" style="text-align: center;">操作</th>
+                                                            </tr>
+                                                            </thead>
+                                                            <tr>
+                                                                <td>
+                                                                    <div class="pictrueBox">
+                                                                        <div class="pictrue" v-if="batchAttr.pic"
+                                                                             @click="uploadImage('batchAttr.pic')"><img
+                                                                                    :src="batchAttr.pic"></div>
+                                                                        <div class="upLoad"
+                                                                             @click="uploadImage('batchAttr.pic')"
+                                                                             v-else>
+                                                                            <i class="layui-icon layui-icon-camera"
+                                                                               class="iconfont"
+                                                                               style="font-size: 26px;"></i>
+                                                                        </div>
+                                                                    </div>
+                                                                </td>
+                                                                <td><input type="text" v-model="batchAttr.price"
+                                                                           class="layui-input"></td>
+                                                                <td><input type="text" v-model="batchAttr.cost"
+                                                                           class="layui-input"></td>
+                                                                <td><input type="text" v-model="batchAttr.ot_price"
+                                                                           class="layui-input"></td>
+                                                                <td>
+                                                                    <input type="text" v-model="batchAttr.stock"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td>
+                                                                    <input type="text" v-model="batchAttr.bar_code"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td>
+                                                                    <input type="text" v-model="batchAttr.weight"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td>
+                                                                    <input type="text" v-model="batchAttr.volume"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td style="text-align: center;">
+                                                                    <button class="layui-btn layui-btn-sm" type="button"
+                                                                            @click="batchAdd">批量修改
+                                                                    </button>
+                                                                    <button class="layui-btn layui-btn-sm layui-btn-danger"
+                                                                            type="button"
+                                                                            @click="batchClear">清空
+                                                                    </button>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </div>
+                                                </div>
+                                            </div>
+
+                                            <div class="grid-demo grid-demo-bg1" style="margin-top: 20px">
+                                                <div class="layui-form-item">
+                                                    <label class="layui-form-label">商品属性:</label>
+                                                    <div class="layui-input-block">
+                                                        <table class="layui-table">
+                                                            <thead>
+                                                            <tr>
+                                                                <th v-for="(item,index) in formHeader"
+                                                                    v-if="item.align">
+                                                                    {{item.title}}
+                                                                </th>
+                                                            </tr>
+                                                            </thead>
+                                                            <tr v-for="(item,index) in formData.attrs">
+                                                                <td v-for="(n,v) in item.detail">{{n}}</td>
+                                                                <td>
+                                                                    <div class="pictrueBox">
+                                                                        <div class="pictrue" v-if="item.pic"
+                                                                             @click="uploadImage('attrs.'+index+'.pic')">
+                                                                            <img
+                                                                                    :src="item.pic"></div>
+                                                                        <div class="upLoad"
+                                                                             @click="uploadImage('attrs.'+index+'.pic')"
+                                                                             v-else>
+                                                                            <i class="layui-icon layui-icon-camera"
+                                                                               class="iconfont"
+                                                                               style="font-size: 26px;"></i>
+                                                                        </div>
+                                                                    </div>
+                                                                </td>
+                                                                <td><input type="number" v-model="item.price"
+                                                                           class="layui-input"></td>
+                                                                <td><input type="number" v-model="item.cost"
+                                                                           class="layui-input"></td>
+                                                                <td><input type="number" v-model="item.ot_price"
+                                                                           class="layui-input"></td>
+                                                                <td><input type="number" v-model="item.stock"
+                                                                           class="layui-input"></td>
+                                                                <td>
+                                                                    <input type="text" v-model="item.bar_code"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td>
+                                                                    <input type="number" v-model="item.weight"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td>
+                                                                    <input type="number" v-model="item.volume"
+                                                                           class="layui-input">
+                                                                </td>
+                                                                <td>
+                                                                    <button class="layui-btn layui-btn-sm" type="button"
+                                                                            @click="deleteAttrs(index)">删除
+                                                                    </button>
+                                                                </td>
+                                                            </tr>
+                                                        </table>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
+                                    <div class="grid-demo grid-demo-bg1">
+                                        <div class="layui-form-item">
+                                            <label class="layui-form-label">运费模板<i class="red">*</i></label>
+                                            <div class="layui-input-block">
+                                                <select name="temp_id" lay-filter="temp_id">
+                                                    <option value="0">请选择</option>
+                                                    <option :value="item.id" v-for="item in tempList"
+                                                            :selected=" item.id == formData.temp_id ? true : false ">
+                                                        {{item.name}}
+                                                    </option>
+                                                </select>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="layui-row layui-col-space15">
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品状态</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_show" lay-filter="is_show" value="1"
+                                                           title="上架"
+                                                           :checked="formData.is_show == 1 ? true : false">
+                                                    <input type="radio" name="is_show" lay-filter="is_show" value="0"
+                                                           title="下架"
+                                                           :checked="formData.is_show == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="layui-tab-item">
+                                <div class="layui-row layui-col-space15">
+                                    <textarea type="text/plain" name="description" id="myEditor" style="width:100%;">{{formData.description}}</textarea>
+                                </div>
+                            </div>
+                            <div class="layui-tab-item">
+                                <div class="layui-row layui-col-space15">
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">虚拟销量</label>
+                                                <div class="layui-input-block">
+                                                    <input type="number" name="ficti" lay-verify="title"
+                                                           autocomplete="off"
+                                                           placeholder="请输入虚拟销量" class="layui-input"
+                                                           v-model="formData.ficti">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">获得积分</label>
+                                                <div class="layui-input-block">
+                                                    <input type="number" name="give_integral" lay-verify="title"
+                                                           autocomplete="off" placeholder="请输入获得积分" class="layui-input"
+                                                           v-model="formData.give_integral">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">抵扣积分</label>
+                                                <div class="layui-input-block">
+                                                    <input type="number" name="max_use_integral" lay-verify="title"
+                                                           autocomplete="off" placeholder="请输入抵扣积分" class="layui-input"
+                                                           v-model="formData.max_use_integral">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">排序</label>
+                                                <div class="layui-input-block">
+                                                    <input type="number" name="sort" lay-verify="title"
+                                                           autocomplete="off"
+                                                           placeholder="请输入排序" class="layui-input"
+                                                           v-model="formData.sort">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">佣金设置</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_sub" lay-filter="is_sub" value="1"
+                                                           title="单独设置"
+                                                           :checked="formData.is_sub == 1 ? true : false">
+                                                    <input type="radio" name="is_sub" lay-filter="is_sub" value="0"
+                                                           title="默认设置"
+                                                           :checked="formData.is_sub == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
+                                         v-if="formData.is_sub == 1 && formData.spec_type == 1">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">批量设置</label>
+                                                <div class="layui-input-block">
+                                                    <input style="width: 20%;display: inline-block;" type="number"
+                                                           name="brokerage" lay-verify="title" autocomplete="off"
+                                                           placeholder="请输入一级返佣" class="layui-input"
+                                                           v-model="brokerage.brokerage">
+                                                    <input style="width: 20%;display: inline-block;" type="number"
+                                                           name="brokerage_two" lay-verify="title" autocomplete="off"
+                                                           placeholder="请输入二级返佣" class="layui-input"
+                                                           v-model="brokerage.brokerage_two">
+                                                    <button class="layui-btn layui-btn-sm" style="height: 38px;"
+                                                            type="button"
+                                                            @click="addBrokerage">批量设置
+                                                    </button>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <!-- 单属性-->
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
+                                         v-if="formData.spec_type == 0 && formData.is_sub == 1">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品属性:</label>
+                                                <div class="layui-input-block">
+                                                    <table class="layui-table">
+                                                        <thead>
+                                                        <tr>
+                                                            <th>图片</th>
+                                                            <th>售价</th>
+                                                            <th>成本价</th>
+                                                            <th>原价</th>
+                                                            <th>库存</th>
+                                                            <th>产品编号</th>
+                                                            <th>重量</th>
+                                                            <th>体积</th>
+                                                            <th>一级返佣</th>
+                                                            <th>二级返佣</th>
+                                                        </tr>
+                                                        </thead>
+                                                        <tr>
+                                                            <td>
+                                                                <div class="pictrueBox">
+                                                                    <div class="pictrue" v-if="formData.attr.pic">
+                                                                        <img :src="formData.attr.pic">
+                                                                    </div>
+                                                                </div>
+                                                            </td>
+                                                            <td>{{formData.attr.price}}</td>
+                                                            <td>{{formData.attr.cost}}</td>
+                                                            <td>{{formData.attr.ot_price}}</td>
+                                                            <td>{{formData.attr.stock}}</td>
+                                                            <td>{{formData.attr.bar_code}}</td>
+                                                            <td>{{formData.attr.weight}}</td>
+                                                            <td>{{formData.attr.volume}}</td>
+                                                            <td><input type="text" v-model="formData.attr.brokerage"
+                                                                       class="layui-input"></td>
+                                                            <td><input type="text" v-model="formData.attr.brokerage_two"
+                                                                       class="layui-input"></td>
+                                                        </tr>
+                                                    </table>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <!-- 单属性结束-->
+                                    <!-- 多属性-->
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
+                                         v-if="formData.attrs.length && formHeader.length && formData.is_sub == 1 && formData.spec_type == 1">
+                                        <div class="grid-demo grid-demo-bg1" style="margin-top: 20px">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">商品属性:</label>
+                                                <div class="layui-input-block">
+                                                    <table class="layui-table">
+                                                        <thead>
+                                                        <tr>
+                                                            <th v-for="(item,index) in formHeader"
+                                                                v-if="item.slot != 'action'">
+                                                                {{item.title}}
+                                                            </th>
+                                                        </tr>
+                                                        </thead>
+                                                        <tr v-for="(item,index) in formData.attrs">
+                                                            <td v-for="(n,v) in item.detail">{{n}}</td>
+                                                            <td>
+                                                                <div class="pictrueBox">
+                                                                    <div class="pictrue" v-if="item.pic"><img
+                                                                                :src="item.pic"></div>
+                                                                </div>
+                                                            </td>
+                                                            <td>{{item.price}}</td>
+                                                            <td>{{item.cost}}</td>
+                                                            <td>{{item.ot_price}}</td>
+                                                            <td>{{item.stock}}</td>
+                                                            <td>{{item.bar_code}}</td>
+                                                            <td>{{item.weight}}</td>
+                                                            <td>{{item.volume}}</td>
+                                                            <td>
+                                                                <input type="number" v-model="item.brokerage"
+                                                                       class="layui-input">
+                                                            </td>
+                                                            <td>
+                                                                <input type="number" v-model="item.brokerage_two"
+                                                                       class="layui-input">
+                                                            </td>
+                                                        </tr>
+                                                    </table>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <!--多属性结束-->
+
+                                    <!--                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">-->
+                                    <!--                                        <div class="grid-demo grid-demo-bg1">-->
+                                    <!--                                            <div class="layui-form-item">-->
+                                    <!--                                                <label class="layui-form-label">商品状态</label>-->
+                                    <!--                                                <div class="layui-input-block">-->
+                                    <!--                                                    <input type="radio" name="is_show" lay-filter="is_show" value="1" title="上架"-->
+                                    <!--                                                           :checked="formData.is_show == 1 ? true : false">-->
+                                    <!--                                                    <input type="radio" name="is_show" lay-filter="is_show" value="0" title="下架"-->
+                                    <!--                                                           :checked="formData.is_show == 0 ? true : false">-->
+                                    <!--                                                </div>-->
+                                    <!--                                            </div>-->
+                                    <!--                                        </div>-->
+                                    <!--                                    </div>-->
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">参与极差</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_award" lay-filter="is_award" value="1"
+                                                           title="开启"
+                                                           :checked="formData.is_award == 1 ? true : false">
+                                                    <input type="radio" name="is_award" lay-filter="is_award" value="0"
+                                                           title="关闭"
+                                                           :checked="formData.is_award == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">热卖单品</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_hot" lay-filter="is_hot" value="1"
+                                                           title="开启"
+                                                           :checked="formData.is_hot == 1 ? true : false">
+                                                    <input type="radio" name="is_hot" lay-filter="is_hot" value="0"
+                                                           title="关闭"
+                                                           :checked="formData.is_hot == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">促销单品</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_benefit" lay-filter="is_benefit"
+                                                           value="1" title="开启"
+                                                           :checked="formData.is_benefit == 1 ? true : false">
+                                                    <input type="radio" name="is_benefit" lay-filter="is_benefit"
+                                                           value="0" title="关闭"
+                                                           :checked="formData.is_benefit == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">精品推荐</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_best" lay-filter="is_best" value="1"
+                                                           title="开启"
+                                                           :checked="formData.is_best == 1 ? true : false">
+                                                    <input type="radio" name="is_best" lay-filter="is_best" value="0"
+                                                           title="关闭"
+                                                           :checked="formData.is_best == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">首发新品</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_new" lay-filter="is_new" value="1"
+                                                           title="开启"
+                                                           :checked="formData.is_new == 1 ? true : false">
+                                                    <input type="radio" name="is_new" lay-filter="is_new" value="0"
+                                                           title="关闭"
+                                                           :checked="formData.is_new == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+                                                <label class="layui-form-label">优品推荐</label>
+                                                <div class="layui-input-block">
+                                                    <input type="radio" name="is_good" lay-filter="is_good" value="1"
+                                                           title="开启"
+                                                           :checked="formData.is_good == 1 ? true : false">
+                                                    <input type="radio" name="is_good" lay-filter="is_good" value="0"
+                                                           title="关闭"
+                                                           :checked="formData.is_good == 0 ? true : false">
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                    </div>
+                                    <div class="layui-row layui-col-space15">
+                                        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                            <div class="grid-demo grid-demo-bg1">
+                                                <div class="layui-form-item">
+                                                    <label class="layui-form-label">活动优先级</label>
+                                                    <div class="layui-input-block">
+                                                        <span class="layui-btn layui-btn-sm layui-btn-normal"
+                                                              :style="'background-color:'+activity[item]"
+                                                              v-for="(item,index) in formData.activity" :key="index"
+                                                              draggable="true"
+                                                              @dragstart="handleDragStart($event, item)"
+                                                              @dragover.prevent="handleDragOver($event, item)"
+                                                              @dragenter="handleDragEnter($event, item)"
+                                                              @dragend="handleDragEnd($event, item)">
+                                                        {{item}}
+                                                    </span>
+                                                        <span class="info">可拖动按钮调整活动的优先展示顺序</span>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="layui-tab-content">
+                            <div class="layui-row layui-col-space15">
+                                <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                    <div class="grid-demo grid-demo-bg1">
+                                        <div class="layui-form-item" v-if="id">
+                                            <button class="layui-btn layui-btn-primary layui-btn-sm" id="submit"
+                                                    type="button" @click="handleSubmit()">保存
+                                            </button>
+                                            <button class="layui-btn layui-btn-primary layui-btn-sm" type="button"
+                                                    @click="back" v-if="layTabId != 1">上一步
+                                            </button>
+                                            <button class="layui-btn layui-btn-normal layui-btn-sm" type="button"
+                                                    v-if="layTabId != 3" @click="next">下一步
+                                            </button>
+                                        </div>
+                                        <div class="layui-form-item" v-else>
+                                            <button class="layui-btn layui-btn-primary layui-btn-sm" type="button"
+                                                    @click="back" v-if="layTabId != 1">上一步
+                                            </button>
+                                            <button class="layui-btn layui-btn-normal layui-btn-sm" type="button"
+                                                    @click="next" v-if="layTabId != 3">下一步
+                                            </button>
+                                            <button class="layui-btn layui-btn-normal layui-btn-sm" id="submit"
+                                                    type="button" v-if="layTabId == 3" @click="handleSubmit()">提交
+                                            </button>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+<script>
+    var id = {$id};
+    new Vue({
+        el: '#app',
+        data: {
+            id: id,
+            //分类列表
+            cateList: [],
+            //运费模板
+            tempList: [],
+            upload: {
+                videoIng: false
+            },
+            formData: {
+                cate_id: [],
+                temp_id: 0,
+                commission: 0,
+                store_name: '',
+                keyword: '',
+                unit_name: '',
+                postage: '',
+                store_info: '',
+                image: '',
+                video_link: '',
+                slider_image: [],
+                price: '',
+                spec_type: 0,
+                attr: {
+                    pic: '',
+                    price: 0,
+                    cost: 0,
+                    ot_price: 0,
+                    stock: 0,
+                    bar_code: '',
+                    weight: 0,
+                    volume: 0,
+                    brokerage: 0,
+                    brokerage_two: 0,
+                },
+                attrs: [],
+                description: '',
+                ficti: 0,
+                give_integral: 0,
+                max_use_integral: 0,
+                sort: 0,
+                is_show: 1,
+                is_hot: 0,
+                is_award: 0,
+                is_benefit: 0,
+                is_best: 0,
+                is_new: 0,
+                is_good: 0,
+                is_sub: 0,
+                items: [
+                    // {
+                    //     value: '',
+                    //     detailValue:'',
+                    //     attrHidden:false,
+                    //     detail:[]
+                    // }
+                ],
+                activity: ['秒杀', '砍价', '拼团'],
+            },
+            videoLink: '',
+            //批量添加属性
+            batchAttr: {
+                pic: '',
+                price: 0,
+                cost: 0,
+                ot_price: 0,
+                stock: 0,
+                bar_code: '',
+                weight: 0,
+                volume: 0,
+            },
+            //多属性header头
+            formHeader: [],
+            // 规格数据
+            formDynamic: {
+                attrsName: '',
+                attrsVal: ''
+            },
+            brokerage: {
+                brokerage: '',
+                brokerage_two: '',
+            },
+            activity: {'秒杀': '#1E9FFF', '砍价': '#189688', '拼团': '#FEB900'},
+            attr: [],//临时属性
+            newRule: false,//是否添加新规则
+            radioRule: ['is_sub', 'is_show', 'is_award', 'is_hot', 'is_benefit', 'is_new', 'is_good', 'is_suit', 'is_best', 'spec_type'],//radio 当选规则
+            rule: { //多图选择规则
+                slider_image: {
+                    maxLength: 5
+                }
+            },
+            ruleList: [],
+            ruleIndex: -1,
+            progress: 0,
+            um: null,//编译器实例化
+            form: null,//layui.form
+            layTabId: 1,
+            ruleBool: id ? true : false,
+            type: 0
+        },
+        watch: {
+            'formData.is_sub': function (n) {
+                if (n == 1) {
+                    this.formHeader.push({title: '一级返佣(元)'});
+                    this.formHeader.push({title: '二级级返佣(元)'});
+                } else {
+                    this.formHeader.pop();
+                    this.formHeader.pop();
+                }
+            },
+            'formData.spec_type': function (n) {
+                if (n) {
+                    this.render();
+                }
+            },
+            // 'formData.image':function (n) {
+            //     if(!this.batchAttr.pic){
+            //         this.batchAttr.pic = n;
+            //     }
+            //     if(!this.formData.attr.pic){
+            //         this.formData.attr.pic = n;
+            //     }
+            // }
+        },
+        methods: {
+            back: function () {
+                var that = this;
+                layui.use(['element'], function () {
+                    layui.element.tabChange('docTabBrief', that.layTabId == 1 ? 1 : parseInt(that.layTabId) - 1);
+                });
+            },
+            next: function () {
+                var that = this;
+                layui.use(['element'], function () {
+                    layui.element.tabChange('docTabBrief', that.layTabId == 3 ? 3 : parseInt(that.layTabId) + 1);
+                });
+            },
+            goBack: function () {
+                location.href = this.U({c: 'store.StoreProductCheck', a: 'index'});
+            },
+            U: function (opt) {
+                var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
+                    p = opt.p || {};
+                var params = Object.keys(p).map(function (key) {
+                    return key + '/' + p[key];
+                }).join('/');
+                var gets = Object.keys(q).map(function (key) {
+                    return key + '=' + q[key];
+                }).join('&');
+
+                return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
+            },
+            /**
+             * 提示
+             * */
+            showMsg: function (msg, success) {
+                $('#submit').removeAttr('disabled').text('提交');
+                layui.use(['layer'], function () {
+                    layui.layer.msg(msg, success);
+                });
+            },
+            addBrokerage: function () {
+                if (this.brokerage.brokerage >= 0 && this.brokerage.brokerage_two >= 0) {
+                    var that = this;
+                    this.$set(this.formData, 'attrs', this.formData.attrs.map(function (item) {
+                        item.brokerage = that.brokerage.brokerage;
+                        item.brokerage_two = that.brokerage.brokerage_two;
+                        return item;
+                    }));
+                } else {
+                    return this.showMsg('请填写返佣金额在进行批量添加');
+                }
+            },
+            batchClear: function () {
+                this.$set(this, 'batchAttr', {
+                    pic: '',
+                    price: 0,
+                    cost: 0,
+                    ot_price: 0,
+                    stock: 0,
+                    bar_code: '',
+                    weight: 0,
+                    volume: 0,
+                });
+            },
+            /**
+             * 批量添加
+             * */
+            batchAdd: function () {
+                var that = this;
+                this.$set(this.formData, 'attrs', this.formData.attrs.map(function (item) {
+                    if (that.batchAttr.pic) {
+                        item.pic = that.batchAttr.pic;
+                    }
+                    if (that.batchAttr.price > 0) {
+                        item.price = that.batchAttr.price;
+                    }
+                    if (that.batchAttr.cost > 0) {
+                        item.cost = that.batchAttr.cost;
+                    }
+                    if (that.batchAttr.ot_price > 0) {
+                        item.ot_price = that.batchAttr.ot_price;
+                    }
+                    if (that.batchAttr.stock > 0) {
+                        item.stock = that.batchAttr.stock;
+                    }
+                    if (that.batchAttr.bar_code != '') {
+                        item.bar_code = that.batchAttr.bar_code;
+                    }
+                    if (that.batchAttr.weight > 0) {
+                        item.weight = that.batchAttr.weight;
+                    }
+                    if (that.batchAttr.volume > 0) {
+                        item.volume = that.batchAttr.volume;
+                    }
+                    return item;
+                }));
+
+            },
+            /**
+             * 获取商品信息
+             * */
+            getProductInfo: function () {
+                var that = this;
+                that.requestGet(that.U({
+                    c: "store.StoreProductCheck",
+                    a: 'get_product_info',
+                    q: {id: that.id, type: that.type}
+                })).then(function (res) {
+                    that.$set(that, 'cateList', res.data.cateList);
+                    that.$set(that, 'tempList', res.data.tempList);
+                    var productInfo = res.data.productInfo || {};
+                    if (productInfo.id && that.id) {
+                        that.$set(that, 'formData', productInfo);
+                        that.generate();
+                    }
+                    that.getRuleList();
+                    that.init();
+                }).catch(function (res) {
+                    that.showMsg(res.msg);
+                })
+            },
+            /**
+             * 给某个属性添加属性值
+             * @param item
+             * */
+            addDetail: function (item) {
+                if (!item.detailValue) return false;
+                if (item.detail.find(function (val) {
+                    if (item.detailValue == val) {
+                        return true;
+                    }
+                })) {
+                    return this.showMsg('添加的属性值重复');
+                }
+                item.detail.push(item.detailValue);
+                item.detailValue = '';
+            },
+            /**
+             * 删除某个属性值
+             * @param item 父级循环集合
+             * @param inx 子集index
+             * */
+            deleteValue: function (item, inx) {
+                if (item.detail.length > 1) {
+                    item.detail.splice(inx, 1);
+                } else {
+                    return this.showMsg('请设置至少一个属性');
+                }
+            },
+            /**
+             * 删除某条属性
+             * @param index
+             * */
+            deleteItem: function (index) {
+                this.formData.items.splice(index, 1);
+            },
+            /**
+             * 删除某条属性
+             * @param index
+             * */
+            deleteAttrs: function (index) {
+                var that = this;
+                if (that.id > 0) {
+                    that.requestGet(that.U({
+                        c: "store.StoreProductCheck",
+                        a: 'check_activity',
+                        q: {id: that.id}
+                    })).then(function (res) {
+                        that.showMsg(res.msg);
+                    }).catch(function (res) {
+                        if (that.formData.attrs.length > 1) {
+                            that.formData.attrs.splice(index, 1);
+                        } else {
+                            return that.showMsg('请设置至少一个规则');
+                        }
+                    })
+                } else {
+                    if (that.formData.attrs.length > 1) {
+                        that.formData.attrs.splice(index, 1);
+                    } else {
+                        return that.showMsg('请设置至少一个规则');
+                    }
+                }
+            },
+            /**
+             * 创建属性
+             * */
+            createAttrName: function () {
+                if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
+                    if (this.formData.items.find(function (val) {
+                        if (val.value == this.formDynamic.attrsName) {
+                            return true;
+                        }
+                    }.bind(this))) {
+                        return this.showMsg('添加的属性重复');
+                    }
+                    this.formData.items.push({
+                        value: this.formDynamic.attrsName,
+                        detailValue: '',
+                        attrHidden: false,
+                        detail: [this.formDynamic.attrsVal]
+                    });
+                    this.formDynamic.attrsName = '';
+                    this.formDynamic.attrsVal = '';
+                    this.newRule = false;
+                } else {
+                    return this.showMsg('请添加完整的规格!');
+                }
+            },
+            /**
+             * 删除图片
+             * */
+            deleteImage: function (key, index) {
+                var that = this;
+                if (index != undefined) {
+                    that.formData[key].splice(index, 1);
+                    that.$set(that.formData, key, that.formData[key]);
+                } else {
+                    that.$set(that.formData, key, '');
+                }
+            },
+            createFrame: function (title, src, opt) {
+                opt === undefined && (opt = {});
+                var h = 0;
+                if (window.innerHeight < 800 && window.innerHeight >= 700) {
+                    h = window.innerHeight - 50;
+                } else if (window.innerHeight < 900 && window.innerHeight >= 800) {
+                    h = window.innerHeight - 100;
+                } else if (window.innerHeight < 1000 && window.innerHeight >= 900) {
+                    h = window.innerHeight - 150;
+                } else if (window.innerHeight >= 1000) {
+                    h = window.innerHeight - 200;
+                } else {
+                    h = window.innerHeight;
+                }
+                var area = [(opt.w || window.innerWidth / 2) + 'px', (!opt.h || opt.h > h ? h : opt.h) + 'px'];
+                layui.use('layer', function () {
+                    return layer.open({
+                        type: 2,
+                        title: title,
+                        area: area,
+                        fixed: false, //不固定
+                        maxmin: true,
+                        moveOut: false,//true  可以拖出窗外  false 只能在窗内拖
+                        anim: 5,//出场动画 isOutAnim bool 关闭动画
+                        offset: 'auto',//['100px','100px'],//'auto',//初始位置  ['100px','100px'] t[ 上 左]
+                        shade: 0,//遮罩
+                        resize: true,//是否允许拉伸
+                        content: src,//内容
+                        move: '.layui-layer-title'
+                    });
+                });
+            },
+            changeIMG: function (name, value) {
+                if (this.getRule(name).maxLength !== undefined) {
+                    var that = this;
+                    value.map(function (v) {
+                        that.formData[name].push(v);
+                    });
+                    this.$set(this.formData, name, this.formData[name]);
+                } else {
+                    if (name == 'batchAttr.pic') {
+                        this.batchAttr.pic = value;
+                    } else {
+                        if (name.indexOf('.') !== -1) {
+                            var key = name.split('.');
+                            if (key.length == 2) {
+                                this.formData[key[0]][key[1]] = value;
+                            } else if (key.length == 3) {
+                                this.formData[key[0]][key[1]][key[2]] = value;
+                            } else if (key.length == 4) {
+                                this.$set(this.formData[key[0]][key[1]][key[2]], key[3], value)
+                            }
+                        } else {
+                            this.formData[name] = value;
+                        }
+                    }
+                }
+            },
+            getRule: function (name) {
+                return this.rule[name] || {};
+            },
+            uploadImage: function (name) {
+                return this.createFrame('选择图片', this.U({c: "widget.images", a: 'index', p: {fodder: name}}), {
+                    h: 545,
+                    w: 900
+                });
+            },
+            uploadVideo: function () {
+                if (this.videoLink) {
+                    this.formData.video_link = this.videoLink;
+                } else {
+                    $(this.$refs.filElem).click();
+                }
+            },
+            delVideo: function () {
+                var that = this;
+                that.$set(that.formData, 'video_link', '');
+            },
+            insertEditor: function (list) {
+                this.um.execCommand('insertimage', list);
+            },
+            insertEditorVideo: function (src) {
+                this.um.setContent('<div><video style="width: 99%" src="' + src + '" class="video-ue" controls="controls" width="100"><source src="' + src + '"></source></video></div><br>', true);
+            },
+            getContent: function () {
+                return this.um.getContent();
+            },
+            /**
+             * 监听radio字段
+             */
+            eeventRadio: function () {
+                var that = this;
+                that.radioRule.map(function (val) {
+                    that.form.on('radio(' + val + ')', function (res) {
+                        that.formData[val] = res.value;
+                    });
+                })
+            },
+            init: function () {
+                var that = this;
+                window.UMEDITOR_CONFIG.toolbar = [
+                    // 加入一个 test
+                    'source | undo redo | bold italic underline strikethrough | superscript subscript | forecolor backcolor | removeformat |',
+                    'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontfamily fontsize',
+                    '| justifyleft justifycenter justifyright justifyjustify |',
+                    'link unlink | emotion selectimgs video  | map',
+                    '| horizontal print preview fullscreen', 'drafts', 'formula'
+                ];
+                UM.registerUI('selectimgs', function (name) {
+                    var me = this;
+                    var $btn = $.eduibutton({
+                        icon: 'image',
+                        click: function () {
+                            that.createFrame('选择图片', "{:Url('widget.images/index',['fodder'=>'editor'])}");
+                        },
+                        title: '选择图片'
+                    });
+
+                    this.addListener('selectionchange', function () {
+                        //切换为不可编辑时,把自己变灰
+                        var state = this.queryCommandState(name);
+                        $btn.edui().disabled(state == -1).active(state == 1)
+                    });
+                    return $btn;
+
+                });
+                UM.registerUI('video', function (name) {
+                    var me = this;
+                    var $btn = $.eduibutton({
+                        icon: 'video',
+                        click: function () {
+                            that.createFrame('选择视频', "{:Url('widget.video/index',['fodder'=>'video'])}");
+                        },
+                        title: '选择视频'
+                    });
+
+                    this.addListener('selectionchange', function () {
+                        //切换为不可编辑时,把自己变灰
+                        var state = this.queryCommandState(name);
+                        $btn.edui().disabled(state == -1).active(state == 1)
+                    });
+                    return $btn;
+
+                });
+                //实例化编辑器
+                this.um = UM.getEditor('myEditor', {initialFrameWidth: '99%', initialFrameHeight: 400});
+                this.um.setContent(that.formData.description);
+                that.$nextTick(function () {
+                    layui.use(['form', 'element'], function () {
+                        that.form = layui.form;
+                        that.form.render();
+                        that.form.on('select(temp_id)', function (data) {
+                            that.$set(that.formData, 'temp_id', data.value);
+                        });
+                        that.form.on('select(rule_index)', function (data) {
+                            that.ruleIndex = data.value;
+                        });
+                        layui.element.on('tab(docTabBrief)', function () {
+                            that.layTabId = this.getAttribute('lay-id');
+                        });
+                        that.eeventRadio();
+                    });
+
+                    layui.config({
+                        base: '/static/plug/layui/'
+                    }).extend({
+                        selectN: './selectN',
+                    }).use('selectM', function () {
+                        var selectM = layui.selectM;
+                        selectM({
+                            //元素容器【必填】
+                            elem: '#cate_id'
+                            //候选数据【必填】
+                            , data: that.cateList
+                            //默认值
+                            , selected: that.formData.cate_id || []
+                            //最多选中个数,默认5
+                            , max: 10
+                            , name: 'cate_id'
+                            , model: 'formData.cate_id'
+                            //值的分隔符
+                            , delimiter: ','
+                            //候选项数据的键名
+                            , field: {idName: 'value', titleName: 'label', statusName: 'disabled'}
+                        });
+                    });
+                })
+            },
+            requestPost: function (url, data) {
+                return new Promise(function (resolve, reject) {
+                    axios.post(url, data).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            resolve(res.data)
+                        } else {
+                            reject(res.data);
+                        }
+                    }).catch(function (err) {
+                        reject({msg: err})
+                    });
+                })
+            },
+            requestGet: function (url) {
+                return new Promise(function (resolve, reject) {
+                    axios.get(url).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            resolve(res.data)
+                        } else {
+                            reject(res.data);
+                        }
+                    }).catch(function (err) {
+                        reject({msg: err})
+                    });
+                })
+            },
+            generates: function () {
+                var that = this;
+                that.generate(1);
+            },
+            generate: function (type = 0) {
+                var that = this;
+                this.requestPost(that.U({
+                    c: "store.StoreProductCheck",
+                    a: 'is_format_attr',
+                    p: {id: that.id, type: type}
+                }), {attrs: this.formData.items}).then(function (res) {
+                    that.$set(that.formData, 'attrs', res.data.value);
+                    that.$set(that, 'formHeader', res.data.header);
+                    if (that.id && that.formData.is_sub == 1 && that.formData.spec_type == 1) {
+                        that.formHeader.push({title: '一级返佣(元)'});
+                        that.formHeader.push({title: '二级级返佣(元)'});
+                    }
+                }).catch(function (res) {
+                    return that.showMsg(res.msg);
+                });
+            },
+            handleSubmit: function () {
+                var that = this, cate_id = $('input[name="cate_id"]').val();
+                if (cate_id != '') {
+                    this.formData.cate_id = cate_id.split(',');
+                }
+                if (!that.formData.cate_id.length) {
+                    return that.showMsg('请选择商品分类');
+                }
+                if (!that.formData.temp_id) {
+                    return that.showMsg('请选择运费模板');
+                }
+                if (!that.formData.store_name) {
+                    return that.showMsg('请填写商品名称');
+                }
+                if (!that.formData.image) {
+                    return that.showMsg('请填选择商品图');
+                }
+                if (!that.formData.slider_image.length) {
+                    return that.showMsg('请填选择商品轮播图');
+                }
+                if (that.formData.spec_type == 0) {
+                    if (!that.formData.attr.pic) {
+                        return that.showMsg('请选择单规则图片');
+                    }
+                    if (that.formData.attr.price == '') {
+                        return that.showMsg('请输入单规格价格');
+                    }
+                    if (that.formData.attr.ot_price == '') {
+                        return that.showMsg('请输入单规格原价');
+                    }
+                    if (!that.formData.attr.stock) {
+                        return that.showMsg('请输入单规格库存');
+                    }
+                    var brokerage_totle = Number(that.formData.attr.brokerage) + Number(that.formData.attr.brokerage_two);
+                    if (brokerage_totle > that.formData.attr.price) {
+                        return that.showMsg('一二级返佣相加不能大于商品售价');
+                    }
+                    var attr = {
+                        pic: that.formData.attr.pic,
+                        price: that.formData.attr.price,
+                        cost: that.formData.attr.cost,
+                        ot_price: that.formData.attr.ot_price,
+                        stock: that.formData.attr.stock,
+                        bar_code: that.formData.attr.bar_code,
+                        volume: that.formData.attr.volume,
+                        weight: that.formData.attr.weight,
+                        brokerage: that.formData.attr.brokerage,
+                        brokerage_two: that.formData.attr.brokerage_two,
+                    };
+                    that.formData.attrs = [attr];
+                } else {
+                    if (!that.formData.attrs.length) {
+                        return that.showMsg('请添加多规格属性');
+                    }
+                    for (var index in that.formData.attrs) {
+                        if (!that.formData.attrs[index].pic) {
+                            return that.showMsg('请选择多规格属性第' + (parseInt(index) + 1) + '条的图片');
+                        }
+                        if (that.formData.attrs[index].price === '') {
+                            return that.showMsg('请填写多规格属性第' + (parseInt(index) + 1) + '条的价格');
+                        }
+                        if (that.formData.attrs[index].ot_price === '') {
+                            return that.showMsg('请填写多规格属性第' + (parseInt(index) + 1) + '条的原价');
+                        }
+                        if (that.formData.attrs[index].stock === '') {
+                            return that.showMsg('请填写多规格属性第' + (parseInt(index) + 1) + '条的库存');
+                        }
+                        var brokerage_totle = Number(that.formData.attrs[index].brokerage) + Number(that.formData.attrs[index].brokerage_two);
+                        if (brokerage_totle > that.formData.attrs[index].price) {
+                            return that.showMsg('第' + (parseInt(index) + 1) + '条的一二级返佣相加不能大于商品售价');
+                        }
+                    }
+                }
+                that.formData.description = that.getContent();
+                $('#submit').attr('disabled', 'disabled').text('保存中...');
+                that.requestPost(that.U({
+                    c: 'store.StoreProductCheck',
+                    a: 'save',
+                    p: {id: that.id}
+                }), that.formData).then(function (res) {
+                    that.confirm();
+                }).catch(function (res) {
+                    that.showMsg(res.msg);
+                });
+            },
+            confirm: function () {
+                var that = this;
+                layui.use(['layer'], function () {
+                    var layer = layui.layer;
+                    layer.confirm(that.id ? '修改成功是否返回产品列表' : '添加成功是否返回产品列表', {
+                        btn: ['返回列表', that.id ? '继续修改' : '继续添加'] //按钮
+                    }, function () {
+                        location.href = that.U({c: 'store.StoreProductCheck', a: 'index'});
+                    }, function () {
+                        location.reload();
+                    });
+                });
+            },
+            render: function () {
+                this.$nextTick(function () {
+                    layui.use(['form'], function () {
+                        layui.form.render('select');
+                    });
+                })
+            },
+            // 移动
+            handleDragStart(e, item) {
+                this.dragging = item;
+            },
+            handleDragEnd(e, item) {
+                this.dragging = null
+            },
+            handleDragOver(e) {
+                e.dataTransfer.dropEffect = 'move'
+            },
+            handleDragEnter(e, item) {
+                e.dataTransfer.effectAllowed = 'move'
+                if (item === this.dragging) {
+                    return
+                }
+                var newItems = [...this.formData.activity];
+                var src = newItems.indexOf(this.dragging);
+                var dst = newItems.indexOf(item);
+                newItems.splice(dst, 0, ...newItems.splice(src, 1))
+                this.formData.activity = newItems;
+            },
+            getRuleList: function (type) {
+                var that = this;
+                that.requestGet(that.U({c: 'store.StoreProduct', a: 'get_rule'})).then(function (res) {
+                    that.$set(that, 'ruleList', res.data);
+                    if (type !== undefined) {
+                        that.render();
+                    }
+                });
+            },
+            addRule: function () {
+                return this.createFrame('添加商品规则', this.U({c: 'store.StoreProductRule', a: 'create'}));
+            },
+            allRule: function () {
+                if (this.ruleIndex != -1) {
+                    var rule = this.ruleList[this.ruleIndex];
+                    if (rule) {
+                        this.ruleBool = true;
+                        var rule_value = rule.rule_value.map(function (item) {
+                            return item;
+                        });
+                        this.$set(this.formData, 'items', rule_value);
+                        this.$set(this.formData, 'attrs', []);
+                        this.$set(this, 'formHeader', []);
+                        return true;
+                    }
+                }
+                this.showMsg('选择的属性无效');
+            }
+        },
+        mounted: function () {
+            var that = this;
+            axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
+            that.getProductInfo();
+            window.$vm = that;
+            window.changeIMG = that.changeIMG;
+            window.insertEditor = that.insertEditor;
+            window.insertEditorVideo = that.insertEditorVideo;
+            window.successFun = function () {
+                that.getRuleList(1);
+            }
+            $(that.$refs.filElem).change(function () {
+                var inputFile = this.files[0];
+                that.requestPost(that.U({c: "widget.video", a: 'get_signature'})).then(function (res) {
+                    AdminUpload.upload(res.data.uploadType, {
+                        token: res.data.uploadToken || '',
+                        file: inputFile,
+                        accessKeyId: res.data.accessKey || '',
+                        accessKeySecret: res.data.secretKey || '',
+                        bucketName: res.data.storageName || '',
+                        region: res.data.storageRegion || '',
+                        domain: res.data.domain || '',
+                        uploadIng: function (progress) {
+                            that.upload.videoIng = true;
+                            that.progress = progress;
+                        }
+                    }).then(function (res) {
+                        //成功
+                        that.$set(that.formData, 'video_link', res.url);
+                        that.progress = 0;
+                        that.upload.videoIng = false;
+                        return that.showMsg('上传成功');
+                    }).catch(function (err) {
+                        //失败
+                        console.info(err);
+                        return that.showMsg('上传错误请检查您的配置');
+                    });
+                }).catch(function (res) {
+                    return that.showMsg(res.msg || '获取密钥失败,请检查您的配置');
+                });
+            })
+        }
+    });
+</script>
+</body>
+</html>
+<script>
+    import Layout from "../../../../../public/static/plug/iview/dist/iview";
+
+    export default {
+        components: {Layout}
+    }
+</script>

+ 317 - 0
app/admin/view/store/store_product_check/index.php

@@ -0,0 +1,317 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="layui-fluid" style="background: #fff;margin-top: -10px;">
+    <div class="layui-tab layui-tab-brief" lay-filter="tab">
+        <ul class="layui-tab-title">
+            <li lay-id="list" {eq name='type' value='1' }class="layui-this" {
+            /eq} >
+            <a href="{eq name='type' value='1'}javascript:;{else}{:Url('index',['type'=>1])}{/eq}">全部商品</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='2' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='2'}javascript:;{else}{:Url('index',['type'=>2])}{/eq}">审核中商品({$checking})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='3' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='3'}javascript:;{else}{:Url('index',['type'=>3])}{/eq}">已通过商品({$checkok})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='4' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='4'}javascript:;{else}{:Url('index',['type'=>4])}{/eq}">已驳回商品({$checkno})</a>
+            </li>
+        </ul>
+    </div>
+    <div class="layui-row layui-col-space15" id="app">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-form-item">
+                            <div class="layui-inline">
+                                <label class="layui-form-label">所有分类</label>
+                                <div class="layui-input-block">
+                                    <select name="cate_id">
+                                        <option value=" ">全部</option>
+                                        {volist name='cate' id='vo'}
+                                        <option value="{$vo.id}">{$vo.html}{$vo.cate_name}</option>
+                                        {/volist}
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <label class="layui-form-label">商品名称</label>
+                                <div class="layui-input-block">
+                                    <input type="text" name="store_name" class="layui-input"
+                                           placeholder="请输入商品名称,关键字,编号">
+                                    <input type="hidden" name="type" value="{$type}">
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <div class="layui-input-inline">
+                                    <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search"
+                                            lay-filter="search">
+                                        <i class="layui-icon layui-icon-search"></i>搜索
+                                    </button>
+                                    <button class="layui-btn layui-btn-primary layui-btn-sm export" lay-submit="export"
+                                            lay-filter="export">
+                                        <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出
+                                    </button>
+                                </div>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+        </div>
+        <!--商品列表-->
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="layui-btn-container">
+                        {switch name='type'}
+                        {case value="1"}
+                        <a class="layui-btn layui-btn-sm" href="{:Url('create')}">添加商品</a>
+                        {/case}
+                        {case value="2"}
+                        <a class="layui-btn layui-btn-sm" href="{:Url('create')}">添加商品</a>
+                        {/case}
+                        {case value="4"}
+                        <button class="layui-btn layui-btn-sm" data-type="take_products">重新提交审核</button>
+                        {/case}
+                        {/switch}
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <!--图片-->
+                    <script type="text/html" id="image">
+                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    </script>
+                    <!--上架|下架-->
+                    <script type="text/html" id="checkboxstatus">
+                        {{# if(d.status == 2){ }}
+                        驳回
+                        {{# }else if(d.status == 1){ }}
+                        通过
+                        {{# } else { }}
+                        审核中
+                        {{# } }}
+                    </script>
+                    <!--收藏-->
+                    <script type="text/html" id="like">
+                        <span><i class="layui-icon layui-icon-praise"></i> {{d.like}}</span>
+                    </script>
+                    <!--点赞-->
+                    <script type="text/html" id="collect">
+                        <span><i class="layui-icon layui-icon-star"></i> {{d.collect}}</span>
+                    </script>
+                    <!--商品名称-->
+                    <script type="text/html" id="store_name">
+                        <h4>{{d.store_name}}</h4>
+                        <p>价格:<font color="red">{{d.price}}</font></p>
+                        {{# if(d.cate_name!=''){ }}
+                        <p>分类:{{d.cate_name}}</p>
+                        {{# } }}
+                    </script>
+                    <script type="text/html" id="allstock">
+                        {{+d.stock+(+d.sales)}}
+                    </script>
+                    <!--操作-->
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
+                            编辑
+                        </button>
+                        {{# if(d.status != 1){ }}
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        {{# } }}
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            {{# if(d.status == 0){ }}
+                            {if condition="$user_store eq 0"}
+                            <li>
+                                <a href="javascript:void(0);" lay-event='check_ok'>
+                                    <i class="fa fa-check"></i> 通过
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);" lay-event='check_no'>
+                                    <i class="fa fa-close"></i> 驳回
+                                </a>
+                            </li>
+                            {/if}
+                            {{# } }}
+                            {{# if(d.status == 2){ }}
+                            <li>
+                                <a href="javascript:void(0);" lay-event='check'>
+                                    <i class="fa fa-trash"></i> 提交审核
+                                </a>
+                            </li>
+                            {{# } }}
+                        </ul>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+<script>
+    var type = <?=$type?>;
+    //实例化form
+    layList.form.render();
+    //加载列表
+    layList.tableList('List', "{:Url('product_ist',['type'=>$type])}", function () {
+        var join = new Array();
+        switch (parseInt(type)) {
+            case 1:
+            case 2:
+            case 3:
+                join = [
+                    {field: 'id', title: 'ID', sort: true, event: 'id', width: '6%'},
+                    {field: 'from_store_name', title: '所属门店', width: '6%'},
+                    {field: 'image', title: '商品图片', templet: '#image', width: '10%'},
+                    {field: 'store_name', title: '商品名称', templet: '#store_name'},
+                    {field: 'ficti', title: '虚拟销量', edit: 'ficti', width: '8%'},
+                    {field: 'sort', title: '排序', edit: 'sort', width: '6%'},
+                    {field: 'status', title: '状态', templet: "#checkboxstatus", width: '8%'},
+                    {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
+                ];
+                break;
+            case 4:
+                join = [
+                    {type: 'checkbox'},
+                    {field: 'id', title: 'ID', sort: true, event: 'id', width: '6%'},
+                    {field: 'from_store_name', title: '所属门店', width: '6%'},
+                    {field: 'image', title: '商品图片', templet: '#image', width: '10%'},
+                    {field: 'store_name', title: '商品名称', templet: '#store_name'},
+                    {field: 'ficti', title: '虚拟销量', edit: 'ficti', width: '8%'},
+                    {field: 'sort', title: '排序', edit: 'sort', width: '6%'},
+                    {field: 'status', title: '状态', templet: "#checkboxstatus", width: '8%'},
+                    {field: 'reason', title: '驳回原因', width: '10%'},
+                    {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
+                ];
+                break;
+        }
+        return join;
+    })
+    //excel下载
+    layList.search('export', function (where) {
+        where.excel = 1;
+        location.href = layList.U({c: 'store.store_product_check', a: 'product_ist', q: where});
+    })
+    //下拉框
+    $(document).click(function (e) {
+        $('.layui-nav-child').hide();
+    })
+
+    function dropdown(that) {
+        var oEvent = arguments.callee.caller.arguments[0] || event;
+        oEvent.stopPropagation();
+        var offset = $(that).offset();
+        var top = offset.top - $(window).scrollTop();
+        var index = $(that).parents('tr').data('index');
+        $('.layui-nav-child').each(function (key) {
+            if (key != index) {
+                $(this).hide();
+            }
+        })
+        if ($(document).height() < top + $(that).next('ul').height()) {
+            $(that).next('ul').css({
+                'padding': 10,
+                'top': -($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        } else {
+            $(that).next('ul').css({
+                'padding': 10,
+                'top': $(that).parent('td').height() / 2 + $(that).height(),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        }
+    }
+
+    //点击事件绑定
+    layList.tool(function (event, data, obj) {
+        switch (event) {
+            case 'check':
+                var url = layList.U({c: 'store.store_product_check', a: 'check', q: {id: data.id}});
+                var code = {title: "操作提示", text: "确定提交审核吗?", type: 'info', confirm: '是的,提交该商品'};
+                $eb.$swal('delete', function () {
+                    $eb.axios.get(url).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success', res.data.msg);
+                            obj.del();
+                            location.reload();
+                        } else
+                            return Promise.reject(res.data.msg || '提交失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, code)
+                break;
+            case 'check_ok':
+                var url = layList.U({c: 'store.store_product_check', a: 'check_ok', q: {id: data.id}});
+                var code = {title: "操作提示", text: "确定通过审核吗?", type: 'info', confirm: '是的,通过该商品'};
+                $eb.$swal('delete', function () {
+                    $eb.axios.get(url).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success', res.data.msg);
+                            obj.del();
+                            location.reload();
+                        } else
+                            return Promise.reject(res.data.msg || '通过失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, code)
+                break;
+            case 'check_no':
+                $eb.createModalFrame(data.store_name + '-驳回原因', layList.U({a: 'check_no', q: {id: data.id}}), {h: 550, w: 720});
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'edit':
+                location.href = layList.U({a: 'create', q: {id: data.id}});
+                break;
+        }
+    })
+    //排序
+    layList.sort(function (obj) {
+        var type = obj.type;
+        switch (obj.field) {
+            case 'id':
+                layList.reload({order: layList.order(type, 'id')}, true, null, obj);
+                break;
+        }
+    });
+    //查询
+    layList.search('search', function (where) {
+        layList.reload(where, true);
+    });
+    //自定义方法
+    var action = {
+        take_products: function () {
+            var ids = layList.getCheckData().getIds('id');
+            if (ids.length) {
+                layList.basePost(layList.Url({
+                    c: 'store.store_product_check',
+                    a: 'take_products'
+                }), {ids: ids}, function (res) {
+                    layList.msg(res.msg);
+                    location.reload();
+                });
+            } else {
+                layList.msg('请选择要提交审核的商品');
+            }
+        }
+    };
+    //多选事件绑定
+    $('.layui-btn-container').find('button').each(function () {
+        var type = $(this).data('type');
+        $(this).on('click', function () {
+            action[type] && action[type]();
+        })
+    });
+</script>
+{/block}

+ 34 - 0
app/admin/view/store/store_product_check/like.php

@@ -0,0 +1,34 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox">
+            <div class="ibox-content">
+                <div class="table-responsive">
+                    <table class="table table-striped  table-bordered">
+                        <thead>
+                        <tr>
+                            <th class="text-center">收藏人</th>
+                            <th class="text-center">收藏时间</th>
+                        </tr>
+                        </thead>
+                        <tbody class="">
+                        {volist name="list" id="vo"}
+                        <tr>
+                            <td class="text-center">
+                                {$vo.nickname}
+                            </td>
+                            <td class="text-center">
+                                {$vo.add_time|date='Y-m-d H:i:s'}
+                            </td>
+                        </tr>
+                        {/volist}
+                        </tbody>
+                    </table>
+                </div>
+                {include file="public/inner_page"}
+            </div>
+        </div>
+    </div>
+</div>
+{/block}

+ 390 - 0
app/admin/view/store/store_product_check/statistics.php

@@ -0,0 +1,390 @@
+{extend name="public/container"}
+{block name="head_top"}
+<link rel="stylesheet" href="{__PLUG_PATH}daterangepicker/daterangepicker.css">
+<link href="{__FRAME_PATH}css/plugins/footable/footable.core.css" rel="stylesheet">
+<script src="{__PLUG_PATH}sweetalert2/sweetalert2.all.min.js"></script>
+<script src="{__PLUG_PATH}moment.js"></script>
+<script src="{__PLUG_PATH}daterangepicker/daterangepicker.js"></script>
+<script src="{__PLUG_PATH}echarts.common.min.js"></script>
+<script src="{__FRAME_PATH}js/plugins/footable/footable.all.min.js"></script>
+{/block}
+{block name="content"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox">
+            <div class="ibox-content">
+                <div class="row">
+                    <div class="m-b m-l">
+                        <form action="" class="form-inline">
+                            <div class="search-item" data-name="data">
+                                <span>创建时间:</span>
+                                <button type="button" class="btn btn-outline btn-link" data-value="">全部</button>
+                                <button type="button" class="btn btn-outline btn-link" data-value="{$limitTimeList.today}">今天</button>
+                                <button type="button" class="btn btn-outline btn-link" data-value="{$limitTimeList.week}">本周</button>
+                                <button type="button" class="btn btn-outline btn-link" data-value="{$limitTimeList.month}">本月</button>
+                                <button type="button" class="btn btn-outline btn-link" data-value="{$limitTimeList.quarter}">本季度</button>
+                                <button type="button" class="btn btn-outline btn-link" data-value="{$limitTimeList.year}">本年</button>
+                                <div class="datepicker" style="display: inline-block;">
+                                    <button type="button" class="btn btn-outline btn-link" data-value="{$where.data?:'no'}">自定义</button>
+                                </div>
+                                <input class="search-item-value" type="hidden" name="data" value="{$where.data}" />
+                            </div>
+                            {volist name='header' id='val'}
+                            <div class="col-sm-3">
+                                <div class="widget style1 {$val.color}-bg" style="height: 120px;">
+                                    <div class="row" style="margin-top: 16px;padding: 0 20px;">
+                                        <div class="col-xs-4">
+                                            <i class="fa {$val.class} fa-5x"></i>
+                                        </div>
+                                        <div class="col-xs-8 text-right">
+                                            <span> {$val.name} </span>
+                                            <h2 class="font-bold">{$val.value}</h2>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                            {/volist}
+
+                        </form>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-title">
+                <h5>商品销量折线图</h5>
+                <div class="ibox-tools">
+                    <a class="collapse-link">
+                        <i class="fa fa-chevron-up"></i>
+                    </a>
+                </div>
+            </div>
+            <div class="ibox-content">
+                <div  id="ec-goods-count" style="height:390px;">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<div class="row">
+    <div class="col-sm-12">
+        <div class="col-sm-6">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>销量排行前十</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link">
+                            <i class="fa fa-chevron-up"></i>
+                        </a>
+
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div style="float: left;">
+                        当月前十商品销售总计: <span style="color: lightblue;"><?php  echo $total; ?></span>件
+                        共计 <span style="color: coral;"><?php  echo $price; ?></span>元
+                    </div>
+                    <div class="search-item" data-name="sex" style="float: right;">
+                        <input class="search-item-value" type="hidden" name="sex" value="{$where.sex}" />
+                        <button type="button" class="btn btn-outline btn-link" data-value="2" style="border-radius:0;border-left: 1px solid #eee;border-top: 1px solid #eee;border-bottom: 1px solid #eee;">全部</button><button type="button" class="btn btn-outline btn-link" data-value="1" style="border-radius:0;border-top: 1px solid #eee;border-bottom: 1px solid #eee;" >男</button><button type="button" class="btn btn-outline btn-link" data-value="0" style="border-radius:0;border-right: 1px solid #eee;border-top: 1px solid #eee;border-bottom: 1px solid #eee;">女</button>
+                    </div>
+                    <div class="ibox-content">
+                        <div  id="ec-order-count1" style="height:390px;">
+                        {notempty name="stores"}
+                        {volist name="stores" id="vo"}
+                        <div style="float: left;width: 100px;">{$vo.name}</div>
+                        <div class="progress">
+                            <span style="margin-left: 8px">{$vo.sum}</span>
+                            <div class="progress-bar {$vo.color}" role="progressbar" aria-valuenow="{$vo.sum}" aria-valuemin="0" aria-valuemax="<?php  echo $storeSum1; ?>" style="width: <?php if($storeSum1>0){ ?> <?php $b=$vo['sum']/$storeSum1; echo ceil($b*100);}?>%  ">
+                                <span class="sr-only">40% Complete (success)</span>
+                            </div>
+                        </div>
+                        {/volist}
+                        {/notempty}
+                        </div>
+                    </div>
+                </div>
+
+            </div>
+        </div>
+        <div class="col-sm-6">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>利润排行前十</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link">
+                            <i class="fa fa-chevron-up"></i>
+                        </a>
+                        <!--                                            <a class="close-link">-->
+                        <!--                                                <i class="fa fa-times"></i>-->
+                        <!--                                            </a>-->
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div style="float: left;">
+                        当月前十商品利润总计: <span style="color: lightblue;"><?php  echo $total1; ?></span>件
+                        共计 <span style="color: coral;"><?php  echo $price1; ?></span>元
+                    </div>
+                    <div class="search-item" data-name="sex1" style="float: right;">
+                        <input class="search-item-value" type="hidden" name="sex1" value="{$where.sex1}" />
+                        <button type="button" class="btn btn-outline btn-link" data-value="2" style="border-radius:0;border-left: 1px solid #eee;border-top: 1px solid #eee;border-bottom: 1px solid #eee;">全部</button><button type="button" class="btn btn-outline btn-link" data-value="1" style="border-radius:0;border-top: 1px solid #eee;border-bottom: 1px solid #eee;" >男</button><button type="button" class="btn btn-outline btn-link" data-value="0" style="border-radius:0;border-right: 1px solid #eee;border-top: 1px solid #eee;border-bottom: 1px solid #eee;">女</button>
+                    </div>
+                    <div class="ibox-content" id="ec-order-count2" style="height:390px;">
+                        {notempty name="stor"}
+                        {volist name="stor" id="vs"}
+                        <div style="float: left;width: 100px;">{$vs.name}</div>
+                        <div class="progress">
+                            <span style="margin-left: 8px">¥<?php echo $vs['price']*$vs['piece'];?></span>
+
+                            <div class="progress-bar <?php echo $vs['color'];?>" role="progressbar" aria-valuenow="<?php echo $vs['price']*$vs['piece'];?>" aria-valuemin="11" aria-valuemax="<?php echo $priceSum;?>"
+                                 style="width: <?php if($priceSum>0){?><?php $p=$vs['price']*$vs['piece']/$priceSum; echo ceil($p*100);}?>%">
+                                <span class="sr-only">Complete</span>
+                            </div>
+
+                        </div>
+                        {/volist}
+                        {/notempty}
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<div class="row">
+    <div class="col-sm-12" style="margin-bottom: 20px;">
+        <div class="col-sm-4" >
+            <div class="ibox float-e-margins">
+                <div style="border: 1px solid #eee;">
+                    <div class="ibox-title" >
+                        <h5>待补货商品</h5>
+                        <div class="ibox-tools">
+                            <a class="collapse-link  save-height">
+                                <i class="fa fa-chevron-up"></i>
+                            </a>
+                            <!--                                                <a class="close-link">-->
+                            <!--                                                    <i class="fa fa-times"></i>-->
+                            <!--                                                </a>-->
+                        </div>
+                    </div>
+                    <div class="ibox-content replenishment" style="height: 300px;width: 100%;overflow: scroll;overflow-x:hidden">
+                        <table style="width: 100%;" class="tab">
+                            <tr style="background-color: #fff;height: 40px;">
+                                <th>商品信息</th>
+                                <th>商品单价</th>
+                                <th>库存数量</th>
+                                <th>操作</th>
+                            </tr>
+                            {volist name="stock" id="vk"}
+                            <tr class="tr1" style="height: 36px;line-height: 36px;">
+                                <td>{$vk.store_name}</td>
+                                <td>{$vk.price}</td>
+                                <td>{$vk.stock}</td>
+                                <td>
+                                    <!--                                                        <button type="button" class="btn btn-xs btn-link" data-id="{$vk.id}" style="border: 1px solid #eee;" onclick="$eb.createModalFrame('编辑','{:Url('edit',array('id'=>$vk['id']))}')">编辑</button>-->
+                                    <button class="btn  btn-xs " type="button"  onclick="$eb.createModalFrame('编辑','{:Url('edit',array('id'=>$vk['id']))}')"><i class="fa fa-edit"></i> 编辑</button>
+                                </td>
+                            </tr>
+                            {/volist}
+                        </table>
+                    </div>
+
+                </div>
+
+            </div>
+        </div>
+        <div class="col-sm-4">
+            <div class="ibox float-e-margins">
+                <div style="border: 1px solid #eee;">
+                    <div class="ibox-title">
+                        <h5>差评商品</h5>
+                        <div class="ibox-tools">
+                            <a class="collapse-link">
+                                <i class="fa fa-chevron-up"></i>
+                            </a>
+                            <!--                                            <a class="close-link">-->
+                            <!--                                                <i class="fa fa-times"></i>-->
+                            <!--                                            </a>-->
+                        </div>
+                    </div>
+                    <div class="ibox-content">
+                        <table style="width: 100%;">
+                            <tr style="background-color: #fff;height: 40px;">
+                                <th>商品信息</th>
+                                <th>商品单价</th>
+                                <th>差评数量</th>
+                                <th>操作</th>
+                            </tr>
+                            {volist name="stor1" id="st"}
+                            <tr style="height: 36px;line-height: 36px;">
+                                <td>{$st.name}</td><td>{$st.price}</td><td>{$st.sun}</td>
+                                <td>
+                                    <button class="btn btn-xs " type="button"  onclick="$eb.createModalFrame('编辑','{:Url('edit',array('id'=>$st['uid']))}')"><i class="fa fa-edit"></i> 编辑</button>
+                                </td>
+                            </tr>
+                            {/volist}
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-sm-4">
+            <div class="ibox float-e-margins">
+                <div style="border: 1px solid #eee;">
+                    <div class="ibox-title">
+                        <h5>退货商品</h5>
+                        <div class="ibox-tools">
+                            <a class="collapse-link">
+                                <i class="fa fa-chevron-up"></i>
+                            </a>
+                            <!--                                            <a class="close-link">-->
+                            <!--                                                <i class="fa fa-times"></i>-->
+                            <!--                                            </a>-->
+                        </div>
+                    </div>
+                    <div class="ibox-content">
+                        <table style="width: 100%;">
+                            <tr style="background-color: #fff;height: 40px;">
+                                <th>商品信息</th>
+                                <th>商品单价</th>
+                                <th>退货数量</th>
+                                <th>操作</th>
+                            </tr>
+                            {volist name="refund" id="st"}
+                            <tr style="height: 36px;line-height: 36px;">
+                                <td>{$st.name}</td><td>{$st.price}</td><td>{$st.sun}</td>
+                                <td>
+                                    <button class="btn btn-xs " type="button"  onclick="$eb.createModalFrame('编辑','{:Url('edit',array('id'=>$st['sid']))}')"><i class="fa fa-edit"></i> 编辑</button>
+                                </td>
+                            </tr>
+                            {/volist}
+                        </table>
+                    </div>
+
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="{__FRAME_PATH}js/content.min.js?v=1.0.0"></script>
+<script>
+    (function(){
+        var option = {
+            //设置标题
+            title:{
+//                                            text:'销量图',
+//                                            subtext:'商品销量。'
+            },
+            //设置提示
+            tooltip: {
+                show: true
+            },
+            //设置图例
+            legend: {
+                data:['销量']
+            },
+            //设置坐标轴
+            xAxis : [
+                {
+                    type : 'category',
+                    data : <?=json_encode($orderDays)?>
+                }
+            ],
+            yAxis : [
+                {
+                    type : 'value'
+                }
+            ],
+            //设置数据
+            series : [
+                //折线图
+                {
+                    "name":"销量",
+                    "type":"line",
+                    "data":<?=json_encode($sum)?>,
+                    //绘制平均线
+                    markLine : {
+                        data : [
+                            {type : 'average', name: '平均值'}
+                        ]
+                    },
+                    //绘制最高最低点
+                    markPoint : {
+                        data : [
+                            {type : 'max', name: '最大值'},
+                            {type : 'min', name: '最小值'}
+                        ]
+                    }
+                }
+
+            ]
+        };
+
+        var myChart = echarts.init(document.getElementById('ec-goods-count'));
+        myChart.setOption(option);
+    })();
+</script>
+
+<script>
+    $(".footable").footable();
+    $(".no-sort").off('click');
+    $('.search-item>.btn').on('click',function(){
+        var that = $(this),value = that.data('value'),p = that.parent(),name = p.data('name'),form = p.parents();
+        form.find('input[name="'+name+'"]').val(value);
+        form.submit();
+    });
+    $('.search-item-value').each(function(){
+        var that = $(this),name = that.attr('name'), value = that.val(),dom = $('.search-item[data-name="'+name+'"] .btn[data-value="'+value+'"]');
+        dom.eq(0).removeClass('btn-outline btn-link').addClass('btn-primary')
+            .siblings().addClass('btn-outline btn-link').removeClass('btn-primary')
+    });
+    $(".btn").mouseover(function (event){
+            $(this).closest('table').find("tr:eq(1)").find("td:eq(3)").find("button:eq(0)").removeClass('btn-info');
+            $(event.target).addClass('btn-info').siblings().removeClass('btn-info');
+
+    }).mouseout(function (){
+        $(event.target).removeClass('btn-info');
+//        $(this).closest('table').find("tr:eq(1)").find("td:eq(3)").find("button:eq(0)").addClass('btn-info');
+    });
+    var dateInput =$('.datepicker');
+    dateInput.daterangepicker({
+        autoUpdateInput: false,
+        "opens": "center",
+        "drops": "down",
+        "ranges": {
+            '今天': [moment(), moment().add(1, 'days')],
+            '昨天': [moment().subtract(1, 'days'), moment()],
+            '上周': [moment().subtract(6, 'days'), moment()],
+            '前30天': [moment().subtract(29, 'days'), moment()],
+            '本月': [moment().startOf('month'), moment().endOf('month')],
+            '上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
+        },
+        "locale" : {
+            applyLabel : '确定',
+            cancelLabel : '取消',
+            fromLabel : '起始时间',
+            toLabel : '结束时间',
+            format : 'YYYY/MM/DD',
+            customRangeLabel : '自定义',
+            daysOfWeek : [ '日''一''二''三''四''五''六' ],
+            monthNames : [ '一月''二月''三月''四月''五月''六月',
+                '七月''八月''九月''十月''十一月''十二月' ],
+            firstDay : 1
+        }
+    });
+
+    dateInput.on('cancel.daterangepicker', function(ev, picker) {
+        //$("input[name=limit_time]").val('');
+    });
+    dateInput.on('apply.daterangepicker', function(ev, picker) {
+        $("input[name=data]").val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
+        $('input[name=export]').val(0);
+        $('form').submit();
+    });
+</script>
+{/block}

+ 6 - 0
nginx.htaccess

@@ -0,0 +1,6 @@
+location / {
+rewrite  ^/$  /index/index.html   break;
+	if (!-e $request_filename){
+		rewrite  ^(.*)$  /index.php?s=$1  last;   break;
+	}
+}