| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace ghs\controllers;
- use bizGhs\clear\classes\ClearClass;
- use bizHd\purchase\classes\PurchaseClearClass;
- use common\components\dict;
- use common\components\util;
- use Yii;
- class PurchaseClearController extends BaseController
- {
- //供货商向基地供货商结账生成订单 ssh 20220523
- public function actionCreateOrder()
- {
- $post = Yii::$app->request->post();
- $current = time();
- $list = ClearClass::getAllByCondition(['shopId' => $this->shopId, 'status' => PurchaseClearClass::STATUS_AWAIT_PAY], null, '*', null, true);
- if (!empty($list)) {
- foreach ($list as $item) {
- $deadline = $item->deadline;
- $deadTime = strtotime($deadline);
- if ($current > $deadTime) {
- $item->status = PurchaseClearClass::STATUS_EXPIRE;
- $item->save();
- } else {
- util::fail('还有结算订单待付款');
- }
- }
- }
- $post['sjId'] = $this->sjId;
- $post['shopId'] = $this->shopId;
- $post['clearStyle'] = dict::getDict('clearStyle', 'gys2KmGys');
- $post['customShopAdminId'] = $this->shopAdminId;
- $post['customShopId'] = $this->shopId ?? 0;
- $shopAdmin = $this->shopAdmin;
- $shopAdminName = $shopAdmin['name'] ?? '';
- $post['customShopAdminName'] = $shopAdminName;
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $respond = ClearClass::addOrder($post);
- $transaction->commit();
- util::success($respond);
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::info("下单失败原因:" . $e->getMessage());
- util::fail('下单失败');
- }
- }
- }
|