| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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([
- 'clearStyle' => dict::getDict('clearStyle', 'gys2KmGys'),
- '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('还有待付款的结账单');
- }
- }
- }
- if (getenv('YII_ENV') == 'production') {
- //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
- if (in_array($this->mainId, [23390, 24516])) {
- if (!in_array($this->adminId, [24655,77951])) {
- util::fail('不能操作哈');
- }
- }
- //花大苪 洋桔梗,只有叶荷姐才能销账,多处请搜索关键词hdb_clear_control
- if (in_array($this->shopId, [16070])) {
- if (!in_array($this->adminId, [9303, 4])) {
- util::fail('暂无权限');
- }
- }
- //中山淘花里,销账权限控制,多处请搜索 thl_clear_control
- if (in_array($this->shopId, [17118])) {
- if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) {
- util::fail('你不能销单!');
- }
- }
- //淘花里小榄店 thl_xl_clear
- if (in_array($this->shopId, [72366])) {
- if (!in_array($this->adminId, [69792,55445,55707,69792])) {
- util::fail('你不能销单那。。。');
- }
- }
- //淘花里珠海店
- if (in_array($this->shopId, [78556])) {
- if (!in_array($this->adminId, [69132, 75771, 43732, 55734, 47775, 55711, 40678, 75798])) {
- util::fail('你不能销单,编号6553');
- }
- }
- //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
- if (in_array($this->shopId, [41467, 42946])) {
- if (!in_array($this->adminId, [40144,42912,42023])) {
- util::fail('不能操作哈。。');
- }
- }
- //恋善好多花控制销账权限
- if (in_array($this->shopId, [55238,56609,56611])) {
- if (!in_array($this->adminId, [43856, 54620])) {
- util::fail('暂无权限,请联系老板或财务');
- }
- }
- } else {
- if (in_array($this->shopId, [36523])) {
- // if (!in_array($this->adminId, [919])) {
- // 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('下单失败');
- }
- }
- }
|