| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace hd\controllers;
- use bizHd\custom\classes\CustomClass;
- use bizHd\custom\classes\HdClass;
- use bizHd\deduct\classes\DeductClass;
- use common\components\util;
- use Yii;
- class DeductController extends BaseController
- {
- public $guestAccess = [];
- //减少余额 ssh 20250329(这个方法应该建在CustomController的)
- public function actionDeductBalance()
- {
- $post = Yii::$app->request->post();
- $customId = $post['customId'] ?? 0;
- $remark = $post['remark'] ?? '';
- $custom = CustomClass::getByID($customId, true);
- if (empty($custom)) {
- util::fail('没有找到客户');
- }
- if ($custom->shopId != $this->shopId) {
- util::fail('不是你的客户');
- }
- $hdId = $custom->hdId;
- $hd = HdClass::getByID($hdId, true);
- if (empty($hd)) {
- util::fail('客户信息缺失');
- }
- $amount = $post['amount'] ?? 0;
- if (empty($amount)) {
- util::fail('请填写金额');
- }
- if ($amount < 0) {
- util::fail('金额要大于0');
- }
- $shop = $this->shop;
- $staff = $this->shopAdmin;
- $staffId = $staff->id;
- $staffName = $staff->name;
- $params = [
- 'remark' => $remark,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- ];
- DeductClass::doDeduct($shop, $custom, $hd, $amount, $params);
- util::complete('减少成功');
- }
- }
|