| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\api\controller;
- use app\adminapi\lists\external\DouyinOrderLists;
- use app\adminapi\lists\external\DouyinRefundOrderLists;
- use app\api\lists\GoodsLists;
- use app\api\logic\GoodsLogic;
- use app\api\service\DouYinService;
- use app\common\enum\LoginEnum;
- use app\common\enum\user\UserTerminalEnum;
- use app\common\model\user\User;
- use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
- use app\api\logic\LoginLogic;
- use think\facade\Log;
- /**
- * 抖音 - tmp
- * Class DouYinController
- * @package app\api\controller
- */
- class DouYinController extends BaseApiController
- {
- public array $notNeedLogin = ['testNotify','getClientToken','register','account','getAllGoods','getGoodsDetail','submitOrderNotify','payNotify'];
- /**
- * 手机号注册
- * @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();
- }
- // ******************************** 列表详情 _商品 _订单 _退款
- /**
- * 所有商品
- * @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));
- }
- // ******************************** 订单业务
- /**
- * 拉起支付所需参数
- * @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['douyin_order_id']??'',$params);
- return $this->success('',$requestOrderData);
- } catch (\Exception $e) {
- return $this->fail($e->getMessage());
- }
- }
- public function submitOrderNotify()
- {
- try {
- $params = $this->request->post();
- $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true);
- $res = DouYinService::submitOrderNotify($msg);
- if($res){
- return json(["err_no"=>0,"err_tips"=>"success","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
- */
- public function payNotify()
- {
- try {
- $params = $this->request->post();
- $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true);
- if(DouYinService::payNotify($msg)){
- return json(["err_no"=>0,"err_tips"=>"success"], 200);
- }
- } catch (\Exception $e) {
- return json(["err_no"=>1001,"err_tips"=>$e->getMessage()], 200);
- }
- }
- public function payTailNotify()
- {
- try {
- $params = $this->request->post();
- $msg = is_array($params['msg'])?$params['msg']:json_decode($params['msg'],true);
- if(DouYinService::payTailNotify($msg)){
- return json(["err_no"=>0,"err_tips"=>"success"], 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
- 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
- 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
- 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;
- 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();
- $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);
- }
- }
- }
|