活动接口调整

wysf
ztt 1 year ago
parent 875a131332
commit 702d1acdb7
  1. 7
      app/api/controller/Active.php
  2. 66
      app/api/controller/Data.php
  3. 13
      app/api/controller/Store.php
  4. 13
      app/api/controller/StoreKeeper.php
  5. 26
      app/api/model/ActiveCol.php
  6. 52
      app/api/model/ActiveMain.php
  7. 31
      app/api/model/Goods.php
  8. 48
      app/api/service/Data.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();

@ -0,0 +1,66 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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'));
}
}

@ -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());
}
}

@ -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;

@ -0,0 +1,26 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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
{
}

@ -0,0 +1,52 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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'];
}
}

@ -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;
}
}

@ -0,0 +1,48 @@
<?php
namespace app\api\service;
use app\common\service\BaseService;
/**
* 数据概况服务类
* Class Data
* @package app\api\service\statistics
*/
class Data extends BaseService
{
/**
* 订单数据
* @return mixed
*/
public function getOrderData($startDate = null, $endDate = null): array {
return [
];
}
/**
* 退款数据
* @return mixed
*/
public function getRefundData($startDate = null, $endDate = null): array {
}
/**
* 用户数据
* @return mixed
*/
public function getUserData($startDate = null, $endDate = null): array {
}
/**
* 佣金数据
* @return mixed
*/
public function getCommissionData($startDate = null, $endDate = null) : array{
}
}
Loading…
Cancel
Save