Explorar o código

Merge branch 'liuxiangxin' into jun

jun hai 4 meses
pai
achega
86531c0203

+ 1 - 1
app/Console/Commands/CouponNotice.php

@@ -62,7 +62,7 @@ class CouponNotice extends Command
         // 组合数据
         $phoneList          = implode(',',$phoneList);
         // 给这些手机号发送一条阿里云短信
-        $result             = Sms::sendSms($phoneList,'开邻智数','SMS_478125029');
+        $result             = $phoneList ? Sms::sendSms($phoneList,'开邻智数','SMS_478125029') : [];
         // 返回结果
         return              $result;
 	}

+ 71 - 0
app/Console/Commands/OrdersNotice.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use App\Facades\Servers\Aliyun\Sms;
+use App\Models\OrdersProduct as Model;
+
+class OrdersNotice extends Command
+{
+    /**
+     * 任务名称
+     *
+     * @var string
+     */
+    protected $signature = 'orders_notice';
+
+    /**
+     * 任务描述
+     *
+     * @var string
+     */
+    protected $description = '订单处理通知';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+		// 执行任务
+        $this->run_task();
+		return 0;
+    }
+
+    /**
+	 * 执行任务
+	 * 
+	 * */
+	public function run_task(){
+        // 实例化模型
+        $Model              = new Model();
+        // 获取三天后到期的优惠券->addDays(3)
+        $phoneList          = $Model->query()
+                            ->join('business','orders_product.business_id','=','business.id')
+                            ->join('admin','business.leader_uid','=','admin.uid')
+                            ->whereIn('orders_product.status',['1','2','3','8','9'])
+                            ->groupBy('admin.phone')
+                            ->limit(1000)
+                            ->pluck('admin.phone')
+                            ->toArray();
+        // 组合数据
+        $phoneList          = implode(',',$phoneList);
+        // 给这些手机号发送一条阿里云短信
+        $result             = $phoneList ? Sms::sendSms($phoneList,'开邻智数','SMS_478160083') : [];
+        // 返回结果
+        return              $result;
+	}
+
+}

+ 2 - 0
app/Console/Kernel.php

@@ -36,6 +36,8 @@ class Kernel extends ConsoleKernel
         $schedule->command('regiment')->everyMinute();
         // 优惠券提醒
         $schedule->command('coupon_notice')->dailyAt('15:00');
+        // 优惠券提醒
+        $schedule->command('orders_notice')->dailyAt('07:00');
     }
 
     /**

+ 66 - 62
app/Http/Controllers/Admin/AdminUser.php

@@ -22,7 +22,7 @@ class AdminUser extends Auth{
 	 * 列表页
 	 * 
 	 * */
-    public function index(Model $Model,AdminRule $AdminRule){
+    public function index(Model $Model){
         $mp                     =   [];
         $session                = session('userRule');
         if ($session){
@@ -35,8 +35,9 @@ class AdminUser extends Auth{
             $mp['admin_rule.type']       = 1;
         }
  		// 查询系统用户
-		$list					= $Model::query()->join('admin_rule','admin_rule.admin_uid','=','admin.uid')
-                                ->where($mp)
+		$list					= $Model::query();
+		if($mp) 				$list->join('admin_rule','admin_rule.admin_uid','=','admin.uid');
+        $list					= $list->where($mp)
                                 ->orderByDesc('admin.uid')
                                 ->paginate(config('page_num',10));
 		// 循环处理
@@ -95,68 +96,63 @@ class AdminUser extends Auth{
 			// 验证参数
 			$request->scene('add')->validate();
 			// 接收数据
-			$data['username']		= request('username','');
-			$data['phone']			= request('phone','');
-			$data['password']		= request('password','');
-			$data['password']		= md5($data['password']);
-            $data_type		        = request('data_type','');
-            $ruleData               = [];
-            if ($data_type){
-                $ruleData['data_type']    = $data_type;
-            }
-            $session                = session('userRule');
-            if ($session){
-                $ruleData['company_id']     = $session['company_id'];
-                if ($session['business_id']){
-                    $ruleData['business_id']    = $session['business_id'];
-                }
-            }
+			$data['username']					= request('username','');
+			$data['phone']						= request('phone','');
+			$data['password']					= request('password','');
+			$data['password']					= md5($data['password']);
+            $dataType		        			= request('data_type',1);
+			// 角色数据
+            $ruleData               			= ['menu_type'=>1,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
+			// 当前登录用户角色数据
+            $session							= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
+			// 修改数据
+			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
+			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
+			if( $session['business_id'] ) 		$ruleData['business_id'] = $session['business_id'];
 			// 所属权限组
-			$groups					= (array) request('groups',[]);
+			$groups								= (array) request('groups',[]);
 			// 开启事务
 			DB::beginTransaction();
 			// 写入数据表
-			$uid					= $Model->add($data);
+			$uid								= $Model->add($data);
 			// 如果操作失败
 			if( !$uid ) {
 				// 回滚事务
-    			DB::rollBack();
+				DB::rollBack();
 				// 告知错误
-				return				json_send(['code'=>'error','msg'=>'新增失败']);
+				return							json_send(['code'=>'error','msg'=>'新增失败']);
 			}
 			// 权限组
-			$access					= [];
+			$access								= [];
 			// 循环数据
 			foreach ( $groups as $group_id) {
 				// 追加数据
-				$access[]			= ['group_id'=>$group_id,'user_uid'=>$uid];
+				$access[]						= ['group_id'=>$group_id,'user_uid'=>$uid];
 			}
 			// 写入用户权限组
-			$result					= DB::table('auth_group_access')->insert($access);
+			$result								= DB::table('auth_group_access')->insert($access);
 			// 如果操作失败
 			if( !$result ) {
 				// 回滚事务
-    			DB::rollBack();
+				DB::rollBack();
 				// 告知错误
-				return				json_send(['code'=>'error','msg'=>'权限分配失败']);
+				return							json_send(['code'=>'error','msg'=>'权限分配失败']);
+			}
+			//写入用户角色表
+			$ruleData['admin_uid']      		= $uid;
+			$ruleUid							= $AdminRule->add($ruleData);
+			// 如果操作失败
+			if( !$ruleUid ){
+				// 回滚事务
+				DB::rollBack();
+				return 							json_send(['code'=>'error','msg'=>'新增管理员角色失败']);
 			}
-            //写入用户角色表
-            $ruleData['admin_uid']      =   $uid;
-            $ruleData['type']           =   1;
-            $ruleData['menu_type']      =   $session['menu_type'];
-            $ruleUid					=   $AdminRule->add($ruleData);
-            // 如果操作失败
-            if( !$ruleUid ){
-                // 回滚事务
-                DB::rollBack();
-                return json_send(['code'=>'error','msg'=>'新增管理员角色失败']);
-            }
 			// 提交事务
-    		DB::commit();
+			DB::commit();
 			// 记录行为
 			$this->addAdminHistory(admin('uid'),$Model->getTable(),$uid,1,[],$data);
 			// 告知结果
-			return					json_send(['code'=>'success','msg'=>'新增成功','action'=>'add']);
+			return								json_send(['code'=>'success','msg'=>'新增成功','action'=>'add']);
 		}
 		$whereGroup = [];
 		// 如果不是超管 查询当前用户所属组
@@ -190,30 +186,40 @@ class AdminUser extends Auth{
 	 * */
 	public function edit(Request $request,Model $Model,AdminRule $AdminRule){
 		// 接收参数
-		$uid						= request('uid',0);
+		$uid									= request('uid',0);
 		// 查询用户
-		$oldData					= $Model->where(['uid'=>$uid])->first();
+		$oldData								= $Model->where(['uid'=>$uid])->first();
 		if(request()->isMethod('post')){
 			// 验证参数
 			$request->scene('edit')->validate();
 			// 接收数据
-			$data['username']		= request('username','');
-			$data['phone']			= request('phone','');
-			$data_type			    = request('data_type','');
+			$data['username']					= request('username','');
+			$data['phone']						= request('phone','');
+			$dataType			    			= request('data_type',1);
+			// 角色数据
+            $ruleData               			= $AdminRule::query()->where([['admin_uid','=',$uid]])->first(['id','admin_uid','menu_type','data_type','type','company_id','business_id']);
+			// 如果不存在的话
+			$ruleData							= $ruleData ? $ruleData->toArray() : ['admin_uid'=>$uid,'menu_type'=>1,'data_type'=>$dataType,'type'=>1,'company_id'=>1,'business_id'=>0];
+			// 当前登录用户角色数据
+			$session							= session('userRule') ? session('userRule') : ['menu_type'=>0,'company_id'=>0,'business_id'=>0];
+			// 修改数据
+			if( $session['menu_type'] ) 		$ruleData['menu_type'] = $session['menu_type'];
+			if( $session['company_id'] ) 		$ruleData['company_id'] = $session['company_id'];
+			if( $session['business_id'] ) 		$ruleData['business_id'] = $session['business_id'];
 			// 密码
-			$password				= request('password','');
+			$password							= request('password','');
 			// 所属权限组
-			$groups					= (array) request('groups',[]);
+			$groups								= (array) request('groups',[]);
 			// 如果用户不存在
-			if( !$oldData )			return json_send(['code'=>'error','msg'=>'用户不存在']);
+			if( !$oldData )						return json_send(['code'=>'error','msg'=>'用户不存在']);
 			// 不能修改超管的账号
 			if( $oldData['username'] == config('administrator') )	return json_send(['code'=>'error','msg'=>'这是被禁止的操作']);
 			// 如果要修密码
-			if( $password ) 		$data['password'] = md5($password);
+			if( $password ) 					$data['password'] = md5($password);
 			// 开启事务
 			DB::beginTransaction();
 			// 写入数据表
-			$result					= $Model->edit($uid,$data);
+			$result								= $Model->edit($uid,$data);
 			// 如果操作失败
 			if( !$result ) {
 				// 回滚事务
@@ -239,17 +245,15 @@ class AdminUser extends Auth{
 				// 告知错误
 				return				json_send(['code'=>'error','msg'=>'权限分配失败']);
 			}
-            if ($data_type){
-                // 写入数据表
-                $result					= $AdminRule::query()->where('admin_uid','=',$uid)->update(['data_type'=>$data_type]);
-                // 如果操作失败
-                if( !$result ) {
-                    // 回滚事务
-                    DB::rollBack();
-                    // 告知错误
-                    return				json_send(['code'=>'error','msg'=>'新增失败']);
-                }
-            }
+			// 写入数据表
+			$result					= empty($ruleData['id']) ? $AdminRule->add($ruleData) : $AdminRule->edit($ruleData['id'],$ruleData);
+			// 如果操作失败
+			if( !$result ) {
+				// 回滚事务
+				DB::rollBack();
+				// 告知错误
+				return				json_send(['code'=>'error','msg'=>'修改失败']);
+			}
 			// 提交事务
     		DB::commit();
 			// 记录行为

+ 8 - 22
app/Http/Controllers/Admin/Orders.php

@@ -76,27 +76,23 @@ class Orders extends Auth{
 		if( $startTime )		$map[] = ['orders_product.insert_time','>=',strtotime($startTime)];
 		if( $endTime )			$map[] = ['orders_product.insert_time','<=',strtotime($endTime)];
 		if( $status )			$map[] = ['orders_product.status','=',$status];
-        if( $businessId )		$map[] = ['orders_product.business_id','=',$id];
+        if( $businessId )		$map[] = ['orders_product.business_id','=',$businessId];
         if($is_regiment){
             if( $is_regiment == 1)		$map[] = ['orders.regiment_id','>',0];
             if( $is_regiment == 2)		$map[] = ['orders.regiment_id','=',0];
         }
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['orders_product.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['orders_product.business_id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $shopIds       = $Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
-            }
-        }
+		// 当前登录的角色数据
+        $session                = session('userRule') ? session('userRule') : ['business_id'=>0,'menu_type'=>0,'data_type'=>0];
+		// 是否存在对应的商业公司ID
+       	if ( $session['business_id'] ) $map[] = ['orders_product.business_id','=',$session['business_id']];
+		// 数据类型
+		$shopIds				= ($session['menu_type'] == 1 && $session['data_type'] == 2)  ? Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray() : [];
 		// 查询数据
 		$list					= $OrdersProduct->query()
 									->join('custom','orders_product.custom_uid','=','custom.uid')
 									->join('orders_addr','orders_addr.order_id','=','orders_product.order_id')
 									->leftJoin('orders','orders.id','=','orders_product.order_id');
-        if (isset($shopIds))    $list   =   $list->whereIn('orders_product.business_id',$shopIds);
+        if ( $shopIds )    		$list =   $list->whereIn('orders_product.business_id',$shopIds);
         $list                   = $list->where($map)
 									->orderByDesc('id')
 									->select([
@@ -415,16 +411,6 @@ class Orders extends Auth{
 		if( $startTime )		$map[] = ['orders_product.insert_time','>=',strtotime($startTime)];
 		if( $endTime )			$map[] = ['orders_product.insert_time','<=',strtotime($endTime)];
 		if( $status )			$map[] = ['orders_product.status','=',$status];
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['orders_product.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['orders_product.business_id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $shopIds       = $Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
-            }
-        }
 		// 查询数据
 		$list					= $OrdersProduct->query()
 									->join('custom','orders_product.custom_uid','=','custom.uid')

+ 9 - 19
app/Http/Controllers/Admin/Product.php

@@ -50,8 +50,6 @@ class Product extends Auth{
 		$id						= $code ? $Model->codeToId($code) : 0;
 		// 查询条件
 		$map 					= [];
-		// 是否有城市
-		$whereIn				= $cityIds ? $cityIds : [];
 		// 编码ID
 		if( $id )				$map[] = ['product.id','=',$id];
 		if( $businessId )		$map[] = ['product.business_id','=',$businessId];
@@ -59,20 +57,16 @@ class Product extends Auth{
 		if( $startTime )		$map[] = ['product.insert_time','>=',Carbon::createFromFormat('Y-m-d',$startTime)->startOfDay()->getTimestamp()];
 		if( $startTime )		$map[] = ['product.insert_time','<=',Carbon::createFromFormat('Y-m-d',$startTime)->endOfDay()->getTimestamp()];
 		if( !is_null($status) )	$map[] = ['product.status','=',$status];
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['product.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['product.business_id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
-            }
-        }
+		// 当前登录的角色数据
+        $session                = session('userRule') ? session('userRule') : ['business_id'=>0,'menu_type'=>0,'data_type'=>0];
+		// 是否存在对应的商业公司ID
+       	if ( $session['business_id'] ) $map[] = ['product.business_id','=',$session['business_id']];
+		// 数据类型
+		$shopIds				= ($session['menu_type'] == 1 && $session['data_type'] == 2)  ? Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray() : [];
 		// 查询数据
-		$list					= $Model->query();
-		if( $whereIn )			$list = $list->join('product_city','product_city.product_id','=','product.id')->whereIn('product_city.city_id',$whereIn);
-        if(isset($shopIds))		$list = $list->whereIn('product.business_id',$shopIds);
+		$list					= $Model->query()->join('product_city','product_city.product_id','=','product.id');
+		if( $cityIds )			$list = $list->whereIn('product_city.city_id',$cityIds);
+        if( $shopIds )			$list = $list->whereIn('product.business_id',$shopIds);
         $list 					= $list->groupBy('product.id')
 								->where($map)
 								->orderBy('product.sort')
@@ -255,10 +249,6 @@ class Product extends Auth{
 			$data['tag_scope']		= implode(',',$tagScope);
 			$tagExclude				= request('tag_exclude',[]);
 			$data['tag_exclude']	= implode(',',$tagExclude);
-            $session                = session('userRule');
-            if ($session){
-                $data['company_id']	        = $session['company_id'];
-            }
 			// 循环
 			foreach ($photoList as $key => $value) {
 				if( !$value )		unset($photoList[$key]);

+ 8 - 11
app/Http/Controllers/Admin/Regiment.php

@@ -52,16 +52,13 @@ class Regiment extends Auth{
             $end_time         =   strtotime($end_time);
             $map[] = ['regiment.end_time','<=',$end_time];
         }
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['regiment_active.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['regiment_active.business_id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
-            }
-        }
+        // 当前登录的角色数据
+        $session                = session('userRule') ? session('userRule') : ['business_id'=>0,'menu_type'=>0,'data_type'=>0];
+		// 是否存在对应的商业公司ID
+       	if ( $session['business_id'] ) $map[] = ['regiment_active.business_id','=',$session['business_id']];
+		// 数据类型
+		$shopIds				= ($session['menu_type'] == 1 && $session['data_type'] == 2)  ? Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray() : [];
+		
         $select = [
             'regiment.*',
             'regiment_active.name as active_name',
@@ -74,7 +71,7 @@ class Regiment extends Auth{
             ->join('regiment_active','regiment_active.id','=','regiment.active_id')
             ->join('product','product.id','=','regiment.product_id')
             ->leftJoin('custom','custom.uid','=','regiment.custom_uid');
-        if (isset($shopIds)){
+        if ( $shopIds ){
             $list               = $list->whereIn('regiment_active.business_id',$shopIds);
         }
         $list                   =  $list->where($map)

+ 8 - 11
app/Http/Controllers/Admin/RegimentActive.php

@@ -52,20 +52,17 @@ class RegimentActive extends Auth{
             $end_time         =   strtotime($end_time);
             $map[] = ['regiment_active.end_time','<=',$end_time];
         }
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['regiment_active.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['regiment_active.business_id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
-            }
-        }
+        // 当前登录的角色数据
+        $session                = session('userRule') ? session('userRule') : ['business_id'=>0,'menu_type'=>0,'data_type'=>0];
+		// 是否存在对应的商业公司ID
+       	if ( $session['business_id'] ) $map[] = ['regiment_active.business_id','=',$session['business_id']];
+		// 数据类型
+		$shopIds				= ($session['menu_type'] == 1 && $session['data_type'] == 2)  ? Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray() : [];
+		
         // 查询数据
         $list					= $Model->query()
                                 ->join('product','product.id','=','regiment_active.product_id');
-        if (isset($shopIds))    $list->whereIn('regiment_active.business_id',$shopIds);
+        if ( $shopIds )         $list->whereIn('regiment_active.business_id',$shopIds);
         $list					= $list->where($map)
                                 ->select(['regiment_active.*','product.name as product_name'])
                                 ->orderByDesc('regiment_active.id')

+ 7 - 10
app/Http/Controllers/Admin/RegimentRecord.php

@@ -58,16 +58,13 @@ class RegimentRecord extends Auth{
             $end_time         =   strtotime($end_time);
             $map[] = ['regiment_record.insert_time','<=',$end_time];
         }
-        $session                = session('userRule');
-        if ($session){
-            $map[] = ['regiment_active.company_id','=',$session['company_id']];
-            if ($session['business_id']){
-                $map[] = ['regiment_active.business_id','=',$session['business_id']];
-            }
-            if ($session['menu_type'] == 1 && $session['data_type'] == 2){
-                $shopIds       =  Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray();
-            }
-        }
+        // 当前登录的角色数据
+        $session                = session('userRule') ? session('userRule') : ['business_id'=>0,'menu_type'=>0,'data_type'=>0];
+		// 是否存在对应的商业公司ID
+       	if ( $session['business_id'] ) $map[] = ['regiment_active.business_id','=',$session['business_id']];
+		// 数据类型
+		$shopIds				= ($session['menu_type'] == 1 && $session['data_type'] == 2)  ? Business::query()->where('leader_uid',$session['admin_uid'])->pluck('id')->toArray() : [];
+		
         $select = [
             'regiment_record.*',
             'regiment.status as regiment_status',

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

@@ -598,7 +598,7 @@ class Orders extends Api{
      * 创建拼团订单						 	/api/orders/create_regiment
      *
      * */
-    public function create_regiment(Request $request,Custom $Custom,City $City,Model $Model,WeiBanTags $WeiBanTags,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,CustomAddr $CustomAddr,CustomScore $CustomScore){
+    public function create_regiment(Request $request,Custom $Custom,City $City,Model $Model,WeiBanTags $WeiBanTags,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,CustomAddr $CustomAddr,CustomScore $CustomScore){
         // 接口验签
         // $this->verify_sign();
         // 验证参数
@@ -902,7 +902,7 @@ class Orders extends Api{
      * 取消拼团				/api/orders/cancel_regiment
      *
      * */
-    public function cancel_regiment( Request $request, Model $Model,OrdersProduct $OrdersProduct,CustomScore $CustomScore){
+    public function cancel_regiment( Request $request, Model $Model,OrdersProduct $OrdersProduct){
         // 验证参数
         $request->scene('cancel')->validate();
         // 检查登录
@@ -980,4 +980,33 @@ class Orders extends Api{
             return			json_send(['code'=>'error','msg'=>'取消失败','data'=>['error'=>$th->getMessage().$th->getLine()]]);
         }
     }
+
+	/**
+	 * 订单详情
+	 * 
+	 * @pamam   int		$id      订单ID
+	 * 
+	 * */ 
+	public function get_detail( Request $request, Model $Model,OrdersProduct $OrdersProduct,OrdersAddr $OrdersAddr){
+		// 验证参数
+		$request->scene('get_detail')->validate();
+		// 接受参数
+		$id						= request('id',0);
+		// 查询数据
+		$order					= $Model->query()->find($id,['id','pay_total','status','price_total','coupon_total','business_id','pay_total','weizan_orderid','insert_time']);
+		// 查询不到订单
+		if( !$order	)			return json_send(['code'=>'error','msg'=>'订单不存在']);
+		// 数据转换
+		$order					= $order->toArray();
+		// id转编号
+		$order['order_code']	= $Model->idToCode($order['id']);
+		$order['state']			= $Model->getState($order['status'],'state');
+		// 查询子订单数据
+		$order['order_items']	= $OrdersProduct->query()->where([['order_id','=',$id]])->select(['id as item_id','order_id','product_id','buy_num','pay_total','is_rebate','sku_attr_names as product_spec','product_name','product_thumb'])->get()->toArray();
+		// 地址
+		$order['order_addr']	= $OrdersAddr->query()->where([['order_id','=',$id]])->first(['contact_name','contact_phone','contact_province','contact_city','contact_area','contact_addr','contact_shop']);
+		// 加载模板
+		return					json_send(['code'=>'success','msg'=>'获取成功','data'=>$order]);
+	}
+
 }

+ 31 - 17
app/Http/Controllers/Api/ShopCart.php

@@ -2,6 +2,7 @@
 
 use App\Http\Controllers\Api\Api;
 use App\Http\Requests\Api\ShopCart as Request;
+use App\Models\Business;
 use App\Models\Product\Skus as ProductSkus;
 use App\Models\PromoRebate;
 use App\Models\ShopCart as Model;
@@ -101,7 +102,7 @@ class ShopCart extends Api{
 	 * @param	int     $id		        购物车id
 	 * 
 	 * */
-	public function get_list(Request $request,Model $Model,ProductSkus $ProductSkus,PromoProduct $PromoProduct,Custom $Custom,WeiBanTags $WeiBanTags){
+	public function get_list(Request $request,Model $Model,ProductSkus $ProductSkus,Business $Business,PromoProduct $PromoProduct,Custom $Custom,WeiBanTags $WeiBanTags){
 		// 接口验签
 		// $this->verify_sign();
         // 验证参数
@@ -113,20 +114,26 @@ class ShopCart extends Api{
 		// 显示
 		$map						= [['shop_cart.custom_uid','=',$uid]];
 		// 查询
-		$list						= $Model->query()->join('product','shop_cart.product_id','=','product.id')->where($map)->get(['shop_cart.id','shop_cart.checked','shop_cart.product_id','shop_cart.skuid','shop_cart.buy_num','product.stock','product.spec','product.thumb','product.name','product.price','product.market_price','product.status as product_status'])->toArray();
+		$list						= $Model->query()
+										->join('product','shop_cart.product_id','=','product.id')
+										->where($map)
+										->get([
+											'shop_cart.id','shop_cart.checked','shop_cart.product_id','shop_cart.skuid','shop_cart.buy_num',
+											'product.stock','product.business_id','product.spec','product.thumb','product.name','product.price','product.market_price','product.status as product_status'
+										])
+										->toArray();
 		// 判断结果
 		$skusList					= $ProductSkus->getListByIds(array_column($list,'skuid'));
         //查询产品活动
         $promoList					= $PromoProduct->getListByIds(array_column($list,'product_id'));
         // 查询用户标签
-        $tags                       =   [];
-        $cityId                     =   '';
-        if ($custom){
-            $tags					= $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
-            $cityId					= $custom['city_id'];
-        }
+        $tags                       = empty($custom['weiban_extid']) ? [] : $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
+		// 用户所在城市
+        $cityId                     = empty($custom['city_id']) ? 0 : $custom['city_id'];
 		// 循环处理数据
 		foreach ($list as $key => $value) {
+			// 获取商业公司名称
+			$value['business_name'] = $value['business_id'] ? $Business->getOne($value['business_id'])['name'] : 0;
 			// 如果有sku
 			if( $value['skuid'] )	{
 				// 是否存在
@@ -144,6 +151,7 @@ class ShopCart extends Api{
 				// 如果不存在,状态变动
 				if( !$isExist )		$value['product_status'] = 4;
 			}
+			// 满减活动
             if ($promoList && $cityId){
                 if (isset($promoList[$value['product_id']])){
                     $promoInfo          =   $promoList[$value['product_id']];
@@ -205,7 +213,7 @@ class ShopCart extends Api{
 	 * @param	int     $id		        购物车id
 	 * 
 	 * */
-	public function check_list(Request $request,Model $Model,ProductSkus $ProductSkus,PromoProduct $PromoProduct,Custom $Custom,WeiBanTags $WeiBanTags){
+	public function check_list(Request $request,Model $Model,ProductSkus $ProductSkus,Business $Business,PromoProduct $PromoProduct,Custom $Custom,WeiBanTags $WeiBanTags){
 		// 接口验签
 		// $this->verify_sign();
         // 验证参数
@@ -228,21 +236,27 @@ class ShopCart extends Api{
 		// 显示
 		$map						= [['shop_cart.custom_uid','=',$uid],['product.status','=',0]];
 		// 查询
-		$list						= $Model->query()->join('product','shop_cart.product_id','=','product.id')->whereIn('shop_cart.id',$cartIds)->where($map)->get(['shop_cart.id','shop_cart.checked','shop_cart.product_id','shop_cart.skuid','shop_cart.buy_num','product.stock','product.spec','product.thumb','product.name','product.price','product.market_price','product.status as product_status'])->toArray();
+		$list						= $Model->query()
+									->join('product','shop_cart.product_id','=','product.id')
+									->whereIn('shop_cart.id',$cartIds)->where($map)
+									->get([
+										'shop_cart.id','shop_cart.checked','shop_cart.product_id','shop_cart.skuid','shop_cart.buy_num',
+										'product.stock','product.business_id','product.spec','product.thumb','product.name','product.price','product.market_price','product.status as product_status'
+									])->toArray();
 		// 判断结果
 		$skusList					= $ProductSkus->getListByIds(array_column($list,'skuid'));
         //查询产品活动
         $promoList					= $PromoProduct->getListByIds(array_column($list,'product_id'));
         // 查询用户标签
-        $tags                       =   [];
-        $cityId                     =   '';
-        if ($custom){
-            $tags					= $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
-            $cityId					= $custom['city_id'];
-        }
-        $promoProductList           =   [];
+        $tags                       = empty($custom['weiban_extid']) ? [] : $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
+		// 用户所在城市
+        $cityId                     = empty($custom['city_id']) ? 0 : $custom['city_id'];
+		// 满减活动
+        $promoProductList           = [];
 		// 循环处理数据
 		foreach ($list as $key => $value) {
+			// 获取商业公司名称
+			$value['business_name'] = $value['business_id'] ? $Business->getOne($value['business_id'])['name'] : 0;
 			// 如果有sku
 			if( $value['skuid'] )	{
 				// 是否存在

+ 1 - 0
app/Http/Requests/Api/Orders.php

@@ -35,6 +35,7 @@ class Orders extends BaseRequest
         'create'                => ['product_list','addr_id'],
         'cancel'                => ['id'],
         'get_item'              => ['id'],
+        'get_detail'            => ['id'],
 	];
 
     /**

+ 0 - 1
app/Servers/Aliyun/Sms.php

@@ -39,7 +39,6 @@ class Sms extends Client{
             $result         = $response['body'];
             // 如果失败的话
             if( $result['Code'] != 'OK' )   return ['code'=>$result['Code'],'error'=>$result['Message'],'request_id'=>$result['RequestId']];
-            dd($result);
             // 返回成功信息
             return          ['code'=>$result['Code'],'message'=>$result['Message'],'requestId'=>$result['RequestId'],'bizId'=>$result['BizId']];
         }catch (\Exception $error) {

+ 29 - 0
app/Servers/WeiBan/OpenApi.php

@@ -236,6 +236,35 @@ class OpenApi
         return                              true;
     }
 
+    /**
+     * 给客户添加企业标签
+     * 
+     */
+    public function addTag($staffId,$extUserid,$tagGroup,$tagName){
+        // 获取调用凭证
+        $accessToken                        = $this->getAccessToken();
+        // 如果没有返回
+        if( !$accessToken )                 return [];
+        // 组装接口
+        $url                                = $this->domain.'/open-api/tag/add?access_token='.$accessToken;
+        $param                              = ['staff_id'=>$staffId,'external_user_id'=>$extUserid,'tag_group'=>$tagGroup,'tag_name'=>$tagName]; 
+        // 调用接口
+        $result                             = Curl::to($url)->withData($param)->asJson(true)->post();
+        // 如果没有返回
+        if( !isset($result['errcode']) )    {
+            Log::error('weiban_openai/tag_add','接口未返回数据',$result);
+            return                          false;
+        }
+        // 如果是凭证错误,递归
+        if( $result['errcode'] == '10001' ) return $this->addTag($staffId,$extUserid,$tagGroup,$tagName);
+        // 如果调用结果失败
+        if( $result['errcode'] != 0 )    {
+            Log::error('weiban_openai/tag_add',$result['errcode'].'=>'.$result['errmsg']);
+            return                          false;
+        }
+        return                              true;
+    }
+
 }
 
 ?>

+ 1 - 1
resources/views/admin/business/add.blade.php

@@ -31,7 +31,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 	</div>
 	<div class="form-group col-sm-5">
 		<label class="control-label">详细地址</label>
-		<input class="form-control" required="required" type="text" placeholder="简介说明" maxlength="255" name="address" value="" />
+		<input class="form-control" required="required" type="text" placeholder="详细地址" maxlength="255" name="address" value="" />
 	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">商业公司介绍</label>

+ 1 - 1
resources/views/admin/business/edit.blade.php

@@ -35,7 +35,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 	</div>
 	<div class="form-group col-sm-5">
 		<label class="control-label">详细地址</label>
-		<input class="form-control" required="required" type="text" placeholder="简介说明" maxlength="255" name="address" value="{{$oldData['address']}}" />
+		<input class="form-control" required="required" type="text" placeholder="详细地址" maxlength="255" name="address" value="{{$oldData['address']}}" />
 	</div>
 	<div class="form-group col-sm-12">
 		<label class="control-label">商业公司介绍</label>

+ 1 - 1
resources/views/admin/orders/index.blade.php

@@ -44,7 +44,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 		<select name="business_id" class="form-control">
 			<option value="" >商业公司</option>
 			@foreach ($businessList as $business)
-				<option value="{{$business['id']}}" @if (request('business_id') === $business['id'] ) selected="selected" @endif >{{$business['name']}}</option>
+				<option value="{{$business['id']}}" @if (request('business_id',0) == $business['id'] ) selected="selected" @endif >{{$business['name']}}</option>
 			@endforeach
 		</select>
 	</div>

+ 1 - 1
resources/views/admin/product/edit.blade.php

@@ -304,7 +304,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 	<div class="form-group col-sm-12">
 		@csrf
 		<input type="hidden" name="id" value="{{$oldData['id']}}" />
-		<input id="send" type="submit" @if( !$oldData['status'] ) disabled="" value="上架产品 仅查看" @else value="提交" @endif  class="btn btn-primary btn-block" />
+		<input id="send" type="submit" @if( !$oldData['status'] || $oldData['status'] == 2 ) disabled="" value="上架产品 仅查看" @else value="提交" @endif  class="btn btn-primary btn-block" />
 	</div>
 </form>
 @endsection

+ 50 - 18
resources/views/admin/product/index.blade.php

@@ -19,7 +19,10 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 		<select name="status" class="form-control">
 			<option value="" >产品状态</option>
 			<option value="0" @if (request('status') === '0' ) selected="selected" @endif >已上架</option>
-			<option value="1" @if (request('status') === '1' ) selected="selected" @endif >已下架</option>
+			<option value="1" @if (request('status') === '1' ) selected="selected" @endif >编辑中</option>
+			<option value="2" @if (request('status') === '2' ) selected="selected" @endif >预上架</option>
+			<option value="3" @if (request('status') === '3' ) selected="selected" @endif >已中止</option>
+			<option value="4" @if (request('status') === '4' ) selected="selected" @endif >已结束</option>
 		</select>
 	</div>
 	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12">
@@ -115,7 +118,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td>
 							@if(check_auth('admin/product/edit'))
 							<a class="btn btn-sm btn-warning" href="{{url('admin/product/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
-								@if ($a['status']) 编辑 @else 查看 @endif
+								@if ( $a['status'] && $a['status'] != 2 ) 编辑 @else 查看 @endif
 							</a>
 							@endif
 							@if(check_auth('admin/product/copy'))
@@ -124,22 +127,51 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							</a>
 							@endif
 							@if(check_auth('admin/product/set_status'))
-								@if ($a['status'])
-									<!-- 判断是不是有上架时间 -->
-									@if ( $a['puton_time'] )
-									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'2']))}}">
-										预上架
-									</a>
-									@else
-									<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
-										上架
-									</a>
-									@endif
-								@else
-									<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'3']))}}">
-										下架
-									</a>
-								@endif
+								@switch($a['status'])
+									@case(0)
+										<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'3']))}}">
+											下架
+										</a>
+									@break
+									@case(1)
+										@if ( $a['puton_time'] )
+										<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'2']))}}">
+											预上架
+										</a>
+										@else
+										<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+											上架
+										</a>
+										@endif
+									@break
+									@case(2)
+										<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'3']))}}">
+											下架
+										</a>
+									@break
+									@case(3)
+										@if ( $a['puton_time'] )
+										<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'2']))}}">
+											预上架
+										</a>
+										@else
+										<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+											上架
+										</a>
+										@endif
+									@break
+									@case(4)
+										@if ( $a['puton_time'] )
+										<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'2']))}}">
+											预上架
+										</a>
+										@else
+										<a class="delete btn btn-sm btn-success" data-url="{{url('admin/product/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+											上架
+										</a>
+										@endif
+									@break
+								@endswitch
 							@endif
 							@if(check_auth('admin/product/get_poster'))
 							<a href="{{url('admin/product/get_poster?'.http_build_query(['id'=>$a['id']]))}}" class="btn btn-sm btn-success" >海报</a>

+ 2 - 0
routes/api.php

@@ -44,6 +44,8 @@ Route::any('orders/get_list',[\App\Http\Controllers\Api\Orders::class,'get_list'
 Route::any('orders/cancel',[\App\Http\Controllers\Api\Orders::class,'cancel']);
 // 获取子订单数据
 Route::any('orders/get_item',[\App\Http\Controllers\Api\Orders::class,'get_item']);
+// 获取订单详情
+Route::any('orders/get_detail',[\App\Http\Controllers\Api\Orders::class,'get_detail']);
 
 // 新增购物车
 Route::any('shop_cart/add',[\App\Http\Controllers\Api\ShopCart::class,'add']);