OrderController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\merchant\services\MerchantExtendService;
  4. use bizGhs\admin\classes\AdminClass;
  5. use bizGhs\custom\classes\CustomClass;
  6. use bizGhs\merchant\services\ShopService;
  7. use bizGhs\order\classes\OrderClass;
  8. use bizGhs\order\services\OrderService;
  9. use biz\saas\services\RegionService;
  10. use biz\user\services\UserService;
  11. use bizGhs\product\classes\ProductClass;
  12. use common\components\configDict;
  13. use common\components\httpUtil;
  14. use common\services\xhPayToolService;
  15. use Yii;
  16. use common\components\util;
  17. use common\components\stringUtil;
  18. class OrderController extends BaseController
  19. {
  20. public $withoutLogin = ['order-relate', 'fast-pay'];
  21. //商城下单操作 shish 2021.1.14
  22. public function actionCreateOrder()
  23. {
  24. $post = Yii::$app->request->post();
  25. $adminId = $this->adminId;
  26. $shopId = $this->shopId;
  27. if (!empty($shopId)) {
  28. //供货商端 员工 开单
  29. $post['customId'] = $post['customId'] ?? 0;
  30. $post['adminId'] = $adminId;
  31. $post['userId'] = 0;
  32. } else {
  33. //供货商端 客户 开单
  34. $post['userId'] = $adminId;
  35. $post['adminId'] = 0;
  36. $post['customId'] = CustomClass::addCustom();
  37. }
  38. $post['payWay'] = $this->isWx == true ? 0 : 1;
  39. $post['merchantId'] = $this->merchantId;
  40. $post['shopId'] = 0;
  41. $post['deadline'] = time() + 1800;//订单30分钟后过期
  42. $post['fromType'] = 1;//商城
  43. $post['prePrice'] = 0.01;
  44. $post['actPrice'] = 0.01;
  45. $post['sendSide'] = $post['sendSide'] ?? 0;
  46. $productJson = $post['product'] ?? '';
  47. if (empty($productJson)) {
  48. util::fail('请选择花材');
  49. }
  50. $productList = json_decode($productJson, true);
  51. if (empty($productList)) {
  52. util::fail('请选择花材');
  53. }
  54. $productIds = array_column($productList, 'productId');
  55. ProductClass::valid($productIds, $this->merchantId);
  56. $post['product'] = $productList;
  57. $order = OrderClass::addOrder($post);
  58. $orderSn = $order['orderSn'] ?? '';
  59. $orderId = $order['id'] ?? 0;
  60. util::success([
  61. 'orderId' => $orderId,
  62. 'orderSn' => $orderSn,
  63. 'totalPrice' => 0.01,
  64. 'sendType' => '快递送',
  65. 'sendTime' => '15:00',
  66. 'qrCode' => Yii::$app->params['imgHost'] . '/hhb_small.png',
  67. ]);
  68. }
  69. //延期支付 shish 2021.1.19
  70. public function actionDebt()
  71. {
  72. $get = Yii::$app->request->get();
  73. $orderId = $get['orderId'] ?? 0;
  74. util::complete();
  75. }
  76. }