| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?php
- namespace app\api\controller;
- use think\facade\Log;
- use app\common\logic\PaymentLogic;
- use app\api\logic\GroupActivityLogic;
- use app\api\validate\GroupOrderValidate;
- use app\api\lists\group_activity\UserOrderLists;
- use app\api\lists\property\PropertyGroupOrderLists;
- use app\api\lists\property\PropertyServiceWorkLists;
- /**
- * 拼团活动控制器
- * Class UserController
- * @package app\api\controller
- */
- class GroupActivityController extends BaseApiController
- {
- public array $notNeedLogin = [];
- /**
- * 活动分类列表
- */
- public function categoryList()
- {
- $id = (int)$this->request->param('id');
- $block_key = (int)$this->request->param('block_key');
- $result = GroupActivityLogic::categoryList($id,$block_key);
- return $this->data($result);
- }
- /**
- * 活动详情
- */
- public function detail()
- {
- $id = (int)$this->request->param('id');
- $result = GroupActivityLogic::detail($id,$this->userId);
- return $this->data($result);
- }
- /**
- * 拼团订单详情
- */
- public function orderDetail(){
- $order_id = (int)$this->request->param('order_id');
- $result = GroupActivityLogic::orderDetail($order_id,$this->userId,$this->request->domain());
- return $this->data($result);
- }
- /**
- * 用户订单详情
- */
- public function userOrderDetail(){
- $order_id = (int)$this->request->param('order_id');
- $result = GroupActivityLogic::userOrderDetail($order_id,$this->userId);
- return $this->data($result);
- }
- /**
- * 用户的订单列表
- */
- public function orderList(){
- return $this->dataLists(new UserOrderLists());
- }
- /**
- * 提交订单
- * @return \think\response\Json
- */
- public function submitOrder()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('add', [
- 'user_id' => $this->userId,
- 'terminal' => $this->userInfo['terminal'],
- 'user_info' => $this->userInfo
- ]);
- $result = GroupActivityLogic::submitOrder($params);
- if (false === $result) {
- return $this->fail(GroupActivityLogic::getError());
- }
- return $this->data($result);
- }
- /**
- * @notes 预支付
- * @return \think\response\Json
- */
- public function prepay()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('pay');
- //订单信息
- $order = PaymentLogic::getPayGroupOrderInfo($params);
- if (false === $order) {
- return $this->fail(PaymentLogic::getError());
- }
- //支付流程
- $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
- $result = PaymentLogic::pay($params['pay_way'], 'group', $order, 1, $redirectUrl);
- if (false === $result) {
- return $this->fail(PaymentLogic::getError());
- }
- $result['sn'] = $order['sn'];
- Log::write('group_prepay:'.json_encode($result, JSON_UNESCAPED_UNICODE));
- return $this->success('', $result);
- }
- /**
- * @notes 获取支付状态
- * @return \think\response\Json
- */
- public function payStatus()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('status',[
- 'from' => 'group',
- 'user_id' => $this->userId,
- ]);
- $result = PaymentLogic::getPayStatus($params);
- if ($result === false) {
- return $this->fail(PaymentLogic::getError());
- }
- return $this->data($result);
- }
- /**
- * 取消订单
- * @return \think\response\Json
- */
- public function cancelOrder()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('cancel', [
- 'user_id' => $this->userId
- ]);
- $result = GroupActivityLogic::cancelOrder($params);
- if (false === $result) {
- return $this->fail(GroupActivityLogic::getError());
- }
- return $this->success('取消成功', [], 1, 1);
- }
- /**
- * 申请退款
- * @return \think\response\Json
- */
- public function refundOrder()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('refund', [
- 'user_id' => $this->userId
- ]);
- $result = GroupActivityLogic::refundOrder($params);
- list($flag, $msg) = $result;
- if(false === $flag) {
- return $this->fail($msg);
- }
- if (false === $result) {
- return $this->fail(GroupActivityLogic::getError());
- }
- return $this->success('退款成功', [], 1, 1);
- }
- public function deleteOrder()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('refund',[
- 'user_id' => $this->userId
- ]);
- $result = GroupActivityLogic::deleteOrder($params);
- if (false === $result) {
- return $this->fail(GroupActivityLogic::getError());
- }
- return $this->success('删除成功', [], 1, 1);
- }
- /**
- * 获取拼团订单分享二维码
- */
- public function getQRCode()
- {
- $params = (new GroupOrderValidate())->post()->goCheck('qrcode');
- return $this->success('',['qrcode'=>GroupActivityLogic::getQRCode($params, $this->request->domain())], 1, 1);
- }
- /**
- * 代理人拼团订单列表
- */
- public function propertyOrderLists()
- {
- return $this->dataLists(new PropertyGroupOrderLists());
- }
- /**
- * 代理人完结的工单列表
- */
- public function propertyServiceWorkLists()
- {
- return $this->dataLists(new PropertyServiceWorkLists());
- }
- }
|