From 702d1acdb793cc8e41f9f514312d7a81daf29c42 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Tue, 27 Feb 2024 15:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=8E=A5=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Active.php | 7 +--- app/api/controller/Data.php | 66 ++++++++++++++++++++++++++++++ app/api/controller/Store.php | 13 ++++++ app/api/controller/StoreKeeper.php | 13 ++++++ app/api/model/ActiveCol.php | 26 ++++++++++++ app/api/model/ActiveMain.php | 52 +++++++++++++++++++++++ app/api/model/Goods.php | 31 ++++++++++++++ app/api/service/Data.php | 48 ++++++++++++++++++++++ 8 files changed, 251 insertions(+), 5 deletions(-) create mode 100644 app/api/controller/Data.php create mode 100644 app/api/model/ActiveCol.php create mode 100644 app/api/model/ActiveMain.php create mode 100644 app/api/service/Data.php diff --git a/app/api/controller/Active.php b/app/api/controller/Active.php index b4657290..edff93a1 100644 --- a/app/api/controller/Active.php +++ b/app/api/controller/Active.php @@ -3,7 +3,7 @@ namespace app\api\controller; use app\api\model\Goods as GoodsModel; -use app\common\model\ActiveMain; +use app\api\model\ActiveMain; use app\common\model\Goods; use think\response\Json; use app\common\library\helper; @@ -23,10 +23,7 @@ class Active extends Controller return $this->renderSuccess('活动ID必填'); } $model = new ActiveMain(); - $list = $model->with('col') - ->where('status', '=', 1) - ->where('id', $param['active_id']) - ->find(); + $list = $model->getList($param); if ($list) { foreach ($list['col'] as $k => $row) { $goodsModel = new GoodsModel(); diff --git a/app/api/controller/Data.php b/app/api/controller/Data.php new file mode 100644 index 00000000..e65f8a5f --- /dev/null +++ b/app/api/controller/Data.php @@ -0,0 +1,66 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\controller; + + +use think\db\exception\ModelNotFoundException; +use think\response\Json; +use app\api\service\Data as StatisticsDataService; + +/** + * 数据概况 + * Class Data + * @package app\store\controller\statistics + */ +class Data extends Controller +{ + // 数据概况服务类 + private StatisticsDataService $service; + + /** + * 构造方法 + * @throws \cores\exception\BaseException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws ModelNotFoundException + */ + public function initialize() + { + parent::initialize(); + // 实例化数据概况服务类 + $this->service = new StatisticsDataService; + } + + /** + * 数据统计API + * @param $startDate + * @param $endDate + * @return Json + */ + public function statistics($startDate = null, $endDate = null): Json + { + // 获取数据 + $data = [ + // 订单数据 + 'orderData' => $this->service->getOrderData($startDate, $endDate), + // 退款数据 + 'refundData' => $this->service->getRefundData($startDate, $endDate), + // 用户数据 + 'userData' => $this->service->getUserData($startDate, $endDate), + // 佣金数据 + 'commissionData' => $this->service->getCommissionData($startDate, $endDate), + ]; + return $this->renderSuccess(compact('data')); + } + +} diff --git a/app/api/controller/Store.php b/app/api/controller/Store.php index 4ca9a36e..53df79e6 100644 --- a/app/api/controller/Store.php +++ b/app/api/controller/Store.php @@ -13,6 +13,7 @@ declare (strict_types=1); namespace app\api\controller; use app\api\service\User as UserService; +use app\store\model\store\Address as AddressModel; use think\response\Json; use app\api\service\Store as StoreService; use think\db\exception\DataNotFoundException; @@ -108,6 +109,18 @@ class Store extends Controller return $this->renderSuccess($info); } + /** + * 获取商家退货地址 + * @return Json + * @throws DbException + */ + public function getAddressList(): Json + { + $model = new AddressModel; + $list = $model->getList(['type' => 20]); + return $this->renderSuccess($list->toArray()); + } + } \ No newline at end of file diff --git a/app/api/controller/StoreKeeper.php b/app/api/controller/StoreKeeper.php index a0911ae2..b5372e62 100644 --- a/app/api/controller/StoreKeeper.php +++ b/app/api/controller/StoreKeeper.php @@ -548,6 +548,19 @@ class StoreKeeper extends Controller return $this->renderSuccess('编辑成功'); } + /** + * 店长修改价格 + * @return Json + */ + public function editGoodsPrice(): Json + { + $model = new \app\api\model\Goods(); + if (!$model->editGoodsPrice($this->request->param())) { + return $this->renderError($model->getError() ?: '编辑失败'); + } + return $this->renderSuccess('编辑成功'); + } + public function delPrice(): Json { $model = new GoodsPriceModel; diff --git a/app/api/model/ActiveCol.php b/app/api/model/ActiveCol.php new file mode 100644 index 00000000..51bfa851 --- /dev/null +++ b/app/api/model/ActiveCol.php @@ -0,0 +1,26 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + +use app\common\model\ActiveCol as ActiveColModel; +/** + * 活动栏目模型类 + * Class User + * @package app\common\model + */ +class ActiveCol extends ActiveColModel +{ + + + +} diff --git a/app/api/model/ActiveMain.php b/app/api/model/ActiveMain.php new file mode 100644 index 00000000..4934e2d1 --- /dev/null +++ b/app/api/model/ActiveMain.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\api\model; + +use app\common\model\ActiveMain as ActiveMainModel; +use think\model\relation\HasMany; + +/** + * 活动模型类 + * Class User + * @package app\common\model + */ +class ActiveMain extends ActiveMainModel +{ + + //追加字段 + protected $append = [ + //首页图片 + 'index_icon', + //活动主题图 + 'theme_pic' + ]; + + + public function getList($param) { + return $this->with('col') + ->where('status', '=', 1) + ->where('id', $param['active_id']) + ->find(); + } + + + public function getIndexIconAttr($value, $data) { + $file = $this->with('indexImage')->find(); + return $file['indexImage']['preview_url']; + } + + public function getThemePicAttr($value, $data) { + $file = $this->with('themeImage')->find(); + return $file['themeImage']['preview_url']; + } +} diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 2ad33b6c..adbc58ac 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -18,6 +18,7 @@ use app\api\model\store\Module as StoreModuleModel; use app\api\service\Goods as GoodsService; use app\api\service\User as UserService; use app\api\service\user\Grade as UserGradeService; +use app\common\enum\goods\SpecType as GoodsSpecTypeEnum; use app\common\enum\goods\Status as GoodsStatusEnum; use app\common\model\Goods as GoodsModel; use app\common\model\GoodsCategoryRel as GoodsCategoryRelModel; @@ -630,4 +631,34 @@ class Goods extends GoodsModel $goods['skuInfo']['goods_price'] = UserGradeService::getDiscountPrice($goods['skuInfo']['goods_price'], $discountRatio); } } + + /** + * 修改商品价格 + * @param $param + * @return false|void + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ + public function editGoodsPrice($data) { + if (empty($data['goods_price']) || empty($data['line_price']) || empty($data['id'])) { + $this->error = "请补全信息"; + return false; + } + $detail = $this->with(['skuList']) + ->where('goods_id', '=', $data['id'])->find(); + if ($detail->isEmpty()) { + $this->error = "异常数据"; + return false; + } + // 整理商品的价格 + if ($detail['spec_type'] == GoodsSpecTypeEnum::MULTI) { + [$data['goods_price_min'], $data['goods_price_max']] = GoodsSkuModel::getGoodsPrices($detail['skuList']->toArray()); + [$data['line_price_min'], $data['line_price_max']] = GoodsSkuModel::getLinePrices($detail['skuList']->toArray()); + } elseif ($detail['spec_type'] == GoodsSpecTypeEnum::SINGLE) { + $data['goods_price_min'] = $data['goods_price_max'] = $data['goods_price']; + $data['line_price_min'] = $data['line_price_max'] = $data['line_price']; + } + return $detail->save($data) !== false; + } } diff --git a/app/api/service/Data.php b/app/api/service/Data.php new file mode 100644 index 00000000..7abcb415 --- /dev/null +++ b/app/api/service/Data.php @@ -0,0 +1,48 @@ +