PurchaseController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\purchase\classes\PurchaseClass;
  4. use bizHd\purchase\services\PurchaseService;
  5. use bizGhs\merchant\classes\SupplierClass;
  6. use bizGhs\product\classes\ProductClass;
  7. use Yii;
  8. use common\components\util;
  9. class PurchaseController extends BaseController
  10. {
  11. //生成采购单 shish 2021.1.17
  12. public function actionCreateOrder()
  13. {
  14. $post = Yii::$app->request->post();
  15. $supplierId = $post['supplierId'] ?? 0;
  16. //供货商
  17. $supplier = SupplierClass::getById($supplierId);
  18. if (empty($supplier)) {
  19. util::fail('没有找到供货商');
  20. }
  21. $upShopId = $supplier['upShopId'] ?? 0;
  22. $upId = $supplier['upId'] ?? 0;
  23. $post['upShopId'] = $upShopId;
  24. $post['upId'] = $upId;
  25. $post['shopId'] = $this->shopId;
  26. $product = $post['product'] ?? '';
  27. $productList = json_decode($product, true);
  28. //判断product数据是不是同个供货商的
  29. ProductClass::valid($productList, $upShopId);
  30. $post['product'] = $productList;
  31. $respond = PurchaseClass::addPurchase($post);
  32. $orderSn = $respond['orderSn'] ?? '';
  33. $actPrice = $respond['actPrice'] ?? '';
  34. $data = [
  35. 'orderSn' => $orderSn,
  36. 'actPrice' => $actPrice,
  37. 'hasBalancePay' => 1,
  38. 'hasPayPassword' => 0,
  39. 'hasDebtPay' => 1,
  40. ];
  41. util::success($data);
  42. }
  43. //延期支付 shish 2021.1.24
  44. public function actionDebtPay()
  45. {
  46. $get = Yii::$app->request->get();
  47. $id = $get['id'] ?? 0;
  48. $info = PurchaseClass::getInfo($id);
  49. PurchaseClass::valid($info, $this->shopId);
  50. PurchaseClass::debt($info);
  51. util::complete();
  52. }
  53. //余额支付 shish 2021.1.24
  54. public function actionBalancePay()
  55. {
  56. $get = Yii::$app->request->get();
  57. $id = $get['id'] ?? 0;
  58. $password = $get['password'] ?? '';
  59. $info = PurchaseClass::getInfo($id);
  60. PurchaseClass::valid($info, $this->shopId);
  61. purchaseClass::balancePay($info);
  62. util::complete();
  63. }
  64. //采购记录 shish 2021.1.24
  65. public function actionList()
  66. {
  67. $get = Yii::$app->request->get();
  68. $where = ['merchantId' => $this->sjId];
  69. $status = $get['status'] ?? 0;
  70. if (!empty($status)) {
  71. $where['status'] = $status;
  72. }
  73. $list = PurchaseService::getPurchaseList($where);
  74. util::success($list);
  75. }
  76. //采购详情 shish 2021.01.25
  77. public function actionDetail()
  78. {
  79. $get = Yii::$app->request->get();
  80. $id = $get['id'] ?? 0;
  81. $info = PurchaseClass::getInfo($id, true, true, true);
  82. PurchaseClass::valid($info, $this->shopId);
  83. util::success($info);
  84. }
  85. //可用的支付方式 shish 2021.1.25
  86. public function actionPayWay()
  87. {
  88. $button = [
  89. ['type' => 'wxPay', 'show' => 1, 'disable' => 1],
  90. ['type' => 'debtPay', 'show' => 1, 'disable' => 0],
  91. ['type' => 'balancePay', 'show' => 1, 'disable' => 0],
  92. ];
  93. util::success(['button' => $button]);
  94. }
  95. //待结款明细 shish 2021.1.26
  96. public function actionDebtList()
  97. {
  98. $get = Yii::$app->request->get();
  99. $where = [
  100. 'merchantId' => $this->sjId,
  101. 'debt' => PurchaseClass::DEBT_YES
  102. ];
  103. $respond = PurchaseService::getDebtList($where);
  104. util::success($respond);
  105. }
  106. }