| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * 用途:配送方式配置控制器
- * 谁用:供货商系统管理员
- * 解决什么问题:提供配送方式(送货、自取、跑腿、快递、物流)配置的获取和保存接口
- */
- namespace ghs\controllers;
- use bizGhs\order\classes\ShMethodClass;
- use Yii;
- use common\components\util;
- class ShMethodController extends BaseController
- {
- /**
- * 获取指定配送方式的配置
- * GET 参数:
- * - style: 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 快递, 4: 物流)
- */
- public function actionGetConfig()
- {
- $style = Yii::$app->request->get('style', 0);
- try {
- $config = ShMethodClass::getConfig($this->shopId, $this->mainId, $style);
- util::success($config);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 获取门店所有的5种配送方式配置
- * 如果数据库里没有,则取默认配置进行初始化
- */
- public function actionGetAllMethod()
- {
- try {
- $configs = ShMethodClass::getAllConfigs($this->shopId, $this->mainId);
- util::success($configs);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 获取所有配送方式的排序和别名信息
- */
- public function actionGetSorts()
- {
- try {
- $sorts = ShMethodClass::getSorts($this->mainId);
- util::success($sorts);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- /**
- * 保存指定配送方式的配置
- * POST 参数:
- * - id: 配置ID(可选)
- * - style: 配送类型 (0: 送货, 1: 自取, 2: 跑腿, 3: 快递, 4: 物流)
- * - name: 名称
- * - calcType: 算运费方式 (0: 用跑腿, 1: 用自定义)
- * - status: 状态 (0: 禁用, 1: 启用)
- * - sort: 排序
- * - minAmount: 最低消费金额
- * - minNum: 最低消费数量
- * - unMeet: 不满条件处理方式 (0: 收运费, 1: 收包装费, 2: 不能下单)
- * - unMeetFee: 运费/包装费金额
- * - startKm: 起步公里数
- * - startPrice: 起步价格
- * - perKmPrice: 超出起步每公里加价
- * - changeRate: 临时涨价比例 (%)
- * - explains: 说明项列表 (二维数组,包含 explain, color, fontWeight, sort)
- * - reduceRules: 跑腿满减规则列表 (二维数组,包含 meetNum, meetAmount, freeKm, sort)
- */
- public function actionSaveConfig()
- {
- $post = Yii::$app->request->post();
- try {
- ShMethodClass::saveConfig($this->shopId, $this->mainId, $post);
- util::complete('保存成功');
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- }
|