OrderController.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /**
  3. * OrderController.php
  4. * todo 文件描述
  5. * Created on 2024/12/4 上午9:09
  6. * @author: hankaige
  7. */
  8. namespace app\modules\client\controllers\v1\cashier;
  9. use app\models\Order;
  10. use app\modules\admin\models\cashier\OrderListForm;
  11. use app\modules\admin\models\order\MchOrderPayDataForm;
  12. use app\modules\admin\models\order\MchOrderSubmitForm;
  13. use app\modules\admin\models\order\MchOrderSubmitPreviewForm;
  14. use app\modules\admin\models\order\ReuseOrderGoodsPriceForm;
  15. use app\modules\client\models\v1\cashier\OrderForm;
  16. use app\utils\PrintOrder;
  17. class OrderController extends BaseController
  18. {
  19. /**
  20. * 获取直接收银二维码 走二维码当面付款逻辑
  21. * @return \yii\web\Response
  22. * @author: hankaige
  23. * @Time: 2024/12/4 下午1:43
  24. */
  25. public function actionGetPayQrcode():\yii\web\Response
  26. {
  27. $form = new OrderForm();
  28. $form->store_id = get_store_id();
  29. $form->md_id = $this->md_id;
  30. $form->scenario = $form::IMMEDIATELY_PAY;
  31. $form->attributes = get_params();
  32. return $this->asJson($form->getPayQrcode());
  33. }
  34. /**
  35. * 操作挂单
  36. * @return \yii\web\Response
  37. * @author: hankaige
  38. * @Time: 2024/12/5 上午9:15
  39. */
  40. public function actionHangingOrder():\yii\web\Response
  41. {
  42. $form = new OrderForm();
  43. $form->store_id = get_store_id();
  44. $form->scenario = $form::HANGING_ORDER;
  45. $form->attributes = post_params();
  46. return $this->asJson($form->hangingOrder());
  47. }
  48. /**
  49. * 获取挂单列表
  50. * @return \yii\web\Response
  51. * @author: hankaige
  52. * @Time: 2024/12/5 上午10:53
  53. */
  54. public function actionGetHangingOrderList():\yii\web\Response
  55. {
  56. $form = new OrderForm();
  57. $form->store_id = get_store_id();
  58. $form->md_id = $this->md_id;
  59. $form->scenario = $form::HANGING_ORDER_LIST;
  60. $form->attributes = get_params();
  61. return $this->asJson($form->getHangingOrderList());
  62. }
  63. public function actionGetHangingOrderDetail():\yii\web\Response
  64. {
  65. $form = new OrderForm();
  66. $form->store_id = get_store_id();
  67. $form->md_id = $this->md_id;
  68. $form->scenario = $form::HANGING_ORDER_DETAIL;
  69. $form->attributes = get_params();
  70. return $this->asJson($form->getHangingOrderDetail());
  71. }
  72. /**
  73. * 删除挂单订单
  74. * @return \yii\web\Response
  75. * User: hankaige
  76. * DATE TIME: 2022/12/6 09:36
  77. */
  78. public function actionDelHangingOrder(){
  79. $form = new OrderForm();
  80. $form->store_id = get_store_id();
  81. $form->scenario = $form::DEL_HANGING_ORDER;
  82. $form->attributes = get_params();
  83. return $this->asJson($form->delHanging());
  84. }
  85. /**
  86. * 取出挂单信息
  87. * @return \yii\web\Response
  88. * @author: hankaige
  89. * @Time: 2024/12/5 上午11:36
  90. */
  91. public function actionGetHangingOrder():\yii\web\Response
  92. {
  93. $form = new OrderForm();
  94. $form->store_id = get_store_id();
  95. $form->md_id = $this->md_id;
  96. $form->scenario = $form::GET_HANGING_ORDER;
  97. $form->attributes = get_params();
  98. return $this->asJson($form->getHangingOrder());
  99. }
  100. public function actionOrderPreview():\yii\web\Response
  101. {
  102. $form = new MchOrderSubmitPreviewForm();
  103. $form->store_id = get_store_id();
  104. $form->md_id = $this->md_id;
  105. $form->attributes = post_params();
  106. return $this->asJson($form->search());
  107. }
  108. // todo 生成待支付订单
  109. public function actionOrderSubmit(){
  110. $form = new MchOrderSubmitForm();
  111. $params = post_params();
  112. $params['hangind_order_id'] = empty($params['hangind_order_id']) || $params['hangind_order_id'] == 'null' ? 0 : $params['hangind_order_id'];
  113. $form->attributes = $params;
  114. $form->user_id = post_params('user_id');
  115. $form->store_id = get_store_id();
  116. $form->md_id = $this->md_id;
  117. return $this->asJson($form->save());
  118. }
  119. // todo 支付订单
  120. public function actionPayData(){
  121. $form = new MchOrderPayDataForm();
  122. $form->attributes = post_params();
  123. $form->user_id = post_params('user_id');
  124. $form->store_id = get_store_id();
  125. $form->md_id = $this->md_id;
  126. $form->_from = 'cashier';
  127. return $this->asJson($form->search());
  128. }
  129. public function actionOrderList():\yii\web\Response
  130. {
  131. $form = new OrderForm();
  132. $form->store_id = get_store_id();
  133. $form->md_id = $this->md_id;
  134. $form->scenario = $form::ORDER_LIST;
  135. $form->attributes = get_params();
  136. return $this->asJson($form->orderList());
  137. }
  138. public function actionRefundOrder():\yii\web\Response
  139. {
  140. // 获取订单
  141. $store_id = get_store_id();
  142. $form = new OrderListForm();
  143. $form->attributes = get_params();
  144. $form->is_offline = Order::IS_OFFLINE_FALSE;
  145. $form->store_id = $store_id;
  146. $form->order_id = get_params('order_id');
  147. return $this->asJson($form->orderRefund());
  148. }
  149. public function actionPrintOrder(){
  150. $data = post_params();
  151. $type = $data['type'] ?? 0;
  152. $store_id = get_store_id();
  153. $md_id = $this->md_id;
  154. $mch_id = get_mch_id();
  155. if ((int)$md_id === -1 || (int)$md_id === 0) {
  156. $md_id = 0;
  157. }
  158. // 订单打印
  159. $print = new PrintOrder($store_id, $data['order_id'], 'reprint', $data['order_type'],
  160. $md_id ?: 0, $type, $mch_id);
  161. return $this->asJson($print->print_order());
  162. }
  163. public function actionGetReuseGoodsPrice(){
  164. $form = new ReuseOrderGoodsPriceForm();
  165. $form->user_id = post_params('user_id');
  166. $form->goods_id = post_params('goods_id');
  167. $form->store_id = get_store_id();
  168. return $this->asJson($form->search());
  169. }
  170. }