| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace pt\controllers;
- use bizGhs\apply\classes\ApplyClass;
- use bizHd\saas\services\ApplyService;
- use common\components\dict;
- use common\components\sms;
- use common\components\util;
- use Yii;
- class ApplyController extends BaseController
- {
- //修改全品和单品 ssh 20240416
- public function actionChangeAll()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $apply = ApplyClass::getById($id, true);
- if (empty($apply)) {
- util::fail('没有找到申请记录');
- }
- if ($apply->status != 1) {
- util::fail('不是审核状态');
- }
- $new = $apply->all == 1 ? 0 : 1;
- $apply->all = $new;
- $apply->save();
- util::complete();
- }
- //申请列表
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $status = $get['status'] ?? 0;
- $where = [];
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $list = ApplyService::getApplyList($where);
- util::success($list);
- }
- //审核
- public function actionCheck()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $id = Yii::$app->request->post('id');
- $status = Yii::$app->request->post('status', 0);
- $remark = Yii::$app->request->post('remark', '');
- $apply = ApplyService::getById($id);
- if (empty($apply)) {
- util::fail('找不到申请记录');
- }
- if (isset($apply['status']) && $apply['status'] == 2) {
- util::fail('已经审过了');
- }
- if (isset($apply['style']) && $apply['style'] != dict::getDict('ptStyle', 'ghs')) {
- util::fail('暂时只支持审核批发商的申请');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
- if ($status == 1) {
- \bizGhs\apply\services\ApplyService::pass($id);
- }
- $transaction->commit();
- if ($status == 1) {
- $mobile = $apply['mobile'] ?? '';
- $cf = '15280215347';
- if (getenv('YII_ENV') == 'production') {
- //sms::freeSend($mobile . ',' . $cf, '恭喜,开店申请审核通过了,登录后请及时修改密码,如有疑问请联系 {$var}');
- }
- }
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("审核操作报错:" . $exception->getMessage());
- util::fail('操作失败');
- }
- util::complete();
- }
- }
|