AdoptCostOrderController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\plugins\adopt\controllers\client;
  8. use app\models\Order;
  9. use app\plugins\adopt\controllers\BaseController;
  10. use app\modules\client\models\v1\ExpressDetailForm;
  11. use app\modules\client\models\v1\order\OrderPayDataForm;
  12. use app\modules\client\models\v1\order\OrderSubmitForm;
  13. use app\modules\client\models\v1\order\OrderSubmitPreviewForm;
  14. use app\modules\client\models\v1\OrderCommentForm;
  15. use app\modules\client\models\v1\OrderCommentPreview;
  16. use app\modules\client\models\v1\OrderConfirmForm;
  17. use app\modules\client\models\v1\OrderDetailForm;
  18. use app\modules\client\models\v1\OrderListForm;
  19. use app\modules\client\models\v1\OrderRefundPreviewForm;
  20. use app\modules\client\models\v1\OrderRevokeForm;
  21. use app\modules\client\models\v1\SaasOrderForm;
  22. use app\plugins\adopt\models\client\AdoptCostOrderDetailForm;
  23. use app\plugins\adopt\models\client\AdoptCostOrderListForm;
  24. use app\plugins\adopt\models\client\AdoptOrderDetailForm;
  25. use app\plugins\adopt\models\client\AdoptOrderListForm;
  26. use app\plugins\adopt\models\client\AdoptOrderPickForm;
  27. use app\plugins\adopt\models\client\AdoptOrderPreserveForm;
  28. use app\plugins\adopt\models\client\CostExpressDetailForm;
  29. use app\plugins\adopt\models\client\CostOrderConfirmForm;
  30. use app\plugins\adopt\models\client\CostOrderPayDataForm;
  31. use app\plugins\adopt\models\client\CostOrderRevokeForm;
  32. use app\plugins\adopt\models\client\CostOrderSubmitForm;
  33. use app\plugins\adopt\models\client\CostOrderSubmitPreviewForm;
  34. use app\utils\Delivery\Delivery;
  35. use app\utils\ShareQrcode;
  36. use yii\base\BaseObject;
  37. class AdoptCostOrderController extends BaseController
  38. {
  39. public function behaviors()
  40. {
  41. return parent::behaviors();
  42. }
  43. /**
  44. * 新-订单提交前的预览页面
  45. * @return \yii\web\Response
  46. */
  47. public function actionSubmitPreview()
  48. {
  49. $form = new CostOrderSubmitPreviewForm();
  50. $form->attributes = post_params();
  51. $form->store_id = get_store_id();
  52. $form->user_id = get_user_id();
  53. return $form->search();
  54. }
  55. /**
  56. * 新-订单提交
  57. * @return \yii\web\Response
  58. */
  59. public function actionSubmit()
  60. {
  61. $form = new CostOrderSubmitForm();
  62. $form->attributes = post_params();
  63. $form->store_id = get_store_id();
  64. $form->user_id = get_user_id();
  65. $form->user = get_user();
  66. return $form->save();
  67. }
  68. /**
  69. * 订单支付数据
  70. * @return \yii\web\Response
  71. */
  72. public function actionPayData()
  73. {
  74. $form = new CostOrderPayDataForm();
  75. $form->attributes = get_params();
  76. $form->store_id = get_store_id();
  77. $form->user = get_user();
  78. return $form->search();
  79. }
  80. /**
  81. * 订单列表
  82. * @return \yii\web\Response
  83. */
  84. public function actionList()
  85. {
  86. $form = new AdoptCostOrderListForm();
  87. $form->attributes = get_params();
  88. $form->store_id = get_store_id();
  89. $form->user_id = get_user_id();
  90. return $form->search();
  91. }
  92. /**
  93. * 订单取消
  94. * @return \yii\web\Response
  95. */
  96. public function actionRevoke()
  97. {
  98. $form = new CostOrderRevokeForm();
  99. $form->attributes = get_params();
  100. $form->store_id = get_store_id();
  101. $form->user_id = get_user_id();
  102. return $form->save();
  103. }
  104. /**
  105. * 订单详情
  106. * @return \yii\web\Response
  107. */
  108. public function actionDetail()
  109. {
  110. $form = new AdoptCostOrderDetailForm();
  111. $form->attributes = get_params();
  112. $form->store_id = get_store_id();
  113. if (!empty(get_params('userId'))) {
  114. $form->user_id = get_params('userId');
  115. } else {
  116. $form->user_id = get_user_id();
  117. }
  118. return $form->search();
  119. }
  120. /**
  121. * 订单确认收货
  122. */
  123. public function actionConfirm()
  124. {
  125. $form = new CostOrderConfirmForm();
  126. $form->attributes = get_params();
  127. $form->store_id = get_store_id();
  128. $form->user_id = get_user_id();
  129. return $form->save();
  130. }
  131. /**
  132. * 订单物流信息
  133. */
  134. public function actionExpressDetail()
  135. {
  136. $form = new CostExpressDetailForm();
  137. $form->attributes = get_params();
  138. $form->store_id = get_store_id();
  139. $form->user_id = get_user_id();
  140. return $form->search();
  141. }
  142. /**
  143. * @return \yii\web\Response
  144. */
  145. public function actionUserDelete() {
  146. $order_id = post_params('order_id');
  147. $order = Order::findOne(['id' => $order_id, 'user_delete' => 1]);
  148. if ($order) {
  149. return $this->asJson([
  150. 'code' => 1,
  151. 'msg' => '订单已删除'
  152. ]);
  153. }
  154. Order::updateAll(['user_delete' => 1], ['id' => $order_id]);
  155. return $this->asJson([
  156. 'code' => 0,
  157. 'msg' => '删除成功'
  158. ]);
  159. }
  160. public function actionFriendPay() {
  161. $order_id = post_params('order_id');
  162. $order = Order::findOne(['id' => $order_id, 'is_delete' => 0]);
  163. \Yii::warning(['-------- 代付 -------', [$order_id, get_user_id()]]);
  164. if (get_user_id() != $order->user_id) {
  165. $order->pay_user_id = get_user_id();
  166. $order->save();
  167. }
  168. return $this->asJson([
  169. 'code' => 0,
  170. 'msg' => 'success'
  171. ]);
  172. }
  173. }