| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace mall\controllers;
- use bizHd\order\classes\PsMethodClass;
- use common\components\util;
- use Yii;
- /**
- * 商城端配送方式接口(xhPsMethod / xhPsExplain)
- * 用途:混合结算页展示各购买方式对应的配送说明
- */
- class PsMethodController extends BaseController
- {
- /**
- * 获取门店全部配送方式及说明项
- */
- public function actionGetAllMethod()
- {
- if (empty($this->shopId) || empty($this->mainId)) {
- util::fail('门店信息无效');
- }
- try {
- $configs = PsMethodClass::getAllConfigs($this->shopId, $this->mainId);
- // 客户单独送货上门规则覆盖 style=0
- if (!empty($this->custom) || !empty($this->hd)) {
- $customInfo = [];
- if (!empty($this->hd)) {
- $customInfo = is_array($this->hd) ? $this->hd : $this->hd->toArray();
- }
- if (!empty($this->custom)) {
- $customInfo = array_merge($customInfo, is_array($this->custom) ? $this->custom : $this->custom->toArray());
- }
- foreach ($configs as &$config) {
- if ((int)($config['style'] ?? 0) === 0) {
- $config = PsMethodClass::applyCustomHomeRule($config, $customInfo);
- }
- }
- unset($config);
- }
- // 今日已收过附加费时,前端不再展示门槛提示(每日每客户每配送方式只收一次)
- $customId = (int)($this->customId ?? 0);
- if ($customId > 0) {
- foreach ($configs as &$config) {
- $style = (int)($config['style'] ?? 0);
- $unMeet = (int)($config['unMeet'] ?? 0);
- $hasPaidSendCost = PsMethodClass::isSendCostPaidToday($customId, $style);
- $hasPaidPackCost = PsMethodClass::isPackPaidToday($customId, $style);
- if ($unMeet === 0 && $hasPaidSendCost) {
- $config['minAmount'] = 0;
- $config['minNum'] = 0;
- $config['unMeetFee'] = 0;
- } elseif ($unMeet === 2 && $hasPaidPackCost) {
- $config['minAmount'] = 0;
- $config['minNum'] = 0;
- $config['unMeetFee'] = 0;
- }
- }
- unset($config);
- }
- util::success(['method' => $configs]);
- } catch (\Exception $e) {
- util::fail($e->getMessage());
- }
- }
- }
|