service = new MassagerActionService(); } public function login() { $params = (new BaseApiValidate([ "account" => "require", "password" => "require", ]))->checkBody(); $r = $this->service->login($params["account"], $params["password"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function loginByMobile() { $params = (new BaseApiValidate([ "mobile" => "require", "sms_code" => "require|number", ]))->checkBody(); $r = $this->service->loginByMobile($params["mobile"], $params["sms_code"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function wxAppLogin() { $params = (new BaseApiValidate([ "openId" => "require", "unionId" => "require" ]))->checkBody(); $r = $this->service->wxAppLogin($params["openId"], $params["unionId"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function bindAppWx() { $params = (new BaseApiValidate([ "openId" => "require", "unionId" => "require" ]))->checkBody(); $r = $this->service->bindAppWx($this->massager->id, $params["openId"], $params["unionId"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function bindAppletWx() { $params = (new BaseApiValidate([ "code" => "require" ]))->checkBody(); $r = (new WxService())->wxLoginByApplet($params["code"]); if (0 === $r->code()) $this->error($r->msg()); $info = $r->data(); if (!isset($info["unionid"]) || !isset($info["openid"])) $this->error("微信登录错误! unionid|openid 不能为空!"); $model = new \app\api\model\massager\Massager(); $massager = $model->findById($this->massager->id); if (!$massager) $this->error("用户不存在!"); if ($massager["union_id"] === $info["unionid"] && $massager["applet_openid"] === $info["openid"]) { $this->success(true); } $m = $model->findByUnionId($info["unionid"]); if ($m) $this->error("该微信已经绑定助教,无法重复绑定!"); $model->update([ "applet_openid" => $info["openid"], "union_id" => $info["unionid"], ], ["id" => $this->massager->id]); $this->success(true); } public function fetchOrder($status = null, $page = 1, $size = 10) { $array = $status ? explode(",", $status) : []; foreach ($array as $item) { if (!in_array($item, array_merge(ALL_ORDER_STATUS, ["*"]))) $this->error("状态错误!"); } $r = $this->service->fetchOrder($this->massager->id, in_array("*", $array) ? [ \E_ORDER_STATUS::Purchase, \E_ORDER_STATUS::Proceed, \E_ORDER_STATUS::WaitFeedback, \E_ORDER_STATUS::Finish, \E_ORDER_STATUS::Reject, \E_ORDER_STATUS::Cancel, \E_ORDER_STATUS::AdminCancel, \E_ORDER_STATUS::AutoCancel ] : $array, $page, $size); $this->success($r); } public function untakeOrderCount() { $this->success($this->service->untakeOrderCount($this->massager->id)); } /** * 处理订单 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function disposeOrder() { $params = (new BaseApiValidate([ "order_id" => "require|number", "type" => "require", "lng" => "require|number", "lat" => "require|number" ]))->checkBody(); if (!in_array($params["type"], ALL_ORDER_PROGRESS_TYPE)) $this->error("打卡type错误"); $r = $this->service->dispose($this->massager->id, $params["order_id"], $params["type"], $params["lng"], $params["lat"], isset($params["card_image"]) ? $params["card_image"] : null); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } /** * 拒绝接单 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function rejectOrder() { $params = (new BaseApiValidate([ "order_id" => "require|number", "reason" => "require" ]))->checkBody(); $r = $this->service->rejectOrder($this->massager->id, $params["order_id"], $params["reason"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function getMassagerInfo() { $params = (new BaseApiValidate([ "massager_id" => "require|number", ]))->checkBody(); $r = $this->service->getMassagerInfo($params["massager_id"]); $r ? $this->success($r) : $this->error("助教信息不存在!"); } public function updateInfo() { $params = (new BaseApiValidate([ // "description" => "", "radius" => "number", "height" => "number", "weight" => "number", "free_travel_km" => "number", ]))->checkBody(); $this->service->modify($this->massager->id, $params); $this->success(); } public function updateLocation() { $params = (new BaseApiValidate([ "city_code" => "require|number", "lng" => "require|number", "lat" => "require|number", ]))->checkBody(); $r = $this->service->updateLocation($this->massager->id, (int)$params["city_code"], $params["lng"], $params["lat"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function workClockIn() { $r = $this->service->workClockIn($this->massager->id); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function online() { $r = $this->service->online($this->massager->id); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function findWallet() { $r = $this->service->findWallet($this->massager->id); $this->success($r); } public function fetchComment() { $params = (new BaseApiValidate([ "negative" => "between:0,1", "page" => "require|number", "size" => "require|number", ]))->checkBody(); $r = $this->service->fetchComment($this->massager->id, isset($params["negative"]) ? $params["negative"] : null, $params["page"], $params["size"]); $this->success($r); } public function allegedly() { $params = (new BaseApiValidate([ "comment_id" => "require|number", "allegedly_text" => "require", ]))->checkBody(); $r = $this->service->allegedly($this->massager->id, $params["comment_id"], $params["allegedly_text"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function areaVisa() { $params = (new BaseApiValidate([ "new_city_code" => "require|number", "description" => "require", "lng" => "require|number", "lat" => "require|number", ]))->checkBody(); $r = $this->service->areaVisa($this->massager->id, $params["new_city_code"], $params["description"], $params["lng"], $params["lat"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function closeAccount() { $params = (new BaseApiValidate([ "sms_code" => "require|number" ]))->checkBody(); $r = $this->service->closeAccount($this->massager->id, $params["sms_code"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function feedback() { $params = (new BaseApiValidate([ // "type" => "require", "reason" => "require", "mobile" => "require", "content" => "require", "relation_type" => "require", ]))->checkBody(); if (!in_array($params["relation_type"], ['platform', 'agency', 'store', 'massager', 'user', 'other'])) $this->error("relation_type"); $r = $this->service->feedback( $this->massager->id, isset($params["type"]) ? $params["type"] : 'complaint', $params["content"], isset($params["images"]) ? $params["images"] : null, $params["reason"], $params["mobile"], isset($params["relation_type"]) ? $params["relation_type"] : null, isset($params["relation_id"]) ? $params["relation_id"] : null, isset($params["relation_name"]) ? $params["relation_name"] : null ); $this->success($r); } public function modify() { $params = $this->request->param(); if (isset($params["mobile"])) { if (11 !== strlen($params["mobile"])) $this->error("手机号码格式错误"); if (!isset($params["sms_code"])) $this->error("验证码不能为空"); } $r = $this->service->modify($this->massager->id, $params); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function fetchMassagerPhoto() { $params = (new BaseApiValidate([ "massager_id" => "require|number", ]))->checkBody(); $r = $this->service->fetchMassagerPhoto($params["massager_id"]); is_null($r) ? $this->error("数据不存在") : $this->success($r); } public function fetchTripAmountOrder() { $params = (new BaseApiValidate([ "page" => "require|number", "size" => "require|number" ]))->checkBody(); $r = $this->service->fetchTripAmountOrder($this->massager->id, $params["page"], $params["size"]); $this->success($r); } public function fetchDurationCount() { $this->success($this->service->fetchDurationCount($this->massager->id)); } public function fetchBill() { $params = (new BaseApiValidate([ 'currency_type' => 'require', 'change_types' => 'require', 'page' => 'require|number', 'size' => 'require|number', ]))->checkBody(); if (!in_array($params["currency_type"], [\E_USER_BILL_CURRENCY_TYPE::Money, \E_USER_BILL_CURRENCY_TYPE::Score])) $this->error("currency_type error"); $r = $this->service->fetchBill( $this->massager->id, $params["currency_type"], explode(",", (string)$params["change_types"]), $params["page"], $params["size"] ); $this->success($r); } public function fetchShareProfit() { $r = $this->service->fetchShareProfit($this->massager->id); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function tabulateData() { $r = $this->service->tabulateData($this->massager->id); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function deposit() { $params = (new BaseApiValidate([ 'platform' => 'require', 'amount' => 'require|between:1,100000', ]))->checkBody(); if (!in_array($params["platform"], [\E_ORDER_PAY_TYPE::Wechat, \E_ORDER_PAY_TYPE::ALi, \E_ORDER_PAY_TYPE::Bank])) $this->error("platform error"); $r = $this->service->deposit( $this->massager->id, $params["platform"], fixed2Float($params["amount"]) ); $r->code() == 1 ? $this->success($r->data(), $r->msg()) : $this->error($r->msg(), null, $r->code()); } public function fetchSystemMessage() { $params = (new BaseApiValidate([ 'page' => 'require|number', 'size' => 'require|number', ]))->checkBody(); $this->success($this->service->fetchSystemMessage($this->massager->id, $params["page"], $params["size"])); } public function getUnreadMessageCount() { $this->success($this->service->getUnreadMessageCount($this->massager->id)); } public function resetPassword() { $params = (new BaseApiValidate([ "mobile" => "require|length:11", "sms_code" => "require|number", "new_password" => "require", ]))->checkBody(); $r = $this->service->resetPassword($params["mobile"], $params["sms_code"], $params["new_password"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function fetchDiffAmountDetailsByYm($year = null, $month = null) { $r = $this->service->fetchDiffAmountDetailsByYm($this->massager->id, $this->massager["city_code"], $year, $month); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } // 结算本月Order public function closingOrderPerformanceByYm() { $r = $this->service->closingOrderPerformanceByYm($this->massager->id); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function fetchClosingOrderPerformance($page = null, $size = null) { $this->success($this->service->fetchClosingOrderPerformance($this->massager->id, $page, $size)); } public function fetchInteriorScoreDetails($year = null, $month = null) { if (null === $year) $year = date("Y"); if (null === $month) $month = date("m"); $this->success( $this->service->fetchInteriorScoreDetails($this->massager->id, $year, $month) ); } public function uploadContract($contract_file = null) { if (is_null($contract_file)) $this->error("请上传合同附件"); $this->success($this->service->uploadContract($this->massager->id, $contract_file)); } /** * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function publishDynamic() { $params = (new BaseApiValidate([ "type" => "require", "massager_id" => "require|number", "topic_id" => "number", "description" => "require", "attachment_files" => "require", "city_code" => "require", "address" => "require", "lng" => "require", "lat" => "require" ]))->checkBody(); $r = $this->service->publishDynamic($this->massager->id, $params); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function appeal() { $params = (new BaseApiValidate([ "order_id" => "require|number", "appeal_reason" => "require", ]))->checkBody(); $r = $this->service->appeal($this->massager->id, $params["order_id"], $params["appeal_reason"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function setNoWorkPeriod() { $params = (new BaseApiValidate([ "range" => "require" ]))->checkBody(); $r = $this->service->setNoWorkPeriod($this->massager->id, $params["range"]); $r->code() ? $this->success($r->data()) : $this->error($r->msg()); } public function fetchNoWorkPeriod() { $this->success($this->service->fetchNoWorkPeriod($this->massager->id)); } public function delNoWorkPeriod() { $params = (new BaseApiValidate([ "id" => "require" ]))->checkBody(); $this->success($this->service->delNoWorkPeriod($params["id"])); } public function fetchInviteQrCode() { $url = "https://pbh5.xunsoftware.com/pages/teacher/settle?parent_id={$this->massager->id}"; if (is_null($this->massager->invite_qr_code)) { $qr_code = \qrcodeBase64("https://pbh5.xunsoftware.com/pages/teacher/settle", ["parent_id" => $this->massager->id]); (new \app\api\model\massager\Massager())->update([ "invite_qr_code" => $qr_code ], ["id" => $this->massager->id]); $this->success($qr_code); } $this->success([ "invite_qr_code" => $this->massager->invite_qr_code, "link" => $url ]); } }