Pārlūkot izejas kodu

修改促销活动订单

jun 5 mēneši atpakaļ
vecāks
revīzija
1eb2e285d1

+ 4 - 2
app/Console/Commands/Regiment.php

@@ -64,7 +64,7 @@ class Regiment extends Command
             $activeList =  $activeList->toArray();
             $activeList =  array_column($activeList,null,'id');
             $activeIds  =   array_column($activeList,'id');
-            $regiment   =   RegimentModel::query()->where('status','=',1)->whereIn('active_id',$activeIds)->get()->toArray();
+            $regiment   =   RegimentModel::query()->where('status','=',0)->whereIn('active_id',$activeIds)->get()->toArray();
             if ($regiment){
                 foreach ($regiment as $v){
                         //虚拟成团
@@ -74,7 +74,7 @@ class Regiment extends Command
                            if ($regimentRecordList){
                                $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                                //修改订单
-                               $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>2,'update_time'=>$time]);
+                               $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>1,'update_time'=>$time]);
                                if (!$res)   Log::error('run_regiment','修改订单失败');
                            }
                            //修改状态
@@ -91,11 +91,13 @@ class Regiment extends Command
                                $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                                //修改订单
                                $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
+                               if (!$res)   Log::error('run_regiment','修改团记录失败');
                            }
                        }
                 }
             }
             $res    =   $Model->query()->whereIn('id',$activeIds)->update(['status'=>2,'update_time'=>$time]);
+            if (!$res)   Log::error('run_regiment','修改团活动失败');
         }
 
         //团过期

+ 3 - 5
app/Http/Controllers/Admin/CustomScore.php

@@ -5,7 +5,6 @@ use App\Models\Custom;
 use App\Models\CustomScore as Model;
 use Illuminate\Support\Facades\DB;
 use App\Models\FilesManager;
-use App\Models\WeiBan\External as WeiBanExternal;
 
 /**
  * 客户管理
@@ -143,7 +142,7 @@ class CustomScore extends Auth{
 	 * 表格导入
 	 * 
 	 * */
-	public function import_weiban( Request $request,Model $Model,Custom $Custom,FilesManager $FilesManager,WeiBanExternal $WeiBanExternal){
+	public function import_weiban( Request $request,Model $Model,Custom $Custom,FilesManager $FilesManager){
 		// 验证参数
 		$request->scene('import_execl')->validate();
 		// 获取表格信息
@@ -152,8 +151,8 @@ class CustomScore extends Auth{
 		$sheetList							= $FilesManager->weibanToScore($file);
 		// 如果不存在结果
 		if( isset($sheetList['error']) )	return json_send(['code'=>'error','msg'=>$sheetList['error']]);
-		// 通过微伴ID查询用户ID
-		$uidList							= $WeiBanExternal->query()->whereIn('id',array_column($sheetList,'weiban_extid'))->pluck('custom_uid','id')->toArray();
+        // 通过微伴ID查询用户ID
+        $uidList							= $Custom->query()->whereIn('weiban_extid',array_column($sheetList,'weiban_extid'))->pluck('uid as custom_uid','weiban_extid')->toArray();
 		// 未知用户
 		$noUsers							= [];
 		// 循环列表
@@ -162,7 +161,6 @@ class CustomScore extends Auth{
 			if( empty($uidList[$value['weiban_extid']]) )   {
 				// 判断
 				$noUsers[]					= $value['weiban_extid'];
-				$noUsers[]					= $value['weiban_extid'];
 				unset($sheetList[$key]);
 				continue;
 			}

+ 2 - 3
app/Http/Controllers/Api/Orders.php

@@ -173,7 +173,6 @@ class Orders extends Api{
         $promoList					    = $PromoProduct->getRebatePrice(array_column($buyList,'product_id'),$uid,$productPrice,$cityId,$tags);
         $promoProductPrice				= $promoList['product_price'];
         $promoRebateProduct				= $promoList['rebate_product'];
-        $promoReductionTotal			= $promoList['reduction_total'];
 		// 组合订单数据
 		foreach ($orderProduct as $key => $order) {
 			// 判断哪一家的赠品
@@ -195,7 +194,7 @@ class Orders extends Api{
                 // 循环赠品
                 foreach ( $promoRebateProduct[$order['business_id']] as $value) {
                     // 没有对应的产品
-                    if( !isset($productList[$value['product_id']]) )  $productList[$value['product_id']] = ['id'=>$value['id'],'stock'=>$value['stock']];
+                    if( !isset($productList[$value['product_id']]) )  $productList[$value['product_id']] = ['id'=>$value['product_id'],'stock'=>$value['stock']];
                     // 判断库存,如果库存不足,只赠送最后的库存
                     if( $productList[$value['product_id']]['stock'] <= $value['buy_num'] )  $value['buy_num'] = $productList[$value['product_id']]['stock'];
                     // 库存扣减
@@ -275,7 +274,7 @@ class Orders extends Api{
 				unset($order['product_list']);
 				// 创建总订单
 				$orderId				= $Model->add($order);
-				// 如果订单写入失败	
+				// 如果订单写入失败
 				if( !$orderId )			{
 					// 回退数据
 					DB::rollBack();

+ 14 - 10
app/Http/Controllers/Api/Product.php

@@ -108,19 +108,20 @@ class Product extends Api{
             if ($promoList && $cityId){
                 if (isset($promoList[$value['id']])){
                     $promoInfo          =   $promoList[$value['id']];
-                    $promoTitle         =   "满". $promoInfo['std_pay']. "元";
+                    $promoTitle             =   '';
                     if ($promoInfo['rebate_type'] == 1){
-                        $promoTitle     .=  "减". $promoInfo['rebate']. "元";
+                        $promoTitle     =  "减";
                     }elseif ($promoInfo['rebate_type'] == 2){
-                        $promoTitle     .=  "打". $promoInfo['rebate']. "折";
+                        $promoTitle     .=  "折";
                     }elseif ($promoInfo['rebate_type'] == 3){
-                        $rebate 	= (string) PromoRebate::query()->join('product','promo_rebate.product_id','=','product.id')->where([['promo_id','=',$promoInfo['id']]])->value('product.name');
-
-                        $promoTitle     .=  "赠送". $rebate;
+                        $promoTitle     .=  "满赠";
+                    }
+                    $promoInfoCity      =   [];
+                    if ($promoInfo['city_ids']){
+                        $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
                     }
-                    $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
                     // 判断是不是可以参与
-                    if (in_array($cityId,$promoInfoCity)){
+                    if (!$promoInfoCity || in_array($cityId,$promoInfoCity)){
                         if( $promoInfo['tag_scope']) {
                             // 解析数组
                             $promoInfo['tag_scope']	= explode(',',$promoInfo['tag_scope']);
@@ -290,9 +291,12 @@ class Product extends Api{
 
                 $promoTitle     .=  "赠送". $rebate;
             }
-            $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+            $promoInfoCity      =   [];
+            if ($promoInfo['city_ids']){
+                $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+            }
             // 判断是不是可以参与
-            if (in_array($cityId,$promoInfoCity)){
+            if (!$promoInfoCity || in_array($cityId,$promoInfoCity)){
                 if( $promoInfo['tag_scope']) {
                     // 解析数组
                     $promoInfo['tag_scope']	= explode(',',$promoInfo['tag_scope']);

+ 11 - 4
app/Http/Controllers/Api/ShopCart.php

@@ -157,9 +157,12 @@ class ShopCart extends Api{
 
                         $promoTitle     .=  "赠送". $rebate;
                     }
-                    $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+                    $promoInfoCity      =   [];
+                    if ($promoInfo['city_ids']){
+                        $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+                    }
                     // 判断是不是可以参与
-                    if (in_array($cityId,$promoInfoCity)){
+                    if (!$promoInfoCity || in_array($cityId,$promoInfoCity)){
                         if( $promoInfo['tag_scope']) {
                             // 解析数组
                             $promoInfo['tag_scope']	= explode(',',$promoInfo['tag_scope']);
@@ -279,9 +282,12 @@ class ShopCart extends Api{
 
                         $promoTitle     .=  "赠送". $rebate;
                     }
-                    $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+                    $promoInfoCity      =   [];
+                    if ($promoInfo['city_ids']){
+                        $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+                    }
                     // 判断是不是可以参与
-                    if (in_array($cityId,$promoInfoCity)){
+                    if (!$promoInfoCity || in_array($cityId,$promoInfoCity)){
                         if( $promoInfo['tag_scope']) {
                             // 解析数组
                             $promoInfo['tag_scope']	= explode(',',$promoInfo['tag_scope']);
@@ -356,6 +362,7 @@ class ShopCart extends Api{
                 }
             }
         }
+        $discount = number_format($discount,2);
 		// 重组数组
 		$list						= array_values($list);
 		// 返回结果

+ 5 - 2
app/Models/PromoProduct.php

@@ -127,10 +127,13 @@ class PromoProduct extends Model
         $promoList							= $this->getListByIds($productIds);
         $promoProductList   =   [];
         foreach ($promoList as $promoInfo) {
-            $promoInfoCity = explode(',', $promoInfo['city_ids']);
+            $promoInfoCity      =   [];
+            if ($promoInfo['city_ids']){
+                $promoInfoCity      =   explode(',',$promoInfo['city_ids']);
+            }
             $promoInfo['price_total']      =   $productPrice[$promoInfo['product_id']]['price_total'];
             // 判断是不是可以参与
-            if (in_array($cityId, $promoInfoCity)) {
+            if (!$promoInfoCity || in_array($cityId, $promoInfoCity)) {
                 if ($promoInfo['tag_scope']) {
                     // 解析数组
                     $promoInfo['tag_scope'] = explode(',', $promoInfo['tag_scope']);

+ 2 - 2
resources/views/admin/regiment/index.blade.php

@@ -68,10 +68,10 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 									拼团中
 								@endif
 								@if( $a['status'] == 2 )
-										拼团失败
+										拼团成功
 								@endif
 								@if( $a['status'] == 3 )
-										拼团成功
+										拼团失败
 								@endif
 							</td>
 							<td>{{date('Y/m/d H:i:s',$a['start_time'])}}</td>