shish 5 gadi atpakaļ
vecāks
revīzija
9aca9e9a8e

+ 7 - 5
app-hd/controllers/PurchaseController.php

@@ -74,7 +74,7 @@ class PurchaseController extends BaseController
         $get = Yii::$app->request->get();
         $orderSn = $get['orderSn'] ?? 0;
         $info = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
-        PurchaseClass::valid($info->attributes, $this->shopId);
+        PurchaseService::valid($info, $this->shopId);
         $ghsId = $info->ghsId;
         $ghs = GhsClass::getGhsInfo($ghsId);
         $customId = $ghs['customId'] ?? 0;
@@ -113,8 +113,7 @@ class PurchaseController extends BaseController
         if (empty($info)) {
             util::fail('没有找到采购单');
         }
-
-        PurchaseClass::valid($info->attributes, $this->shopId);
+        PurchaseService::valid($info, $this->shopId);
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();
         try {
@@ -148,7 +147,9 @@ class PurchaseController extends BaseController
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $info = PurchaseService::getInfo($id, true, true);
-        PurchaseClass::valid($info, $this->shopId);
+        if (isset($info['shopId']) == false || $info['shopId'] != $this->shopId) {
+            util::fail('没有权限访问');
+        }
         util::success($info);
     }
 
@@ -240,9 +241,10 @@ class PurchaseController extends BaseController
         util::success($newParams);
     }
 
-    //运费计算  linqh 2021.4.12  暂反回固定
+    //运费计算  linqh 2021.4.12  暂时返回固定值
     public function actionFreight()
     {
         util::success(['sedCost' => 10]);
     }
+
 }

+ 37 - 0
app-hd/controllers/ShopCouponController.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace hd\controllers;
+
+use biz\shop\services\ShopCouponService;
+use common\components\util;
+use Yii;
+
+class ShopCouponController extends BaseController
+{
+
+    public $guestAccess = [];
+
+    //门店列表 shish 2021.5.15
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['shopId'] = $this->shopId;
+        $status = $get['status'] ?? 0;
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $list = ShopCouponService::getCouponList($where);
+        util::success($list);
+    }
+
+    //有可用红包 shish 2021.5.15
+    public function actionHas()
+    {
+        $data = [
+            'has' => rand(0, 1)
+        ];
+        util::success($data);
+    }
+
+}

+ 0 - 18
biz-hd/purchase/classes/PurchaseClass.php

@@ -202,30 +202,12 @@ class PurchaseClass extends BaseClass
     }
 
 
-    //检查采购单
-    public static function valid($info, $shopId)
-    {
-        if (empty($info)) {
-            util::fail('没有找到采购单');
-        }
-        if (isset($info['shopId']) && $info['shopId'] == $shopId) {
-            return true;
-        }
-        util::fail('没有权限操作');
-    }
-
     //订单取消,变更状态,占用库存释放 shish 2021.5.8
     public static function cancel($id)
     {
         $purchase = Purchase::findBySql('select * from ' . Purchase::tableName() . ' where id = :id for update', ['id' => $id])->one();
         $purchase->status = self::STATUS_CANCEL;
         $purchase->save();
-        //供货商那边加回库存
-//        $orderSn = $purchase->orderSn;
-//        $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, "*");
-//        foreach ($purchaseItem as $v) {
-//            ProductClass::addStockByItemNum($v['ghsProductId'], $v['itemNum']);
-//        }
 
         $shopId = $purchase->shopId;
         $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();

+ 12 - 2
biz-hd/purchase/services/PurchaseService.php

@@ -91,6 +91,18 @@ class PurchaseService extends BaseService
         return current($respond);
     }
 
+    //检查采购单
+    public static function valid($info, $shopId)
+    {
+        if (empty($info)) {
+            util::fail('没有找到采购单');
+        }
+        if (isset($info->shopId) && $info->shopId == $shopId) {
+            return true;
+        }
+        util::fail('没有权限操作');
+    }
+
     //采购记录 ssh 2021.1.24
     public static function getPurchaseList($where)
     {
@@ -130,7 +142,6 @@ class PurchaseService extends BaseService
             $saleId = $purchase->saleId;
             //销售单失效
             OrderClass::cancel($saleId);
-            return $purchase;
         }
         return $purchase;
     }
@@ -186,7 +197,6 @@ class PurchaseService extends BaseService
         }
         $deadline = $info->deadline;
         if ($deadline <= date("Y-m-d H:i:s")) {
-            PurchaseClass::cancel($info->id);
             util::fail('订单已失效,请重新采购');
         }
         if (isset($info->status) == false || $info->status != PurchaseClass::STATUS_UN_PAY) {

+ 21 - 0
biz/shop/classes/ShopCouponClass.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace biz\shop\classes;
+
+use biz\base\classes\BaseClass;
+
+class ShopCouponClass extends BaseClass
+{
+
+    public static $baseFile = '\biz\shop\models\ShopCoupon';
+
+    const STATUS_UN_USE = 1;
+    const STATUS_USED = 2;
+    const STATUS_EXPIRE = 3;
+
+    public static function groupBaseInfo($list)
+    {
+        return $list;
+    }
+
+}

+ 15 - 0
biz/shop/models/ShopCoupon.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\shop\models;
+
+use biz\base\models\Base;
+
+class ShopCoupon extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhShopCoupon';
+    }
+
+}

+ 24 - 0
biz/shop/services/ShopCouponService.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace biz\shop\services;
+
+use biz\base\services\BaseService;
+use biz\shop\classes\ShopCouponClass;
+
+class ShopCouponService extends BaseService
+{
+
+    public static $baseFile = '\biz\shop\classes\ShopCouponClass';
+
+    public static function getCouponList($where)
+    {
+        $data = ShopCouponClass::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        $data['list'] = ShopCouponClass::groupBaseInfo($list);
+        return $data;
+    }
+
+}

+ 2 - 0
console/controllers/PurchaseController.php

@@ -31,8 +31,10 @@ class PurchaseController extends Controller
                     $id = $purchase['id'] ?? 0;
                     $current = PurchaseClass::getById($id, true);
                     PurchaseService::expire($current);
+
                     $log = "过期的采购单:{$id} json:" . json_encode($purchase);
                     $arr[] = $log;
+
                 }
             }
             $transaction->commit();

+ 1 - 0
sql.sql

@@ -2503,6 +2503,7 @@ ALTER TABLE xhShop ADD cgUnSend INT NOT NULL DEFAULT 0 COMMENT '采购待配送
 ALTER TABLE xhShop ADD cgSending INT NOT NULL DEFAULT 0 COMMENT '采购配送中订单数' AFTER `cgUnSend`;
 ALTER TABLE xhShop ADD cgFinish INT NOT NULL DEFAULT 0 COMMENT '采购完成订单数' AFTER `cgSending`;
 ALTER TABLE xhShop ADD cgCancel INT NOT NULL DEFAULT 0 COMMENT '采购取消订单数' AFTER `cgFinish`;
+ALTER TABLE xhShopCoupon MODIFY `status` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '状态 1未使用 2使用 3过期';
 
 -----linqh 2021.5.14  监控ws定时任务
 */1 * * * * sh /root/new_monitor_shell/ws_monitor.sh >> /dev/null 2>&1