You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.6 KiB
104 lines
3.6 KiB
<?php
|
|
|
|
namespace App\Service;
|
|
|
|
use App\Constants\LogLabel;
|
|
use App\Constants\SsdbKeysPrefix;
|
|
use App\Model\Store;
|
|
use App\TaskWorker\SSDBTask;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpMessage\Upload\UploadedFile;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use League\Flysystem\Filesystem;
|
|
|
|
class StoreService implements StoreServiceInterface
|
|
{
|
|
/**
|
|
* @Inject
|
|
* @var AttachmentServiceInterface
|
|
*/
|
|
protected $attachmentService;
|
|
|
|
/**
|
|
* @Inject
|
|
* @var Filesystem
|
|
*/
|
|
protected $filesystem;
|
|
|
|
public function entry($data)
|
|
{
|
|
Db::beginTransaction();
|
|
try {
|
|
|
|
// 文件上传
|
|
if ($data['logo'] instanceof UploadedFile) {
|
|
$data['logo'] = $this->attachmentService->formUpload($data['logo'], 'storelogo', $this->filesystem);
|
|
}
|
|
|
|
if ($data['fm_img'] instanceof UploadedFile) {
|
|
$data['fm_img'] = $this->attachmentService->formUpload($data['fm_img'], 'idcard', $this->filesystem);
|
|
}
|
|
|
|
if ($data['zm_img'] instanceof UploadedFile) {
|
|
$data['zm_img'] = $this->attachmentService->formUpload($data['zm_img'], 'idcard', $this->filesystem);
|
|
}
|
|
|
|
if ($data['yyzz'] instanceof UploadedFile) {
|
|
$data['yyzz'] = $this->attachmentService->formUpload($data['yyzz'], 'storelicense', $this->filesystem);
|
|
}
|
|
|
|
// 商户信息入库(需审核)
|
|
$store = Store::query()->updateOrCreate(
|
|
['id' => $data['id']],
|
|
[
|
|
'name' => $data['name'],
|
|
'market_id' => $data['market_id'],
|
|
'md_type' => $data['md_type'],
|
|
'address' => $data['address'],
|
|
'coordinates' => $data['coordinates'],
|
|
'details' => $data['details'],
|
|
'link_name' => $data['link_name'],
|
|
'link_tel' => $data['link_tel'],
|
|
'tel' => $data['link_tel'],
|
|
'logo' => $data['logo'],
|
|
'fm_img' => $data['fm_img'],
|
|
'zm_img' => $data['zm_img'],
|
|
'yyzz' => $data['yyzz'],
|
|
'user_id' => $data['user_id'],
|
|
'sq_id' => $data['user_id'],
|
|
'admin_id' => $data['user_id'],
|
|
'rz_time' => $data['rz_time'],
|
|
'mm_user_id' => $data['mm_user_id'],
|
|
'sq_time' => date('Y-m-d H:i:s'),
|
|
'rzdq_time' => date('Y-m-d H:i:s', time() + 1000 * 24 * 3600),
|
|
'state' => 1,
|
|
'is_open' => 1,
|
|
'money' => 0,
|
|
'code' => time() . rand(1000, 9999) . $data['user_id'],
|
|
'uniacid' => 2,
|
|
'zf_state' => 2,
|
|
]
|
|
);
|
|
|
|
Db::commit();
|
|
|
|
// 商户新用户等统计信息入SSDB
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
|
|
|
|
if (!$ssdb->exec('hexists', SsdbKeysPrefix::STORE_NEW_USER.$store->id, 'count')) {
|
|
if(false === $ssdb->exec('hset', SsdbKeysPrefix::STORE_NEW_USER.$store->id, ['count', 0])) {
|
|
$this->log->event(
|
|
LogLabel::SSDB_LOG,
|
|
['method' => 'hset-'.SsdbKeysPrefix::STORE_NEW_USER.$store->id, 'key' => SsdbKeysPrefix::STORE_NEW_USER.$store->id]
|
|
);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollBack();
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
}
|