| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace app\api\service;
- use addons\fastchat\library\Chat;
- use app\admin\model\Admin;
- use app\api\model\Store;
- class StoreService extends BaseService
- {
- private $model;
- public function __construct()
- {
- $this->model = new Store();
- }
- public function fetch(array $params)
- {
- $paginate = $this->model->fetch(
- $params['city_code'],
- isset($params['county_code']) ? $params['county_code'] : null,
- $params['lng_lat'],
- $params['service_id'] ?? null,
- $params['search_text'] ?? null,
- $params['distance'] ?? null,
- $params['page'] ?? 1,
- $params['size'] ?? 10
- );
- return [
- $paginate->items(),
- $paginate->total()
- ];
- }
- /**
- * @param array $params
- * @return \SResult
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function apply(array $params)
- {
- $store = $this->model->where("name", $params["name"])->find();
- if ($store) {
- return $this->fail("球房已经存在请勿重复申请");
- }
- $store_id = $this->model->insertGetId([
- "name" => $params["name"],
- "photo_images" => isset($params["photo_images"]) ? $params["photo_images"] : null,
- "description" => isset($params["description"]) ? $params["description"] : null,
- "tags" => isset($params["tags"]) ? $params["tags"] : null,
- "star" => 5,
- "phone" => $params["phone"],
- "area_city" => $params["area_city"],
- "p_code" =>$params["p_code"],
- "city_code" => $params["city_code"],
- "county_code" => $params["county_code"],
- "address" => $params["address"],
- "lng" => $params["lng"],
- "lat" => $params["lat"],
- "status" => \E_BASE_STATUS::Checking
- ]);
- $qr_code = \qrcodeBase64("https://pbh5.xunsoftware.com/pages/user/login", ["invite_store_id" => $store_id]);
- $this->model->update([
- "invite_qr_code" => $qr_code
- ], ["id" => $store_id]);
- return $this->ok(true);
- }
- public static function inform($no, $store_id, $city_code, $service_start_date)
- {
- $admins = Admin::whereOr("store_id", $store_id)
- ->whereOr("FIND_IN_SET('{$city_code}',city_codes)")->select();
- if (count($admins) > 0) {
- $admin_ids = join(",", array_map(function ($data) {
- return $data["id"];
- }, $admins));
- Chat::init(1)
- ->admin($admin_ids)
- ->send("球房有新订单,订单号为【{$no}】,预计到店时间为【{$service_start_date}】,请及时处理!");
- }
- }
- }
|