| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace app\workerapi\controller\shops;
- use app\common\logic\PaymentLogic;
- use app\workerapi\controller\BaseApiController;
- use app\workerapi\lists\shops\ShopOrderLists;
- use app\workerapi\logic\shops\ShopOrderLogic;
- use app\workerapi\validate\shops\ShopOrderValidate;
- use app\workerapi\validate\shops\ShopPayValidate;
- /**
- * 商城订单
- */
- class OrderController extends BaseApiController
- {
- public function submitOrder()
- {
- $params = (new ShopOrderValidate())->post()->goCheck('submit', [
- 'user_id' => $this->userId,
- 'terminal' => $this->userInfo['terminal'],
- 'user_info' => $this->userInfo
- ]);
- $result = ShopOrderLogic::submitOrder($params);
- if (false === $result) {
- return $this->fail(ShopOrderLogic::getError());
- }
- return $this->data($result);
- }
- public function lists()
- {
- return $this->dataLists(new ShopOrderLists());
- }
- public function detail()
- {
- $params = (new ShopOrderValidate())->goCheck('detail',[
- 'worker_id' => $this->userId,
- ]);
- $result = ShopOrderLogic::detail($params);
- if (false === $result) {
- return $this->fail(ShopOrderLogic::getError());
- }
- return $this->data($result);
- }
- /**
- * 取消订单
- */
- public function cancelOrder()
- {
- $params = (new ShopOrderValidate())->goCheck('detail',[
- 'worker_id' => $this->userId,
- ]);
- $result = ShopOrderLogic::cancelOrder($params);
- if (false === $result) {
- return $this->fail(ShopOrderLogic::getError());
- }
- return $this->success('取消成功', [], 1, 1);
- }
- /**
- * @notes 预支付
- * @return \think\response\Json
- */
- public function prepay()
- {
- $params = (new ShopPayValidate())->post()->goCheck('pay');
- //订单信息
- $order = PaymentLogic::getPayShopOrderInfo($params);
- if (false === $order) {
- return $this->fail(PaymentLogic::getError(), $params);
- }
- //支付流程
- $redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
- $result = PaymentLogic::shopPay($params['pay_way'], 'shop_goods', $order, $this->userInfo, $redirectUrl);
- if (false === $result) {
- return $this->fail(PaymentLogic::getError(), $params);
- }
- $result['sn'] = $order['sn'];
- return $this->success('', $result);
- }
- public function logisticDetail()
- {
- $params = (new ShopOrderValidate())->goCheck('detail',[
- 'worker_id' => $this->userId,
- ]);
- $result = ShopOrderLogic::logisticDetail($params);
- if (false === $result) {
- return $this->fail(ShopOrderLogic::getError());
- }
- return $this->data($result);
- }
- public function confirmReceipt()
- {
- $params = (new ShopOrderValidate())->goCheck('detail',[
- 'worker_id' => $this->userId,
- ]);
- $result = ShopOrderLogic::confirmReceipt($params);
- if (false === $result) {
- return $this->fail(ShopOrderLogic::getError());
- }
- return $this->success('确认收货成功', [], 1, 1);
- }
- public function deleteOrder()
- {
- $params = (new ShopOrderValidate())->goCheck('detail',[
- 'worker_id' => $this->userId,
- ]);
- $result = ShopOrderLogic::deleteOrder($params);
- if (false === $result) {
- return $this->fail(ShopOrderLogic::getError());
- }
- return $this->success('删除成功', [], 1, 1);
- }
- }
|