qifengquan 1 year ago
parent
commit
742d50993e

+ 63 - 1
app/data/controller/shop/Goods.php

@@ -173,8 +173,9 @@ class Goods extends Controller
             $this->payments = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('type,code,name', 'code');
             $this->discounts = BaseUserDiscount::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('id,name,items', 'id');
             // 商品规格处理
-            $fields = 'goods_sku `sku`,goods_code,goods_spec `key`,stock_total `stock`,price_selling `selling`,price_market `market`,number_virtual `virtual`,number_express `express`,reward_balance `balance`,reward_integral `integral`,status';
+            $fields = 'goods_sku `sku`,goods_code,goods_spec `key`,stock_total `stock`,price_selling `selling`,price_market `market`,number_virtual `virtual`,number_express `express`,reward_balance `balance`,reward_integral `integral`,status,show_image';
             $data['data_items'] = json_encode(ShopGoodsItem::mk()->where(['goods_code' => $data['code']])->column($fields, 'goods_spec'), JSON_UNESCAPED_UNICODE);
+
         } elseif ($this->request->isPost()) {
 
             $data['admin_id']=AdminService::getUserId();
@@ -331,6 +332,67 @@ class Goods extends Controller
         }
     }
 
+    /**
+     * 商品编辑
+     * @param array $data
+     * @return void
+     */
+    public function examinex_edit(){
+        if (empty($data['code'])) {
+            $data['code'] = CodeExtend::uniqidNumber(20, 'G');
+        }
+        if ($this->request->isGet()) {
+            $data['marks'] = str2arr($data['marks'] ?? '');
+            $data['payment'] = str2arr($data['payment'] ?? '');
+            $data['cateids'] = str2arr($data['cateids'] ?? '');
+            // 其他表单数据
+            $this->marks = ShopGoodsMark::items();
+            $this->cates = ShopGoodsCate::treeTable(true);
+            $this->trucks = ExpressService::templates();
+            $this->upgrades = BaseUserUpgrade::items();
+            $this->payments = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('type,code,name', 'code');
+            $this->discounts = BaseUserDiscount::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('id,name,items', 'id');
+            // 商品规格处理
+            $fields = 'goods_sku `sku`,goods_code,goods_spec `key`,stock_total `stock`,price_selling `selling`,price_market `market`,number_virtual `virtual`,number_express `express`,reward_balance `balance`,reward_integral `integral`,status,show_image';
+            $data['data_items'] = json_encode(ShopGoodsItem::mk()->where(['goods_code' => $data['code']])->column($fields, 'goods_spec'), JSON_UNESCAPED_UNICODE);
+
+        } elseif ($this->request->isPost()) {
+
+            $data['admin_id']=AdminService::getUserId();
+            $data['examine']=0;
+
+            if (empty($data['cover'])) $this->error('商品图片不能为空!');
+//            if (empty($data['slider'])) $this->error('轮播图片不能为空!');
+//            if (empty($data['payment'])) $this->error('支付方式不能为空!');
+            [$data['price_market'], $data['price_selling']] = [0, 0];
+            $data['stock_total']=0;
+            [$count, $items] = [0, array_column(json_decode($data['data_items'], true), 0)];
+            foreach ($items as $item) if ($item['status'] > 0) {
+                if ($data['price_market'] === 0 || $data['price_market'] > $item['market']) $data['price_market'] = $item['market'];
+                if ($data['price_selling'] === 0 || $data['price_selling'] > $item['selling']) $data['price_selling'] = $item['selling'];
+                $data['stock_total']+=$item['stock'];
+                $count++;
+            }
+            if (empty($count)) $this->error('无效的的商品价格信息!');
+            $data['marks'] = arr2str($data['marks'] ?? []);
+//            $data['payment'] = arr2str($data['payment'] ?? []);
+            ShopGoodsItem::mk()->where(['goods_code' => $data['code']])->update(['status' => 0]);
+            foreach ($items as $item) data_save(ShopGoodsItem::class, [
+                'goods_sku'       => $item['sku'],
+                'goods_spec'      => $item['key'],
+                'goods_code'      => $data['code'],
+                'stock_total'     => $item['stock'],
+                'price_market'    => $item['market'],
+                'price_selling'   => $item['selling'],
+                'status'          => $item['status'] ? 1 : 0,
+                'admin_id'        => $data['admin_id'],
+                'show_image'      => $data['cover']
+            ], 'goods_spec', [
+                'goods_code' => $data['code'],
+            ]);
+        }
+    }
+
 
     public function _examinex_form_filter(array &$data)
     {

+ 3 - 1
app/data/view/shop/goods/examine.html

@@ -87,11 +87,13 @@
 <!--                </td>-->
                 <td class='nowrap sub-strong-blue'>
                     {if $admin_id ==10000}
+<!--                    <a class="layui-btn layui-btn-xs layui-btn-warm" data-action="{:url('examinex_edit')}" data-value="code#{$vo.code};">编 辑</a>-->
+                    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?code={$vo.code}'>编 辑</a>
+
                     <a class="layui-btn layui-btn-xs layui-btn-warm" data-action="{:url('examinex')}" data-value="code#{$vo.code};examine#1">通 过</a>
                     <a class="layui-btn layui-btn-xs" data-modal="{:url('shop.goods/examinex')}?id={$vo.id}" data-title="拒绝原因">拒绝</a>
 
 
-
 <!--                    <a class="layui-btn layui-btn-xs layui-btn-primary" data-action="{:url('examinex')}" data-value="code#{$vo.code};examine#2">拒 绝</a>-->
                     {else}
                     等待审核

+ 6 - 0
app/data/view/shop/goods/form.html

@@ -220,6 +220,7 @@
                 <thead>
                 <tr>
                     <th class="nowrap" ng-repeat="x in navas track by $index"><b ng-bind="x"></b></th>
+                    <th class="text-center nowrap pointer" data-tips-text="图片"  width="12%"><b>规格图片</b> <i class="layui-icon">&#xe63c;</i></th>
                     <th class="text-center nowrap pointer" data-tips-text="批量设置商品SKU" ng-click="batchSet('sku',null,'请输入商品SKU代码')" width="12%"><b>商品SKU</b> <i class="layui-icon">&#xe63c;</i></th>
 <!--                    <th class="text-center nowrap pointer" data-tips-text="批量设置市场价格" ng-click="batchSet('market',2,'请输入商品市场价格')" width="10%"><b>市场价格</b> <i class="layui-icon">&#xe63c;</i></th>-->
                     <th class="text-center nowrap pointer" data-tips-text="批量设置销售价格" ng-click="batchSet('selling',2,'请输入商品市销售价格')" width="10%"><b>销售价格</b> <i class="layui-icon">&#xe63c;</i></th>
@@ -235,6 +236,10 @@
                 <tr ng-repeat="rows in items track by $index">
                     <td class="layui-bg-gray nowrap" ng-bind="td.name" ng-if="td.show" ng-repeat="td in rows"></td>
                     <td class="padding-0">
+                        <img  src="{{rows[0].show_image}}" >
+<!--                        <input  ng-model="rows[0].show_image">-->
+                    </td>
+                    <td class="padding-0">
                         <label>
                             <input class="layui-input border-0 padding-left-0 text-center" ng-blur="rows[0].sku=setValue(rows[0].key,'sku',$event.target.value)" ng-model="rows[0].sku">
                         </label>
@@ -439,6 +444,7 @@
 
                         item.express = $rootScope.getValue(item.key, 'express', '1');
                         item.virtual = $rootScope.getValue(item.key, 'virtual', '0');
+                        item.show_image = $rootScope.getValue(item.key, 'show_image', '0');
                         return false;
                     });
                 });