request->post(); Log::info('testNotify'.formatLogData($params)); return $this->success(); } /** * 手机号注册 * @author liugc <466014217@qq.com> * @date 2025/5/20 13:39 */ public function register() { try { $params = $this->request->post(); $this->validate($params,[ "code" => "require", "mobile" => "require|mobile", ]); // 验证码验证 $res = \app\workerapi\logic\LoginLogic::confirmMobile($params); if(!$res){ throw new \Exception('验证码错误'); } // 注册并登录 $result = DouYinService::phoneLogin($params); return $this->data($result); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * @notes 账号密码/手机号密码/手机号验证码登录 * @return \think\response\Json * @author 段誉 * @date 2022/9/16 10:42 */ public function account() { try { $params = (new LoginAccountValidate())->post()->goCheck(); $result = LoginLogic::login($params); if (false === $result) { return $this->fail(LoginLogic::getError()); } return $this->data($result); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * @notes 退出登录 * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author 段誉 * @date 2022/9/16 10:42 */ public function logout() { LoginLogic::logout($this->userInfo); return $this->success(); } public function getOpenid() { $params = $this->request->post(); $toData = [ 'appid' => 'tt74fb0246ebf34b0601', 'secret' => "0c841cc324e8bea8a584d248556d6263fb2dadb2", 'code' => $params['code'], 'anonymous_code' => $params['anonymous_code'] ]; $res = DouYinService::toDyRequestUrl('https://developer.toutiao.com/api/apps/v2/jscode2session',$toData,['Content-Type' => 'application/json'],'errNoReturn',1); Log::info(json_encode($res)); return $this->success('',$res); } // ******************************** 列表详情 _商品 _订单 _退款 /* * 商品审核结果回调 */ public function goodsNotify() { $params = $this->request->post(); // {"operate_type":"CREATE","product_id":"7527118921439119395","reason":"","status":"PASS"} Log::info('goodsNotify:'.formatLogData($params)); return $this->success(); } /** * 所有商品 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/20 14:35 */ public function getAllGoods() { $params = $this->request->get(); $params['platform_value'] = 6; return $this->dataLists((new GoodsLists())->setParams($params)); } /** * 商品详情 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/20 14:35 */ public function getGoodsDetail() { $params = $this->request->get(); $params['platform_value'] = 6; $result = GoodsLogic::detail($params['goods_category_id'],'category',$this->userId,$params); return $this->data($result); } /** * 订单列表 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function getOrderLists() { $params = $this->request->get(); $params['user_id'] = $this->userId; return $this->dataLists((new DouyinOrderLists())->setParams($params)); } public function getOrderDetail() { $params = $this->request->get(); $params['user_id'] = $this->userId; $result = DouYinService::getOrderDetail($params); return $this->data($result); } /** * 退款订单列表 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function getRefundLists() { $params = $this->request->get(); $params['user_id'] = $this->userId; return $this->dataLists((new DouyinRefundOrderLists())->setParams($params)); } // ******************************** 订单业务 public function createOrder() { try { $params = $this->request->post(); $params['user_id'] = $this->userId; $params['user_info'] = $this->userInfo; $requestOrderData = DouYinService::createOrder($params); return $this->success('',$requestOrderData); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 拉起支付所需参数 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function requestOrderData() { try { $params = $this->request->post(); $params['user_id'] = $this->userId; $params['user_info'] = $this->userInfo; $requestOrderData = DouYinService::getPluginCreateOrderData($params['goods_id']??'',$params['quantity']??1,$params['dy_order_id']??'',$params); Log::info('requestOrderData:'.formatLogData($requestOrderData)); return $this->success('',$requestOrderData); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } public function submitOrderNotify() { try { $params = $this->request->post(); Log::info('submitOrderNotify:'.formatLogData($params)); $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true); if($params['type'] == 'pre_create_order') $res = DouYinService::submitOrderNotify($msg); if($params['type'] == 'pre_create_refund') $res = DouYinService::refundOrderNotify($msg); Log::info("submitOrderNotify:".formatLogData($res)); if($res){ return json(["err_no"=>0,"err_tips"=>"","data"=>$res], 200); } } catch (\Exception $e) { return json(["err_no"=>1001,"err_tips"=>$e->getMessage()], 200); } } /** * 支付回调 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 * {"version":"2.0","msg":"{\"app_id\":\"tt74fb0246ebf34b0601\",\"status\":\"CANCEL\",\"order_id\":\"1086630633686742888\",\"cp_extra\":\"{\\\"outShopId\\\":6,\\\"skuId\\\":\\\"7526760812149835817\\\",\\\"quantity\\\":\\\"1\\\",\\\"user_id\\\":29,\\\"douyinOrderId\\\":0}\",\"message\":\"TIME_OUT\",\"event_time\":1752545313000,\"out_order_no\":\"202507151003336089\",\"total_amount\":15000,\"discount_amount\":0,\"item_id\":\"0\",\"delivery_type\":0,\"order_source\":\"\"}","type":"payment"} */ public function payNotify() { try { $params = $this->request->post(); Log::info('payNotify:'.formatLogData($params)); $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true); if($params['type'] == 'payment' && DouYinService::payNotify($msg)){ return json(["err_no"=>0,"err_tips"=>""], 200); } if($params['type'] == 'refund'){ return json(["err_no"=>0,"err_tips"=>""], 200); } } catch (\Exception $e) { return json(["err_no"=>1001,"err_tips"=>$e->getMessage()], 200); } } public function payTailNotify() { try { $params = $this->request->post(); Log::info('payTailNotify:'.formatLogData($params)); $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true); if($params['type'] == 'payment' && DouYinService::payTailNotify($msg)){ return json(["err_no"=>0,"err_tips"=>""], 200); } if($params['type'] == 'refund'){ return json(["err_no"=>0,"err_tips"=>""], 200); } } catch (\Exception $e) { return json(["err_no"=>1001,"err_tips"=>$e->getMessage()], 200); } } // ******************************** 订单预约/改约 /** * 预约 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function reservation() { try { $params = $this->request->post(); // order_number Log::info('reservation:'.formatLogData($params)); //DouYinService::reservation($params); return $this->success(); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 修改预约 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function upReservation() { try { $params = $this->request->post(); // order_number appointment_time Log::info('upReservation:'.formatLogData($params)); //DouYinService::upReservation($params); return $this->success(); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } // ******************************** 订单 取消 退款 /** * 取消订单 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function cancelOrder() { try { $params = $this->request->post(); // order_number Log::info('cancelOrder:'.formatLogData($params)); DouYinService::cancelOrder($params); return $this->success(); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 退款 * @return \think\response\Json * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function refund() { try { $params = $this->request->post(); // order_number appointment_time $params['user_id'] = $this->userId; Log::info('refund:'.formatLogData($params)); DouYinService::refund($params); return $this->success(); } catch (\Exception $e) { return $this->fail($e->getMessage()); } } /** * 退款回调 * @author liugc <466014217@qq.com> * @date 2025/5/22 14:35 */ public function refundNotify() { try { $params = $this->request->post(); Log::info('refundNotify:'.formatLogData($params)); $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true); if(DouYinService::refundNotify($msg)){ return json(["err_no"=>0,"err_tips"=>"success"], 200); } } catch (\Exception $e) { return json(["err_no"=>1001,"err_tips"=>$e->getMessage()], 200); } } }