PurchaseController.php 3.5 KB

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