PurchaseController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace shop\controllers;
  3. use biz\purchase\classes\PurchaseClass;
  4. use biz\purchase\services\PurchaseService;
  5. use bizGhs\merchant\classes\SupplierClass;
  6. use bizGhs\product\classes\ProductClass;
  7. use common\components\orderSn;
  8. use Yii;
  9. use common\components\util;
  10. class PurchaseController extends BaseController
  11. {
  12. //生成采购单 shish 2021.1.17
  13. public function actionCreateOrder()
  14. {
  15. $post = Yii::$app->request->post();
  16. $supplierId = $post['supplierId'] ?? 0;
  17. //供货商
  18. $supplier = SupplierClass::getById($supplierId);
  19. if (empty($supplier)) {
  20. util::fail('没有找到供货商');
  21. }
  22. $upShopId = $supplier['upShopId'] ?? 0;
  23. $upId = $supplier['upId'] ?? 0;
  24. $post['shopId'] = $this->shopId;
  25. $product = $post['product'] ?? '';
  26. $productList = json_decode($product, true);
  27. //判断product数据是不是同个供货商的
  28. ProductClass::valid($productList, $upShopId);
  29. $post['product'] = $productList;
  30. $respond = PurchaseClass::addPurchase($post);
  31. $orderSn = $respond['orderSn'] ?? '';
  32. $actPrice = $respond['actPrice'] ?? '';
  33. $data = [
  34. 'orderSn' => $orderSn,
  35. 'actPrice' => $actPrice,
  36. 'hasBalancePay' => 1,
  37. 'hasPayPassword' => 0,
  38. 'hasDebtPay' => 1,
  39. ];
  40. util::success($data);
  41. }
  42. //延期支付 shish 2021.1.24
  43. public function actionDebtPay()
  44. {
  45. $get = Yii::$app->request->get();
  46. $id = $get['id'] ?? 0;
  47. $info = PurchaseClass::getInfo($id);
  48. PurchaseClass::valid($info, $this->shopId);
  49. PurchaseClass::debt($info);
  50. util::complete();
  51. }
  52. //余额支付 shish 2021.1.24
  53. public function actionBalancePay()
  54. {
  55. $get = Yii::$app->request->get();
  56. $id = $get['id'] ?? 0;
  57. $password = $get['password'] ?? '';
  58. $info = PurchaseClass::getInfo($id);
  59. PurchaseClass::valid($info, $this->shopId);
  60. purchaseClass::balancePay($info);
  61. util::complete();
  62. }
  63. //采购记录 shish 2021.1.24
  64. public function actionList()
  65. {
  66. $get = Yii::$app->request->get();
  67. $where = ['merchantId' => $this->merchantId];
  68. $status = $get['status'] ?? 0;
  69. if (!empty($status)) {
  70. $where['status'] = $status;
  71. }
  72. $list = PurchaseService::getPurchaseList($where);
  73. util::success($list);
  74. }
  75. }