| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace hd\controllers;
- use bizHd\purchase\classes\PurchaseClass;
- use bizHd\purchase\services\PurchaseService;
- use bizGhs\merchant\classes\SupplierClass;
- use bizGhs\product\classes\ProductClass;
- use Yii;
- use common\components\util;
- class PurchaseController extends BaseController
- {
-
- //生成采购单 shish 2021.1.17
- public function actionCreateOrder()
- {
- $post = Yii::$app->request->post();
- $supplierId = $post['supplierId'] ?? 0;
- //供货商
- $supplier = SupplierClass::getById($supplierId);
- if (empty($supplier)) {
- util::fail('没有找到供货商');
- }
- $upShopId = $supplier['upShopId'] ?? 0;
- $upId = $supplier['upId'] ?? 0;
- $post['upShopId'] = $upShopId;
- $post['upId'] = $upId;
-
- $post['shopId'] = $this->shopId;
- $product = $post['product'] ?? '';
- $productList = json_decode($product, true);
- //判断product数据是不是同个供货商的
- ProductClass::valid($productList, $upShopId);
- $post['product'] = $productList;
- $respond = PurchaseClass::addPurchase($post);
- $orderSn = $respond['orderSn'] ?? '';
- $actPrice = $respond['actPrice'] ?? '';
- $data = [
- 'orderSn' => $orderSn,
- 'actPrice' => $actPrice,
- 'hasBalancePay' => 1,
- 'hasPayPassword' => 0,
- 'hasDebtPay' => 1,
- ];
- util::success($data);
- }
-
- //延期支付 shish 2021.1.24
- public function actionDebtPay()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $info = PurchaseClass::getInfo($id);
- PurchaseClass::valid($info, $this->shopId);
- PurchaseClass::debt($info);
- util::complete();
- }
-
- //余额支付 shish 2021.1.24
- public function actionBalancePay()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $password = $get['password'] ?? '';
- $info = PurchaseClass::getInfo($id);
- PurchaseClass::valid($info, $this->shopId);
- purchaseClass::balancePay($info);
- util::complete();
- }
-
- //采购记录 shish 2021.1.24
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = ['merchantId' => $this->sjId];
- $status = $get['status'] ?? 0;
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $list = PurchaseService::getPurchaseList($where);
- util::success($list);
- }
-
- //采购详情 shish 2021.01.25
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $info = PurchaseClass::getInfo($id, true, true, true);
- PurchaseClass::valid($info, $this->shopId);
- util::success($info);
- }
-
- //可用的支付方式 shish 2021.1.25
- public function actionPayWay()
- {
- $button = [
- ['type' => 'wxPay', 'show' => 1, 'disable' => 1],
- ['type' => 'debtPay', 'show' => 1, 'disable' => 0],
- ['type' => 'balancePay', 'show' => 1, 'disable' => 0],
- ];
- util::success(['button' => $button]);
- }
- //待结款明细 shish 2021.1.26
- public function actionDebtList()
- {
- $get = Yii::$app->request->get();
- $where = [
- 'merchantId' => $this->sjId,
- 'debt' => PurchaseClass::DEBT_YES
- ];
- $respond = PurchaseService::getDebtList($where);
- util::success($respond);
- }
- }
|