Sfoglia il codice sorgente

【Mod】代码接口优化以及地址提示优化

liuxiangxin 4 mesi fa
parent
commit
b6d1e4e809

+ 10 - 3
app/Http/Controllers/Api/Custom.php

@@ -61,7 +61,9 @@ class Custom extends Api{
 		// 如果没有关联企微,获取二维码,已关联的不验证
 		$followQrcode					= $custom['weiban_extid'] ?  ['thumb'=>'','link_url'=>''] : $WeiBanQrcode->getFollowQrcode($custom['city_id']);
 		// 城市ID换城市名
-		$cityId							= (string) $City->getOne($custom['city_id'],'name');
+		$cityName						= (string) $City->getOne($custom['city_id'],'name');
+		$pid 							= (int) $City->getOne($custom['city_id'],'pid');
+		$province						= (string)($pid ? $City->getOne($pid,'name') : '');
 		// 所需数组组合
 		$custom							= [
 											'uid'=>$custom['uid'],
@@ -70,8 +72,13 @@ class Custom extends Api{
 											'phone'=>$custom['phone'],
 											'is_manager'=>$custom['is_manager'],
 											'company_id'=>1, // 无需验证资质
-											'show_price'=>$cityId?1:0, // 是否选择了城市处理
-											'city_id'=>$cityId,
+											'show_price'=>$cityName?1:0, // 是否选择了城市处理
+											'city_id'=>$cityName,
+											'city_info'=>[
+												'city_id'=>$custom['city_id'],
+												'city_name'=>$cityName,
+												'province_name'=>$province,
+											],
 											'follow_qrcode'=>$followQrcode['thumb'],
 											'follow_linkurl'=>$followQrcode['link_url'],
 										];

+ 2 - 2
app/Http/Controllers/Api/CustomAddr.php

@@ -62,7 +62,7 @@ class CustomAddr extends Api{
 		$pid 							= $City->getOne($cityId,'pid');
 		$province						= $City->getOne($pid,'name');
 		// 判断选择的城市名称是不是一致
-		if( trim($cityName) != trim($data['contact_city']) ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.$province.'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
+		if( trim($cityName) != trim($data['contact_city']) ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.($province=='直辖县级'?$cityName:$province).'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
 		// 替换地址中间的空格
 		$data['contact_addr']			= str_ireplace(' ','',$data['contact_addr']);
 		// 最大数量
@@ -111,7 +111,7 @@ class CustomAddr extends Api{
 		$pid 							= $City->getOne($cityId,'pid');
 		$province						= $City->getOne($pid,'name');
 		// 判断选择的城市名称是不是一致
-		if( trim($cityName) != trim($data['contact_city']) ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.$province.'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
+		if( trim($cityName) != trim($data['contact_city']) ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.($province=='直辖县级'?$cityName:$province).'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
 		// 替换地址中间的空格
 		$data['contact_addr']			= str_ireplace(' ','',$data['contact_addr']);
 		// 如果需要默认当前的话

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

@@ -69,7 +69,7 @@ class Orders extends Api{
 		$pid 							= $City->getOne($cityId,'pid');
 		$province						= $City->getOne($pid,'name');
 		// 判断选择的城市名称是不是一致
-		if( trim($cityName) != trim($addr['contact_city']) ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.$province.'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
+		if( trim($cityName) != trim($addr['contact_city']) ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.($province=='直辖县级'?$cityName:$province).'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
         // 商品购买数量
 		$buyNum							= [];
 		// 循环购买信息
@@ -987,7 +987,7 @@ class Orders extends Api{
 	 * @pamam   int		$id      订单ID
 	 * 
 	 * */ 
-	public function get_detail( Request $request, Model $Model,OrdersProduct $OrdersProduct,OrdersAddr $OrdersAddr){
+	public function get_detail( Request $request, Model $Model,OrdersProduct $OrdersProduct,Business $Business,OrdersAddr $OrdersAddr){
 		// 验证参数
 		$request->scene('get_detail')->validate();
 		// 接受参数
@@ -999,10 +999,16 @@ class Orders extends Api{
 		// 数据转换
 		$order					= $order->toArray();
 		// id转编号
+		$order['insert_time']	= date('Y-m-d H:i:s',$order['insert_time']);
+		$order['business_name']	= (string) $Business->getOne($order['business_id'],'name');
 		$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();
+		// 处理缩略图
+		foreach ($order['order_items'] as $key => $value) {
+			$order['order_items'][$key]['product_thumb']	= $value['product_thumb'] ? path_compat($value['product_thumb'])  : '';
+		}
 		// 地址
 		$order['order_addr']	= $OrdersAddr->query()->where([['order_id','=',$id]])->first(['contact_name','contact_phone','contact_province','contact_city','contact_area','contact_addr','contact_shop']);
 		// 加载模板