PurchaseController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace shop\controllers;
  3. use biz\purchase\classes\PurchaseClass;
  4. use biz\purchase\services\PurchaseService;
  5. use bizGhs\product\classes\ProductClass;
  6. use common\components\orderSn;
  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. $upShopId = $post['upShopId'] ?? 0;
  16. $post['shopId'] = $this->shopId;
  17. $product = $post['product'] ?? '';
  18. $productList = json_decode($product, true);
  19. //判断product数据是不是同个供货商的
  20. ProductClass::valid($productList, $upShopId);
  21. $post['product'] = $productList;
  22. $respond = PurchaseClass::addPurchase($post);
  23. $orderSn = $respond['orderSn'] ?? '';
  24. $actPrice = $respond['actPrice'] ?? '';
  25. $data = [
  26. 'orderSn' => $orderSn,
  27. 'actPrice' => $actPrice,
  28. 'hasBalancePay' => 1,
  29. 'hasPayPassword' => 0,
  30. 'hasDebtPay' => 1,
  31. ];
  32. util::success($data);
  33. }
  34. //延期支付 shish 2021.1.24
  35. public function actionDebtPay()
  36. {
  37. $get = Yii::$app->request->get();
  38. $id = $get['id'] ?? 0;
  39. $info = PurchaseClass::getInfo($id);
  40. PurchaseClass::valid($info, $this->shopId);
  41. PurchaseClass::debt($info);
  42. util::complete();
  43. }
  44. //余额支付 shish 2021.1.24
  45. public function actionBalancePay()
  46. {
  47. $get = Yii::$app->request->get();
  48. $id = $get['id'] ?? 0;
  49. $password = $get['password'] ?? '';
  50. $info = PurchaseClass::getInfo($id);
  51. PurchaseClass::valid($info, $this->shopId);
  52. purchaseClass::balancePay($info);
  53. util::complete();
  54. }
  55. //采购记录 shish 2021.1.24
  56. public function actionList()
  57. {
  58. $get = Yii::$app->request->get();
  59. $where = ['merchantId' => $this->merchantId];
  60. $status = $get['status'] ?? 0;
  61. if (!empty($status)) {
  62. $where['status'] = $status;
  63. }
  64. $list = PurchaseService::getPurchaseList($where);
  65. util::success($list);
  66. }
  67. }