| 
									
										
										
										
											2021-12-02 18:34:44 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\traits\account; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use app\model\BusinessFlow; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | trait BusinessFlowTrait | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 获取关注的商家列表 | 
					
						
							|  |  |  |      * @param $accountCode | 
					
						
							|  |  |  |      * @param $page | 
					
						
							|  |  |  |      * @param $size | 
					
						
							|  |  |  |      * @return | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getBusinessFlowList($accountCode, $page, $size) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return BusinessFlow::alias("a") | 
					
						
							|  |  |  |             ->join("business b","a.business_code = b.code") | 
					
						
							|  |  |  |             ->where("a.user_code",$accountCode) | 
					
						
							|  |  |  |             ->field(["b.code", | 
					
						
							|  |  |  |                 "b.business_name", | 
					
						
							|  |  |  |                 "b.business_subtitle", | 
					
						
							|  |  |  |                 "b.lat", | 
					
						
							|  |  |  |                 "b.lng", | 
					
						
							|  |  |  |                 "b.characteristic", | 
					
						
							|  |  |  |                 "b.background", | 
					
						
							|  |  |  |             ]) | 
					
						
							|  |  |  |             ->page($page,$size) | 
					
						
							|  |  |  |             ->select(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-06 18:56:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 获取关注的商家的code | 
					
						
							|  |  |  |      * @param $accountCode | 
					
						
							|  |  |  |      * @return array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function getBusinessFlowCodeArray($accountCode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return BusinessFlow::where("user_code",$accountCode) | 
					
						
							|  |  |  |             ->column("business_code"); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 获取关注的商家的code | 
					
						
							|  |  |  |      * @param $accountCode | 
					
						
							|  |  |  |      * @param $businessCode | 
					
						
							|  |  |  |      * @return BusinessFlow|array|\think\Model|null | 
					
						
							|  |  |  |      * @throws \think\db\exception\DataNotFoundException | 
					
						
							|  |  |  |      * @throws \think\db\exception\DbException | 
					
						
							|  |  |  |      * @throws \think\db\exception\ModelNotFoundException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function hasBusinessFlow($accountCode,$businessCode) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return BusinessFlow::where("user_code",$accountCode) | 
					
						
							|  |  |  |             ->where("business_code",$businessCode) | 
					
						
							|  |  |  |             ->find(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * 关注一个商家 | 
					
						
							|  |  |  |      * @param $accountCode | 
					
						
							|  |  |  |      * @param $businessCode | 
					
						
							|  |  |  |      * @param $businessName | 
					
						
							|  |  |  |      * @return BusinessFlow|\think\Model | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function createBusinessFlow($accountCode,$businessCode,$businessName) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return BusinessFlow::create([ | 
					
						
							|  |  |  |             "user_code"=>$accountCode, | 
					
						
							|  |  |  |             "business_code"=>$businessCode, | 
					
						
							|  |  |  |             "business_name"=>$businessName, | 
					
						
							|  |  |  |             "create_time"=>date("Y-m-d H:i:s") | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |