From 27c3b804812d885f32ee1601c67da4147fb203e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sat, 20 Mar 2021 15:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/ShopGoods.php | 8 ++++---- app/data/controller/api/Goods.php | 2 +- app/data/controller/api/auth/Order.php | 2 +- app/data/service/GoodsService.php | 22 +++++++++++----------- app/data/service/OrderService.php | 2 +- app/data/view/shop_payment/form.html | 11 ++++++----- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/app/data/controller/ShopGoods.php b/app/data/controller/ShopGoods.php index e6ef36298..c72fb7c06 100644 --- a/app/data/controller/ShopGoods.php +++ b/app/data/controller/ShopGoods.php @@ -80,7 +80,7 @@ class ShopGoods extends Controller { $this->marks = GoodsService::instance()->getMarkData(); $this->cates = GoodsService::instance()->getCateData(); - GoodsService::instance()->buildData($data, false); + GoodsService::instance()->bindData($data, false); } /** @@ -201,7 +201,7 @@ class ShopGoods extends Controller protected function _form_result(bool $result) { if ($result && $this->request->isPost()) { - GoodsService::instance()->syncStock(input('code')); + GoodsService::instance()->stock(input('code')); $this->success('商品编辑成功!', 'javascript:history.back()'); } } @@ -219,7 +219,7 @@ class ShopGoods extends Controller if ($this->request->isGet()) { $list = $this->app->db->name('ShopGoods')->where($map)->select()->toArray(); if (empty($list)) $this->error('无效的商品数据,请稍候再试!'); - [$this->vo] = GoodsService::instance()->buildData($list); + [$this->vo] = GoodsService::instance()->bindData($list); $this->fetch(); } else { [$data, $post, $batch] = [[], $this->request->post(), CodeExtend::uniqidDate(12, 'B')]; @@ -234,7 +234,7 @@ class ShopGoods extends Controller } if (!empty($data)) { $this->app->db->name('ShopGoodsStock')->insertAll($data); - GoodsService::instance()->syncStock($map['code']); + GoodsService::instance()->stock($map['code']); $this->success('商品数据入库成功!'); } } diff --git a/app/data/controller/api/Goods.php b/app/data/controller/api/Goods.php index 7609a6739..c304e7c79 100644 --- a/app/data/controller/api/Goods.php +++ b/app/data/controller/api/Goods.php @@ -47,7 +47,7 @@ class Goods extends Controller } $query = $this->_query('ShopGoods')->like('name,cateids,marks,payment')->equal('code'); $result = $query->where(['deleted' => 0, 'status' => 1])->order('sort desc,id desc')->page(true, false, false, 10); - if (count($result['list']) > 0) GoodsService::instance()->buildData($result['list']); + if (count($result['list']) > 0) GoodsService::instance()->bindData($result['list']); $this->success('获取商品数据', $result); } diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index c1bacdf2c..dbfac5fcb 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -177,7 +177,7 @@ class Order extends Auth }); // 同步商品库存销量 foreach (array_unique(array_column($items, 'goods_code')) as $code) { - GoodsService::instance()->syncStock($code); + GoodsService::instance()->stock($code); } // 触发订单创建事件 $this->app->event->trigger('ShopOrderCreate', $order['order_no']); diff --git a/app/data/service/GoodsService.php b/app/data/service/GoodsService.php index 768cfae96..50ebf7851 100644 --- a/app/data/service/GoodsService.php +++ b/app/data/service/GoodsService.php @@ -13,6 +13,15 @@ use think\admin\Service; class GoodsService extends Service { + /** + * 最大分类级别 + * @return integer + */ + public function getCateMax(): int + { + return 3; + } + /** * 获取分类数据 * @return array @@ -65,15 +74,6 @@ class GoodsService extends Service return $query->where($map)->order('sort desc,id desc')->column('name'); } - /** - * 最大分类级别 - * @return integer - */ - public function getCateMax(): int - { - return 3; - } - /** * 更新商品库存数据 * @param string $code @@ -82,7 +82,7 @@ class GoodsService extends Service * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function syncStock(string $code): bool + public function stock(string $code): bool { // 商品入库统计 $query = $this->app->db->name('ShopGoodsStock'); @@ -125,7 +125,7 @@ class GoodsService extends Service * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function buildData(array &$data = [], $simple = true): array + public function bindData(array &$data = [], $simple = true): array { [$cates, $codes] = [$this->getCateData(), array_unique(array_column($data, 'code'))]; $marks = $this->app->db->name('ShopGoodsMark')->where(['status' => 1])->column('name'); diff --git a/app/data/service/OrderService.php b/app/data/service/OrderService.php index 1eeffd921..7b3e06188 100644 --- a/app/data/service/OrderService.php +++ b/app/data/service/OrderService.php @@ -32,7 +32,7 @@ class OrderService extends Service { $map = ['order_no' => $orderNo]; $codes = $this->app->db->name('ShopOrderItem')->where($map)->column('goods_code'); - foreach (array_unique($codes) as $code) GoodsService::instance()->syncStock($code); + foreach (array_unique($codes) as $code) GoodsService::instance()->stock($code); return true; } diff --git a/app/data/view/shop_payment/form.html b/app/data/view/shop_payment/form.html index ecc321a88..e320db46b 100644 --- a/app/data/view/shop_payment/form.html +++ b/app/data/view/shop_payment/form.html @@ -6,11 +6,12 @@
支付方式图标 - Payment Cover -
- - -
+ Payment Image +