| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace ghs\controllers;
- use biz\ghs\classes\GhsClass;
- use bizGhs\order\classes\PurchaseOrderClass;
- use bizGhs\order\services\PurchaseOrderService;
- use bizHd\purchase\classes\PurchaseClass;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class PurchaseController extends BaseController
- {
- public $guestAccess = ['get-cg-salt'];
- /**
- * 分享跳转花店采购详情时,按 xhCg 主键取 salt(无需登录)
- */
- public function actionGetCgSalt()
- {
- $get = Yii::$app->request->get();
- $id = intval($get['id'] ?? 0);
- if (empty($id)) {
- util::fail('采购单无效');
- }
- $cg = PurchaseClass::getById($id, true);
- if (empty($cg)) {
- util::fail('没有找到采购单');
- }
- $payDate = substr($cg->payTime ?? '', 0, 10);
- //2026年6月1号前的可以取这个数据,之后的不行
- if ($payDate >= '2026-06-01') {
- util::fail('该分享链接已失效');
- }
- $salt = $cg->salt ?? '';
- if (empty($salt)) {
- util::fail('采购单信息无效');
- }
- util::success(['salt' => $salt]);
- }
- //待结款明细 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,77951])) {
- 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('确认成功');
- }
- }
|