| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace ghs\controllers;
- use biz\ghs\classes\GhsClass;
- use bizGhs\order\classes\PurchaseOrderClass;
- use bizGhs\order\services\PurchaseOrderService;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class PurchaseController extends BaseController
- {
- //待结款明细 ssh 2021.1.26
- public function actionDebtList()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $confirm = $get['confirm'] ?? -1;
- $shortOrderSn = $get['shortOrderSn'] ?? '';
- $info = GhsClass::getGhsInfo($id);
- GhsClass::valid($info, $this->shopId);
- $where = ['ghsId' => $id, 'debt' => PurchaseOrderClass::DEBT_YES];
- if ($confirm > -1) {
- $where['confirm'] = $confirm;
- }
- $searchTime = $get['searchTime'] ?? '';
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- $where['entryTime'] = ['between', [$period['startTime'], $period['endTime']]];
- }
- if (!empty($shortOrderSn)) {
- $where['orderSn'] = ['like', $shortOrderSn];
- }
- $respond = PurchaseOrderService::getDebtList($where);
- $respond['ghsInfo'] = $info;
- util::success($respond);
- }
- //批量确认 ssh 20240518
- public function actionBatchConfirm()
- {
- if (getenv('YII_ENV') == 'production') {
- //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
- if (in_array($this->mainId, [23390, 24516])) {
- if (!in_array($this->adminId, [24655])) {
- util::fail('不能操作哦');
- }
- }
- } else {
- if (in_array($this->shopId, [36523])) {
- // if (!in_array($this->adminId, [919])) {
- // util::fail('不能操作哈');
- // }
- }
- }
- $post = Yii::$app->request->post();
- $str = $post['id'] ?? 0;
- $ghsId = $post['ghsId'] ?? 0;
- if (empty($str)) {
- util::fail('没有选择订单');
- }
- $arr = json_decode($str, true);
- $ids = array_column($arr, 'id');
- if (empty($ids)) {
- util::fail('没有订单哦');
- }
- $list = PurchaseOrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
- if (empty($list)) {
- util::fail('没有订单');
- }
- foreach ($list as $order) {
- if ($order->ghsId != $ghsId) {
- util::fail('订单有问题');
- }
- $order->confirm = 1;
- $order->save();
- }
- util::complete('确认成功');
- }
- }
|