|
|
@@ -194,8 +194,8 @@ class PurchaseController extends BaseController
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
|
|
|
- $version = $post['version']??0;
|
|
|
- $direct = $post['direct']??0;
|
|
|
+ $version = $post['version'] ?? 0;
|
|
|
+ $direct = $post['direct'] ?? 0;
|
|
|
|
|
|
//多颜色数据整理
|
|
|
$colorItem = $post['xj'] ?? [];
|
|
|
@@ -281,10 +281,10 @@ class PurchaseController extends BaseController
|
|
|
|
|
|
//收集客户要下单的花材数量
|
|
|
$orderNum = [];
|
|
|
- foreach($productList as $key => $product) {
|
|
|
- $bigNum = $product['bigNum']??0;
|
|
|
- $productId = $product['productId']??0;
|
|
|
- $orderNum[$productId] = ['num'=>$bigNum];
|
|
|
+ foreach ($productList as $key => $product) {
|
|
|
+ $bigNum = $product['bigNum'] ?? 0;
|
|
|
+ $productId = $product['productId'] ?? 0;
|
|
|
+ $orderNum[$productId] = ['num' => $bigNum];
|
|
|
}
|
|
|
$lackList = [];
|
|
|
$changeList = [];
|
|
|
@@ -327,15 +327,15 @@ class PurchaseController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($version >= 10){
|
|
|
- $stock = $currentInfo['stock']??0;
|
|
|
+ if ($version >= 10) {
|
|
|
+ $stock = $currentInfo['stock'] ?? 0;
|
|
|
$stock = floatval($stock);
|
|
|
- $productId = $currentInfo['id']??0;
|
|
|
- $productName = $currentInfo['name']??'';
|
|
|
+ $productId = $currentInfo['id'] ?? 0;
|
|
|
+ $productName = $currentInfo['name'] ?? '';
|
|
|
$num = $orderNum[$productId] && $orderNum[$productId]['num'] ? $orderNum[$productId]['num'] : 0;
|
|
|
$num = floatval($num);
|
|
|
- if($num>$stock){
|
|
|
- $lackList[] = ['name'=>$productName,'stock'=>$stock];
|
|
|
+ if ($num > $stock) {
|
|
|
+ $lackList[] = ['name' => $productName, 'stock' => $stock];
|
|
|
$changeList[$productId] = $stock;
|
|
|
}
|
|
|
}
|
|
|
@@ -349,30 +349,30 @@ class PurchaseController extends BaseController
|
|
|
util::fail('预售和非预售花材不能一起下单');
|
|
|
}
|
|
|
|
|
|
- if($version >= 10){
|
|
|
- if($direct == 1){
|
|
|
+ if ($version >= 10) {
|
|
|
+ if ($direct == 1) {
|
|
|
//直接更换库存并提交
|
|
|
$allNoStock = true;
|
|
|
- foreach($productList as $pKey =>$pVal){
|
|
|
- $productId = $pVal['productId']??0;
|
|
|
- if(isset($changeList[$productId])){
|
|
|
+ foreach ($productList as $pKey => $pVal) {
|
|
|
+ $productId = $pVal['productId'] ?? 0;
|
|
|
+ if (isset($changeList[$productId])) {
|
|
|
$changeStock = $changeList[$productId];
|
|
|
$productList[$pKey]['bigNum'] = $changeStock;
|
|
|
}
|
|
|
- if($productList[$pKey]['bigNum']>0){
|
|
|
+ if ($productList[$pKey]['bigNum'] > 0) {
|
|
|
$allNoStock = false;
|
|
|
}
|
|
|
- if($productList[$pKey]['bigNum']<=0){
|
|
|
+ if ($productList[$pKey]['bigNum'] <= 0) {
|
|
|
unset($productList[$pKey]);
|
|
|
}
|
|
|
}
|
|
|
- if($allNoStock){
|
|
|
+ if ($allNoStock) {
|
|
|
util::fail('全部没库存了');
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//前台提示库存不足
|
|
|
- if(!empty($lackList)){
|
|
|
- util::success(['lackList'=>$lackList,'hasLackError'=>1]);
|
|
|
+ if (!empty($lackList)) {
|
|
|
+ util::success(['lackList' => $lackList, 'hasLackError' => 1]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -387,38 +387,38 @@ class PurchaseController extends BaseController
|
|
|
|
|
|
//旭海银柳的临时解决办法
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
- if($ghsShopInfo->mainId == 41121){
|
|
|
- $mer = [1903693,1903712,1903789,1903796,1903816,1903841,1903855,1903859,1903860,1903864];
|
|
|
+ if ($ghsShopInfo->mainId == 41121) {
|
|
|
+ $mer = [1903693, 1903712, 1903789, 1903796, 1903816, 1903841, 1903855, 1903859, 1903860, 1903864];
|
|
|
$getIds = array_column($productList, 'productId');
|
|
|
$hasYl = false;
|
|
|
- foreach($productList as $ylVal){
|
|
|
+ foreach ($productList as $ylVal) {
|
|
|
$ylProductId = $ylVal['productId'];
|
|
|
- if(in_array($ylProductId, $mer)){
|
|
|
+ if (in_array($ylProductId, $mer)) {
|
|
|
$hasYl = true;
|
|
|
}
|
|
|
}
|
|
|
- if($hasYl){
|
|
|
- $myInfoList = ProductClass::getAllByCondition(['id'=>['in',$getIds]],null,'*','id');
|
|
|
- $currentMap = [1903693=>220,1903712=>150,1903789=>100,1903796=>60,1903816=>45,1903841=>80,1903855=>55,1903859=>40,1903860=>25,1903864=>20];
|
|
|
- foreach($productList as $ylKey => $ylValue){
|
|
|
+ if ($hasYl) {
|
|
|
+ $myInfoList = ProductClass::getAllByCondition(['id' => ['in', $getIds]], null, '*', 'id');
|
|
|
+ $currentMap = [1903693 => 220, 1903712 => 150, 1903789 => 100, 1903796 => 60, 1903816 => 45, 1903841 => 80, 1903855 => 55, 1903859 => 40, 1903860 => 25, 1903864 => 20];
|
|
|
+ foreach ($productList as $ylKey => $ylValue) {
|
|
|
$ylProductId = $ylValue['productId'];
|
|
|
- $num = $ylValue['bigNum']??0;
|
|
|
- if(!isset($currentMap[$ylProductId])){
|
|
|
+ $num = $ylValue['bigNum'] ?? 0;
|
|
|
+ if (!isset($currentMap[$ylProductId])) {
|
|
|
util::fail('花材有问题');
|
|
|
}
|
|
|
$mustBeNum = $currentMap[$ylProductId];
|
|
|
- $myInfo = $myInfoList[$ylProductId]??[];
|
|
|
- if(empty($myInfo)){
|
|
|
+ $myInfo = $myInfoList[$ylProductId] ?? [];
|
|
|
+ if (empty($myInfo)) {
|
|
|
util::fail('花材有问题哦');
|
|
|
}
|
|
|
- $myName = $myInfo['name']??'';
|
|
|
- if($num>=$mustBeNum){
|
|
|
- $curVal = $num/$mustBeNum;
|
|
|
- if($curVal != intval($curVal)){
|
|
|
- util::fail($myName.' 要'.$mustBeNum.'捆或'.$mustBeNum.'的倍数');
|
|
|
+ $myName = $myInfo['name'] ?? '';
|
|
|
+ if ($num >= $mustBeNum) {
|
|
|
+ $curVal = $num / $mustBeNum;
|
|
|
+ if ($curVal != intval($curVal)) {
|
|
|
+ util::fail($myName . ' 要' . $mustBeNum . '捆或' . $mustBeNum . '的倍数');
|
|
|
}
|
|
|
- }else{
|
|
|
- util::fail($myName.' 数量要'.$mustBeNum.'捆');
|
|
|
+ } else {
|
|
|
+ util::fail($myName . ' 数量要' . $mustBeNum . '捆');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -659,7 +659,7 @@ class PurchaseController extends BaseController
|
|
|
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
//源花汇不允许客户自己下欠款单
|
|
|
- if($ghs['mainId']== 10536){
|
|
|
+ if ($ghs['mainId'] == 10536) {
|
|
|
util::fail('暂未开通');
|
|
|
}
|
|
|
}
|
|
|
@@ -728,7 +728,7 @@ class PurchaseController extends BaseController
|
|
|
//有几个地方要同步去修改
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
//源花汇、盛丰不自动打小票,关键词mall_order_no_auto_print
|
|
|
- $mallOrderNoPrint = [10536,44282];
|
|
|
+ $mallOrderNoPrint = [10536, 44282];
|
|
|
} else {
|
|
|
$mallOrderNoPrint = [];
|
|
|
}
|
|
|
@@ -1132,7 +1132,9 @@ class PurchaseController extends BaseController
|
|
|
$order->changePrice = 2;
|
|
|
$order->save();
|
|
|
|
|
|
- $name = $orderSn;
|
|
|
+ $ghsShopName = $ghsShop->shopName ?? '';
|
|
|
+ //要带上哪个店的,这样才知道客户下的单是哪个店的,客户很多有多家店
|
|
|
+ $name = "买花 " . $orderSn . "(" . $ghsShopName . ")";
|
|
|
$totalFee = $order->realPrice;
|
|
|
$openId = '';
|
|
|
if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
|