From f87f640425cff1e313b59ed1b2993c26d3a9a819 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 10 Nov 2023 16:21:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MerchantIntentionRepository.php.bak | 166 ------------------ app/listener/SendGoodsCode.php | 2 +- crmeb/jobs/SendGoodsCodeJob.php | 2 +- 3 files changed, 2 insertions(+), 168 deletions(-) delete mode 100644 app/common/repositories/system/merchant/MerchantIntentionRepository.php.bak diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php.bak b/app/common/repositories/system/merchant/MerchantIntentionRepository.php.bak deleted file mode 100644 index b5428766..00000000 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php.bak +++ /dev/null @@ -1,166 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\common\repositories\system\merchant; - -use app\common\repositories\BaseRepository; -use crmeb\jobs\SendSmsJob; -use crmeb\services\SmsService; -use FormBuilder\Factory\Elm; -use app\common\dao\system\merchant\MerchantIntentionDao; -use think\exception\ValidateException; -use think\facade\Db; -use think\facade\Queue; -use think\facade\Route; - -/** - * @mixin MerchantIntentionDao - */ -class MerchantIntentionRepository extends BaseRepository -{ - - public function __construct(MerchantIntentionDao $dao) - { - $this->dao = $dao; - } - - public function getList(array $where, $page, $limit) - { - $query = $this->dao->search($where); - $count = $query->count(); - $list = $query->page($page, $limit)->order('create_time DESC , status ASC')->with(['merchantCategory', 'merchantType'])->select(); - - return compact('count', 'list'); - } - - public function detail($id, ?int $uid) - { - $where = ['mer_intention_id' => $id]; - if (!is_null($uid)) { - $where['uid'] = $uid; - } - return $this->dao->search($where)->find(); - } - - public function updateIntention($id, array $data) - { - if ($this->dao->existsWhere(['mer_intention_id' => $id, 'status' => '1'])) - throw new ValidateException('当前状态不能修改'); - $data['images'] = implode(',', (array)$data['images']); - $data['status'] = 0; - $data['fail_msg'] = ''; - return $this->dao->update($id, $data); - } - - public function markForm($id) - { - $data = $this->dao->get($id); - $form = Elm::createForm(Route::buildUrl('systemMerchantIntentionMark', ['id' => $id])->build()); - $form->setRule([ - Elm::textarea('mark', '备注', $data['remark'])->required(), - ]); - return $form->setTitle('修改备注'); - } - - public function statusForm($id) - { - $form = Elm::createForm(Route::buildUrl('systemMerchantIntentionStatus', ['id' => $id])->build()); - $form->setRule([ - Elm::select('status', '审核状态', 1)->options([ - ['value' => 1, 'label' => '同意'], - ['value' => 2, 'label' => '拒绝'], - ])->control([ - [ - 'value' => 1, - 'rule' => [ - Elm::radio('create_mer', '自动创建商户', 1)->options([ - ['value' => 1, 'label' => '创建'], - ['value' => 2, 'label' => '不创建'], - ]) - ] - ], - [ - 'value' => 2, - 'rule' => [ - Elm::textarea('fail_msg', '失败原因', '信息填写有误') - ] - ] - ]), - ]); - return $form->setTitle('修改审核状态'); - } - - public function updateStatus($id, $data) - { - $create = $data['create_mer'] == 1; - unset($data['create_mer']); - $intention = $this->search(['mer_intention_id' => $id])->find(); - if (!$intention) - throw new ValidateException('信息不存在'); - if ($intention->status) - throw new ValidateException('状态有误,修改失败'); - $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']); - - $margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']); - $data['is_margin'] = $margin['is_margin'] ?? -1; - $data['margin'] = $margin['margin'] ?? 0; - $merData = []; - if ($create) { - $password = substr($intention['phone'], -6); - $merData = [ - 'mer_name' => $intention['mer_name'], - 'mer_phone' => $intention['phone'], - 'mer_account' => $intention['phone'], - 'category_id' => $intention['merchant_category_id'], - 'type_id' => $intention['mer_type_id'], - 'real_name' => $intention['name'], - 'status' => 1, - 'is_audit' => 1, - 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, - 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, - 'mer_password' => $password, - 'is_margin' => $margin['is_margin'] ?? -1, - 'margin' => $margin['margin'] ?? 0 - ]; - $data['fail_msg'] = ''; - $smsData = [ - 'date' => date('m月d日', strtotime($intention->create_time)), - 'mer' => $intention['mer_name'], - 'phone' => $intention['phone'], - 'pwd' => $password ?? '', - 'site_name' => systemConfig('site_name'), - ]; - } - if ($data['status'] == 2) { - $smsData = [ - 'phone' => $intention['phone'], - 'date' => date('m月d日', strtotime($intention->create_time)), - 'mer' => $intention['mer_name'], - 'site' => systemConfig('site_name'), - ]; - } - - Db::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData) { - if ($data['status'] == 1) { - if ($create) { - $merchant = app()->make(MerchantRepository::class)->createMerchant($merData); - $data['mer_id'] = $merchant->mer_id; - Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]); - } - } else { - Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_FAIL', 'id' => $smsData]); - } - $intention->save($data); - }); - } - -} diff --git a/app/listener/SendGoodsCode.php b/app/listener/SendGoodsCode.php index babf6cbe..0b753b11 100644 --- a/app/listener/SendGoodsCode.php +++ b/app/listener/SendGoodsCode.php @@ -16,7 +16,7 @@ class SendGoodsCode { $this->event = $event; Log::info("sendGoodsCode ============= handle监听order_id " . $this->event['order_id']); - if ($this->event['activity_type'] == 0) { + if ($this->event['activity_type'] == 0 || in_array($this->event['source'], [0,2,103])) { //发起物流信息返回快递员手机 $logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']); //生成用户的收货码 diff --git a/crmeb/jobs/SendGoodsCodeJob.php b/crmeb/jobs/SendGoodsCodeJob.php index 1f7686fc..21aac5ac 100644 --- a/crmeb/jobs/SendGoodsCodeJob.php +++ b/crmeb/jobs/SendGoodsCodeJob.php @@ -30,7 +30,7 @@ class SendGoodsCodeJob implements JobInterface Log::info("sendGoodsCodeJob" . json_encode($this->event)); Log::info("sendGoodsCodeJob ============= handle监听order_id " . $this->event['order_id']); try { - if ($this->event['activity_type'] == 0) { + if ($this->event['activity_type'] == 0 || in_array($this->event['source'], [0,2,103])) { //发起物流信息返回快递员手机 $logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']); //生成用户的收货码