Browse Source

改成单价等问题

shish 4 years ago
parent
commit
3b31b93075

+ 1 - 0
app-ghs/controllers/AuthController.php

@@ -205,6 +205,7 @@ class AuthController extends PublicController
             }
             $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
             $curl = new curl\Curl();
+            $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
             $result = $curl->get($url);
             $arr = Json::decode($result);
             $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';

+ 13 - 3
app-ghs/controllers/OrderController.php

@@ -21,6 +21,7 @@ use common\components\httpUtil;
 use Yii;
 use common\components\util;
 use bizGhs\order\classes\RefundOrderClass;
+use biz\shop\classes\ShopAdminClass;
 
 class OrderController extends BaseController
 {
@@ -54,7 +55,7 @@ class OrderController extends BaseController
         $name = $get['name'] ?? '';
         if (!empty($name)) {
             $searchType = $get['searchType'] ?? 0;
-            if(empty($searchType)){
+            if (empty($searchType)) {
                 //订单编号
                 if (strpos($name, 'XSD') === 0) {
                     $where['orderSn'] = $name;
@@ -63,9 +64,9 @@ class OrderController extends BaseController
                 } else {
                     $where['customName'] = ['like', $name];
                 }
-            }elseif($searchType == 1){
+            } elseif ($searchType == 1) {
                 $where['sendNum'] = $name;
-            }else{
+            } else {
 
             }
         }
@@ -391,6 +392,15 @@ class OrderController extends BaseController
         }
         $info['hasCloudPrint'] = $hasCloudPrint;
 
+        //店长信息
+        $customShopId = $info['customShopId'] ?? 0;
+        $superInfo = ShopAdminClass::getSuper($customShopId);
+        $info['customSuper'] = $superInfo;
+
+        $purchaseId = $info['purchaseId'] ?? 0;
+        $cg = PurchaseClass::getById($purchaseId);
+        $info['cgInfo'] = $cg;
+
         util::success($info);
     }
 

+ 0 - 7
app-ghs/controllers/PurchaseOrderController.php

@@ -48,8 +48,6 @@ class PurchaseOrderController extends BaseController
         $post['ghsInfo'] = json_encode($ghsInfo);
 
         //判断花材里的信息
-        //判定重量
-        $weight = 0;
         foreach ($ghsItemInfo as $v) {
             $bigNum = $v['bigNum'] ?? 0;
             $productId = $v['productId'] ?? 0;
@@ -63,11 +61,6 @@ class PurchaseOrderController extends BaseController
             if ($bigNum <= 0 && $smallNum <= 0) {
                 util::fail('花材数量不能为0');
             }
-            $currentWeight = $v['weight'] ?? 0;
-            $weight = bcadd($weight, $currentWeight, 2);
-        }
-        if ($weight <= 0) {
-            util::fail('请填写重量');
         }
         $post['itemInfo'] = $ghsItemInfo;
         $post['debt'] = PurchaseOrderClass::DEBT_YES;

+ 1 - 0
app-hd/controllers/AuthController.php

@@ -204,6 +204,7 @@ class AuthController extends PublicController
             }
             $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
             $curl = new curl\Curl();
+            $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
             $result = $curl->get($url);
             $arr = Json::decode($result);
             $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';

+ 1 - 0
app-mall/controllers/AuthController.php

@@ -145,6 +145,7 @@ class AuthController extends PublicController
         }
         $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
         $curl = new curl\Curl();
+        $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
         $result = $curl->get($url);
         $arr = Json::decode($result);
         $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';

+ 5 - 4
biz-ghs/order/classes/OrderClass.php

@@ -535,11 +535,11 @@ class OrderClass extends BaseClass
             $showItem = true;
 
             //退款需要显示原有的花材结构,不考虑小菊的显示问题
-            $getOriginalItem = Yii::$app->request->get('getOriginalItem',0);
-            $getOriginalItem2 = Yii::$app->request->post('getOriginalItem',0);
-            if($getOriginalItem == 1 || $getOriginalItem2 ==1){
+            $getOriginalItem = Yii::$app->request->get('getOriginalItem', 0);
+            $getOriginalItem2 = Yii::$app->request->post('getOriginalItem', 0);
+            if ($getOriginalItem == 1 || $getOriginalItem2 == 1) {
                 $showItem = self::getOriginalShowItem($showItem, $val);
-            }else{
+            } else {
                 $showItem = self::getShowItem($showItem, $val);
             }
 
@@ -575,6 +575,7 @@ class OrderClass extends BaseClass
             $list[$key]['printData'] = json_encode($printData);
 
             $list[$key]['debtAmount'] = $debtAmount;
+            $list[$key]['customShopId'] = $customInfoList[$customId]['shopId'] ?? 0;
         }
         return $list;
     }

+ 46 - 74
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -13,6 +13,7 @@ use bizGhs\order\traits\OrderTrait;
 use bizGhs\stock\services\StockRecordService;
 use bizGhs\product\classes\ProductClass;
 use common\components\dict;
+use common\components\imgUtil;
 use common\components\orderSn;
 use common\components\util;
 use Yii;
@@ -52,30 +53,39 @@ class PurchaseOrderClass extends BaseClass
         $data['status'] = self::PURCHASE_ORDER_STATUS_COMPLETE;
         $orderSn = orderSn::getGhsPurchaseSn();
         $data['orderSn'] = $orderSn;
-        //数据结构 [{itemId:0,bigNum:0,smallNum:0,productId:1.0,itemPrice:1,weight:1}]
+        //数据结构 [{itemId:0,bigNum:0,smallNum:0,productId:12,itemPrice:1,weight:1}]
         $ghsItemInfo = $data['itemInfo'];
         $ghsItemInfo = self::mergeItemInfo($ghsItemInfo);
-        //计算出总共多少扎,多少支
-        $bigNum = 0; //总共多少扎
-        $smallNum = 0; //总共多少支
+        //总共多少扎
+        $bigNum = 0;
+        //总共多少支
+        $smallNum = 0;
         $totalItemPrice = 0;
-        //花材中总重量
         $totalWeight = 0;
         $ghsItemInfoMap = [];
-        if (!empty($ghsItemInfo)) {
-            foreach ($ghsItemInfo as $v) {
-                $bigNum += $v['bigNum'] ?? 0;
-                $smallNum += $v['smallNum'] ?? 0;
-                $totalItemPrice = bcadd($totalItemPrice, $v['itemPrice'], 2);
-                $ghsItemInfoMap[$v['productId']] = $v;
-                if (getenv('YII_ENV') == 'production') {
-                    $weight = $v['weight'] ?? 0;
-                } else {
-                    $weight = $v['weight'] ?? 0;
-                }
-                $totalWeight = bcadd($totalWeight, $weight, 2);
+
+        $productIds = array_column($ghsItemInfo, 'productId');
+        $productIds = array_unique(array_filter($productIds));
+        $productList = ProductClass::getByIds($productIds, null, 'id');
+
+        foreach ($ghsItemInfo as $v) {
+            if (isset($v['bigNum']) == false || $v['bigNum'] <= 0) {
+                util::fail('请填写数量');
             }
+            if (isset($v['itemPrice']) == false || $v['itemPrice'] <= 0) {
+                util::fail('请填写价格');
+            }
+            $bigNum += $v['bigNum'] ?? 0;
+            $smallNum += $v['smallNum'] ?? 0;
+            $currentTotalPrice = bcmul($v['bigNum'], $v['itemPrice'], 2);
+            $totalItemPrice = bcadd($totalItemPrice, $currentTotalPrice, 2);
+            $ghsItemInfoMap[$v['productId']] = $v;
+            $currentProductId = $v['productId'] ?? 0;
+            $currentWeight = $productList[$currentProductId]['weight'] ?? 0;
+            $weight = bcmul($currentWeight, $v['bigNum'], 2);
+            $totalWeight = bcadd($totalWeight, $weight, 2);
         }
+
         $data['bigNum'] = $bigNum;
         $data['smallNum'] = $smallNum;
         $data['price'] = $totalItemPrice;
@@ -99,7 +109,6 @@ class PurchaseOrderClass extends BaseClass
 
         //提货费和本地运费
         $paidPrice = bcadd($localCharge, $pickCharge, 2);
-
         $yfPayWay = $data['yfPayWay'] ?? self::YF_PAY_WAY_JF;
         //打包费
         $currentPrice = bcadd($totalItemPrice, $packingCharge, 2);
@@ -126,9 +135,7 @@ class PurchaseOrderClass extends BaseClass
                 $currentPrice = $modifyPrice;
             }
         }
-        //实付款
         $data['actPrice'] = $currentPrice;
-        //实付款,扣除平台补贴
         $data['realPrice'] = $currentPrice;
         $data['paidPrice'] = $paidPrice;
 
@@ -150,12 +157,10 @@ class PurchaseOrderClass extends BaseClass
             $data['cgStyle'] = dict::getDict('cgStyle', 'ghs');
             $order = self::add($data);
 
-            //采购支出
-
             //组装详情表数据
             $batchData = self::groupOrderItem($ghsItemInfo, $orderSn);
 
-            //现在暂时点击确定,完成 加库存
+            //加库存
             foreach ($batchData as $currentKey => $v) {
                 $itemId = $v['itemId'];
                 $productId = $v['productId'];
@@ -173,31 +178,24 @@ class PurchaseOrderClass extends BaseClass
                 //加库存
                 ProductClass::addStockByItemNum($productId, $v['itemNum']);
 
-                //单位采购价=总的采购价/扎数
-                $unitCgPrice = 0;
-                if ($v['itemNum'] > 0) {
-                    $unitCgPrice = bcdiv($v['itemPrice'], $v['itemNum'], 2);
-                }
-                //2021-06-11 修改每扎运费计算
-                $itemInfoTmp = json_decode($v['itemInfo'], true);
-                //花材的重量
-                $productWeight = $itemInfoTmp['itemWeight'] ?? 0;
+                //单位采购价
+                $unitCgPrice = $v['itemPrice'] ?? 0;
+                $productWeight = $productList[$productId]['weight'] ?? 0;
                 $unitFreight = bcmul($avgKgWeight, $productWeight, 2);
                 $unitCost = bcadd($unitCgPrice, $unitFreight, 2);
-                //2021.6.21 成本价改为四舍五入取整数
+                //成本价四舍五入取整数
                 $unitCost = round($unitCost);
-
-                $batchData[$currentKey]['bigPrice'] = $unitCgPrice;
                 $batchData[$currentKey]['bigFreight'] = $unitFreight;
 
-                //采购之后全部变成自动调价
+                $currentCover = $productList[$productId]['cover'] ?? '';
+                $currentName = $productList[$productId]['name'] ?? '';
+                $batchData[$currentKey]['cover'] = $currentCover;
+                $batchData[$currentKey]['name'] = $currentName;
+
                 $product = ProductClass::getLockById($productId);
                 $product->cost = $unitCost;
                 $product->priceLabel = ProductClass::PRICE_LABEL_AUTO;
                 $product->save();
-
-                //触发自动调价 2021.4.26 linqh
-                //ProductClass::autoPriceById($productId);
             }
 
             //写入详情表
@@ -316,19 +314,12 @@ class PurchaseOrderClass extends BaseClass
             util::fail('订单不存在');
         }
         $orderInfo = PurchaseOrderItemClass::getOrderItemDetail($orderSn);
-        $itemData = [];
         if ($orderInfo) {
-            foreach ($orderInfo as $v) {
-                $info = json_decode($v['itemInfo'], true);
-                $tmp = $info;
-                $tmp['itemCover'] = self::groupImg($info['itemCover']);
-                unset($v['itemInfo']);
-                //兼容 旧数据,没有 rank (花材等级 默认给B)
-                if (!isset($tmp['rank'])) {
-                    $tmp['rank'] = 'B';
-                }
-                $tmp = array_merge($tmp, $v);
-                $itemData[] = $tmp;
+            foreach ($orderInfo as $key => $val) {
+                $shortCover = $val['cover'] ?? '';
+                $orderInfo[$key]['ShortCover'] = $shortCover;
+                $orderInfo[$key]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+                $orderInfo[$key]['bigCover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";;
             }
         }
         $orderData = self::groupAdmin($orderData);
@@ -340,7 +331,7 @@ class PurchaseOrderClass extends BaseClass
         $orderData['supplierMobile'] = $ghsInfo['mobile'] ?? '';
         $orderData['supplierAddress'] = $ghsInfo['address'] ?? '';
         $orderData['debtAmount'] = $ghsInfo['debtAmount'] ?? 0;
-        $orderData['itemInfo'] = $itemData;
+        $orderData['itemInfo'] = $orderInfo;
         $orderData['statusName'] = self::getStatusName($orderData['status']);
 
         return $orderData;
@@ -350,37 +341,18 @@ class PurchaseOrderClass extends BaseClass
     public static function groupOrderItem($ghsItemInfo, $orderSn)
     {
         $productData = self::getProductMapData($ghsItemInfo);
-        //写入详情表
         $batchData = [];
         foreach ($ghsItemInfo as $v) {
             $tmp = [];
             $productId = $v['productId'];
             $itemId = $productData[$productId]['itemId'];
-            $rank = $productData[$productId]['rank'] ?? 'B';// 花材级别
             $tmp['orderSn'] = $orderSn;
             $tmp['itemId'] = $itemId;
             $tmp['productId'] = $v['productId'];
-            $ratio = $productData[$productId]['ratio'] ?? 0;
             $tmp['itemStock'] = $productData[$productId]['stock'] ?? 0;//当时库存
-            $tmp['itemNum'] = ProductClass::mergeItemNum($v['bigNum'], $v['smallNum'], $ratio);// 采购数量
-            $tmp['itemPrice'] = $v['itemPrice']; //采购价格
-            $stockFormat = ProductClass::formatStock($tmp['itemStock'], $ratio); // 库存总单位数量转大小单位的数量
-            $itemInfo = [
-                'itemName' => $productData[$productId]['name'] ?? '',//花材名称
-                'itemCover' => $productData[$productId]['cover'] ?? '',//花材图片
-                'bigNum' => $v['bigNum'] ?? 0,//采购数量(大单位)
-                'smallNum' => $v['smallNum'] ?? 0,//采购数量(小单位)
-                'bigNumStock' => $stockFormat['bigNum'],// 当时库存大单位数
-                'smallNumStock' => $stockFormat['smallNum'],//当时库存 小单位数
-                'itemUnit' => $ratio ? 2 : 1,//单位
-                'ratio' => $ratio,// 比例
-                'rank' => $rank,// 花材级别
-                'bigUnit' => $productData[$productId]['bigUnit'],//大单位名称 扎
-                'smallUnit' => $productData[$productId]['smallUnit'],//小单位名称 支
-                'purchaseWeight' => $v['weight'] ?? 0, //采购重量
-                'itemWeight' => $productData[$productId]['weight'] ?? 0,
-            ];
-            $tmp['itemInfo'] = json_encode($itemInfo);
+            $tmp['itemNum'] = $v['bigNum'];
+            $tmp['bigPrice'] = $v['itemPrice'];
+            $tmp['totalPrice'] = bcmul($v['itemPrice'], $tmp['itemNum'], 2);
             $batchData[] = $tmp;
         }
         return $batchData;

+ 1 - 1
biz-ghs/order/services/OrderService.php

@@ -63,7 +63,7 @@ class OrderService extends BaseService
         $sendType = $data['sendType'] ?? OrderClass::SEND_TYPE_MYSELF;
         $getType = $sendType == OrderClass::SEND_TYPE_NO ? PurchaseClass::GET_TYPE_SELF_GET : PurchaseClass::GET_TYPE_SEND;
 
-        //零售采购单时没有传price字段,供应商下单时会传,供应商价格是可以修改的,改成userPrice以便后面使用
+        //零售采购单时没有传price字段,供应商可以改价会传price字段,这里转成userPrice以便采购单识别使用改的价还是花材原价!
         $currentProduct = $data['product'];
         foreach ($currentProduct as $currentKey => $currentItem) {
             if (isset($currentProduct[$currentKey]['price'])) {

+ 7 - 16
biz-ghs/product/classes/ProductClass.php

@@ -605,30 +605,20 @@ class ProductClass extends BaseClass
                 $itemPrice = $discountPrice;
             }
 
-            $userPrice = 0; //用户传的价格
+            //供应商开单可以传单价过来
             if (isset($v['price'])) {
-                if ($v['price'] <= 0) {
-                    util::fail('花材价格不能小于0');
+                if (is_numeric($v['price']) == false || $v['price'] <= 0) {
+                    util::fail('价格不能小于0');
                 }
-                $userPrice = $v['price'];
-                //用户传价格之后,单价会变化
-                $itemPrice = bcdiv($userPrice, $itemNum, 2);
+                $itemPrice = $v['price'];
             }
 
-            //合计价格
             $price = bcmul($itemNum, $itemPrice, 2);
             $tmp = [];
             $tmp['productId'] = $productId;
             $tmp['price'] = $price;
-            if (!empty($userPrice)) {
-                $tmp['price'] = $userPrice;
-            }
 
-            if ($userPrice > 0) {
-                $totalPrice = bcadd($totalPrice, $userPrice, 2);
-            } else {
-                $totalPrice = bcadd($totalPrice, $price, 2);
-            }
+            $totalPrice = bcadd($totalPrice, $price, 2);
 
             $tmp['name'] = $productData[$productId]['name'] ?? '';
             $tmp['smallUnit'] = $productData[$productId]['smallUnit'] ?? '支';
@@ -642,7 +632,7 @@ class ProductClass extends BaseClass
             $tmp['num'] = $itemNum;
             $tmp['bigNum'] = $v['bigNum'];
             $tmp['smallNum'] = $v['smallNum'];
-            $tmp['userPrice'] = $userPrice;
+            $tmp['userPrice'] = $price;
 
             //小单位单价
             $smallUnitPrice = bcdiv($itemPrice, $tmp['ratio'], 2);
@@ -653,6 +643,7 @@ class ProductClass extends BaseClass
 
             $data[] = $tmp;
         }
+
         return ['product' => $data, 'smallNum' => $totalSmallNum, 'bigNum' => $totalBigNum, 'price' => $totalPrice];
     }
 

+ 80 - 85
biz-hd/admin/classes/ShopAdminClass.php

@@ -9,89 +9,84 @@ use bizHd\base\classes\BaseClass;
 
 class ShopAdminClass extends BaseClass
 {
-	
-	public static $baseFile = '\bizHd\admin\models\ShopAdmin';
-	
-	const GENERATE_ADMIN_DATA = 'generate_admin_data_';//创建管理员需要的数据
-	
-	//创建管理准备数据key ssh 2020.4.17
-	public static function getGenerateAdminDataKey($shopId, $adminId)
-	{
-		return self::GENERATE_ADMIN_DATA . $shopId . '_' . $adminId;
-	}
-	
-	//创建管理员数据准备 ssh 2020.4.17
-	public static function prepareBindAdmin($data)
-	{
-		$adminId = $data['adminId'];
-		$shopId = $data['shopId'];
-		$cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
-		$params = [$cacheKey];
-		if (!empty($data)) {
-			foreach ($data as $key => $val) {
-				if (!is_array($val)) {
-					$params[] = $key;
-					$params[] = $val;
-				}
-			}
-		}
-		Yii::$app->redis->executeCommand('HMSET', $params);
-	}
-	
-	//获取创建管理员需要的信息 ssh 2020.4.20
-	public static function getBindAdminData($shopId, $adminId)
-	{
-		$cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
-		$cacheData = Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]);
-		$data = [];
-		if (!empty($cacheData)) {
-			$data = [];
-			$list = [];
-			$x = 0;
-			foreach ($cacheData as $cKey => $cVal) {
-				if ($cKey % 2 == 0) {
-					$list[$x]['key'] = $cVal;
-				} else {
-					$list[$x]['value'] = $cVal;
-					$x++;
-				}
-			}
-			foreach ($list as $lKey => $lVal) {
-				$data[$lVal['key']] = $lVal['value'];
-			}
-		}
-		return $data;
-	}
-	
-	//删除创建管理员需要的信息 ssh 2020.4.20
-	public static function delBindAdminData($shopId, $adminId)
-	{
-		$cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
-		$keyNameList = Yii::$app->redis->executeCommand('HKEYS', [$cacheKey]);
-		if (!empty($keyNameList)) {
-			$data = array_merge([$cacheKey], $keyNameList);
-			$cacheData = Yii::$app->redis->executeCommand('HDEL', $data);
-		}
-	}
-	
-	//取店长 ssh 2021.1.8
-	public static function getManager($shopId)
-	{
-		$relate = self::getByCondition(['shopId' => $shopId]);
-		$adminId = isset($relate['adminId']) ? $relate['adminId'] : 0;
-		$info = [];
-		if (!empty($adminId)) {
-			$info = AdminClass::getById($adminId);
-		}
-		return $info;
-	}
-	
-	public static function valid($adminInfo, $sjId)
-	{
-		if (isset($adminInfo['sjId']) && $adminInfo['sjId'] == $sjId) {
-			return true;
-		}
-		util::fail('此员工您没有权限操作');
-	}
-	
+
+    public static $baseFile = '\bizHd\admin\models\ShopAdmin';
+
+    const GENERATE_ADMIN_DATA = 'generate_admin_data_';//创建管理员需要的数据
+
+    //创建管理准备数据key ssh 2020.4.17
+    public static function getGenerateAdminDataKey($shopId, $adminId)
+    {
+        return self::GENERATE_ADMIN_DATA . $shopId . '_' . $adminId;
+    }
+
+    //创建管理员数据准备 ssh 2020.4.17
+    public static function prepareBindAdmin($data)
+    {
+        $adminId = $data['adminId'];
+        $shopId = $data['shopId'];
+        $cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
+        $params = [$cacheKey];
+        if (!empty($data)) {
+            foreach ($data as $key => $val) {
+                if (!is_array($val)) {
+                    $params[] = $key;
+                    $params[] = $val;
+                }
+            }
+        }
+        Yii::$app->redis->executeCommand('HMSET', $params);
+    }
+
+    //获取创建管理员需要的信息 ssh 2020.4.20
+    public static function getBindAdminData($shopId, $adminId)
+    {
+        $cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
+        $cacheData = Yii::$app->redis->executeCommand('HGETALL', [$cacheKey]);
+        $data = [];
+        if (!empty($cacheData)) {
+            $data = [];
+            $list = [];
+            $x = 0;
+            foreach ($cacheData as $cKey => $cVal) {
+                if ($cKey % 2 == 0) {
+                    $list[$x]['key'] = $cVal;
+                } else {
+                    $list[$x]['value'] = $cVal;
+                    $x++;
+                }
+            }
+            foreach ($list as $lKey => $lVal) {
+                $data[$lVal['key']] = $lVal['value'];
+            }
+        }
+        return $data;
+    }
+
+    //删除创建管理员需要的信息 ssh 2020.4.20
+    public static function delBindAdminData($shopId, $adminId)
+    {
+        $cacheKey = self::getGenerateAdminDataKey($shopId, $adminId);
+        $keyNameList = Yii::$app->redis->executeCommand('HKEYS', [$cacheKey]);
+        if (!empty($keyNameList)) {
+            $data = array_merge([$cacheKey], $keyNameList);
+            $cacheData = Yii::$app->redis->executeCommand('HDEL', $data);
+        }
+    }
+
+    //取店长 ssh 2021.1.8
+    public static function getManager($shopId)
+    {
+        $info = \biz\shop\classes\ShopAdminClass::getSuper($shopId);
+        return $info;
+    }
+
+    public static function valid($adminInfo, $sjId)
+    {
+        if (isset($adminInfo['sjId']) && $adminInfo['sjId'] == $sjId) {
+            return true;
+        }
+        util::fail('此员工您没有权限操作');
+    }
+
 }

+ 4 - 7
biz-hd/purchase/classes/PurchaseClass.php

@@ -99,14 +99,13 @@ class PurchaseClass extends BaseClass
                 $price = $discountPrice;
             }
 
-            //每个花材总价(原价
+            //花材原价
             $productPrePrice = bcmul($itemNum, $price, 2); //采购总价
-            //供应商开单的每个花材总价,可能会改价
             $productTotalPrice = $productPrePrice;
+            //花材改价
             if (isset($product['userPrice']) && $product['userPrice'] > 0) {
-                $productTotalPrice = $product['userPrice'];
-                //改价之后的单价 shish 20210830
-                $price = bcdiv($productTotalPrice, $itemNum, 2);
+                $price = $product['userPrice'];
+                $productTotalPrice = bcmul($itemNum, $price, 2);
             }
 
             $itemInfo = [
@@ -133,12 +132,10 @@ class PurchaseClass extends BaseClass
             $productList[$key]['preTotalPrice'] = $productPrePrice;
             $productList[$key]['productId'] = $hdProductId;
             $productList[$key]['ghsProductId'] = $productId;
-            //小单位单价
             $smallPrice = bcdiv($price, $ratio, 2);
             $productList[$key]['smallPrice'] = $smallPrice;
 
             $prePrice = bcadd($prePrice, $productTotalPrice, 2);
-
         }
 
         $data['itemPrice'] = $prePrice;

+ 1 - 2
common/components/miniUtil.php

@@ -1607,14 +1607,13 @@ class miniUtil
             $data = ['component_appid' => $appId, 'component_appsecret' => $appSecret, 'component_verify_ticket' => $verifyTicket];
             $url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
             $curl = new curl\Curl();
+            $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
             $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
             if (empty($result)) {
                 util::stop('没有取到ComponentAccessToken');
             }
             $result = Json::decode($result);
             if (isset($result['component_access_token']) == false || empty($result['component_access_token'])) {
-                echo '<pre>';
-                print_r($result);
                 Yii::info('get component access token error:' . json_encode($result));
                 Yii::$app->end();
             }

+ 2 - 0
common/components/wxUtil.php

@@ -626,6 +626,7 @@ class wxUtil
             $url = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token={$componentAccessToken}";
             $data = ['component_appid' => $component_app_id, 'authorizer_appid' => $appId, 'authorizer_refresh_token' => $authorize_refresh_token];
             $curl = new curl\Curl();
+            $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
             $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
 
             Yii::info('通过refresh_token获取access_token返回:' . $result);
@@ -1618,6 +1619,7 @@ class wxUtil
             $data = ['component_appid' => $appId, 'component_appsecret' => $appSecret, 'component_verify_ticket' => $verifyTicket];
             $url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
             $curl = new curl\Curl();
+            $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
             $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
             if (empty($result)) {
                 util::stop('没有取到ComponentAccessToken');