Prechádzať zdrojové kódy

【Add】收货地址增加终端类型

liuxiangxin 4 mesiacov pred
rodič
commit
a1ca37366c

+ 38 - 32
app/Http/Controllers/Admin/Orders.php

@@ -19,6 +19,7 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
 use PhpOffice\PhpSpreadsheet\Style\Fill;
 use Intervention\Image\Facades\Image;
 use Intervention\Image\Gd\Font;
+use App\Models\Custom\Shoptype;
 
 /**
  * 订单管理
@@ -38,7 +39,7 @@ class Orders extends Auth{
 	 * 首页列表
 	 * 
 	 * */
-    public function index(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom){
+    public function index(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom,Shoptype $Shoptype){
 		// 接受参数
 		$code					= request('order_code','');
 		$orders_other			= request('orders_other',0);
@@ -86,7 +87,7 @@ class Orders extends Auth{
 									->orderByDesc('id')
 									->select([
 										'orders_product.*','custom.username as custom_name','orders.regiment_id as regiment_id',
-										'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
+										'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.shop_type','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
 									])
 									->paginate(request('limit',config('page_num',10)))->appends(request()->all());
 		// 循环处理数据
@@ -95,6 +96,7 @@ class Orders extends Auth{
 			$value['order_code']	= $Model->idToCode($value['order_id']);
 			$value['custom_code']	= $Custom->idToCode($value['custom_uid']);
 			$value['state']			= $Model->getState($value['status'],'state');
+			$value['shop_type']		= $Shoptype->getOne($value['shop_type'],'name');
 			$value['product_code']	= $value['product_id'] ? $Product->idToCode($value['product_id']) : '— —';
 			// 重组
 			$list[$key]				= $value;
@@ -362,7 +364,7 @@ class Orders extends Auth{
 	 * 导出表格导入
 	 * 
 	 * */
-	public function down_excel(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom){
+	public function down_excel(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom,Shoptype $Shoptype){
 		// 接受参数
 		$code					= request('order_code','');
 		$productCode			= request('product_code','');
@@ -417,7 +419,7 @@ class Orders extends Auth{
 										'orders_product.status',
 										'orders_product.insert_time',
 										'custom.username as custom_name','custom.weiban_extid as weiban_extid',
-										'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
+										'orders_addr.contact_name','orders_addr.contact_shop','orders_addr.shop_type','orders_addr.contact_phone','orders_addr.contact_province','orders_addr.contact_city','orders_addr.contact_area','orders_addr.contact_addr'
 									])->get()->toArray();
 		// 返回结果
 		$data						= [];
@@ -443,6 +445,7 @@ class Orders extends Auth{
 			$data[$value['order_id']]['contact_city'] = $value['contact_city'];
 			$data[$value['order_id']]['contact_area'] = $value['contact_area'];
 			$data[$value['order_id']]['contact_addr'] = $value['contact_addr'] .($value['contact_shop'] ? '【'.$value['contact_shop'].'】' : '');
+			$data[$value['order_id']]['shop_type'] 	  = $value['shop_type'] ? $Shoptype->getOne($value['shop_type'],'name') : '';
 			// 子订单
 			$data[$value['order_id']]['product'][] 	  = ['product_id'=>$value['product_id'] ? $Product->idToCode($value['product_id']) : '— —','product_name'=>$value['product_name'],'product_spec'=>$value['product_spec'],'product_thumb'=>$value['product_thumb'],'product_price'=>$value['product_price'],'pay_price'=>$value['pay_price'],'buy_num'=>$value['buy_num'],'pay_total'=>$value['pay_total'],'price_total'=>$value['price_total'],'coupon_total'=>$value['coupon_total']];
 		}
@@ -483,16 +486,17 @@ class Orders extends Auth{
 				$sheet->setCellValue('H'.$row, $value['contact_city']);
 				$sheet->setCellValue('I'.$row, $value['contact_area']);
 				$sheet->setCellValue('J'.$row, $value['contact_addr']);
-				$sheet->setCellValue('K'.$row, $v['product_id']);
-				$sheet->setCellValue('L'.$row, $v['product_name']);
-				$sheet->setCellValue('M'.$row, $v['product_spec']);
-				$sheet->setCellValue('N'.$row, $v['product_price']);
-				$sheet->setCellValue('O'.$row, $v['pay_price']);
-				$sheet->setCellValue('P'.$row, $v['buy_num']);
-				$sheet->setCellValue('Q'.$row, $v['coupon_total']);
-				$sheet->setCellValue('R'.$row, $v['pay_total']);
-				$sheet->setCellValue('S'.$row, $value['weiban_extid']);
-				$sheet->setCellValue('T'.$row, date('Y-m-d H:i:s',$value['insert_time']));
+				$sheet->setCellValue('K'.$row, $value['shop_type']);
+				$sheet->setCellValue('L'.$row, $v['product_id']);
+				$sheet->setCellValue('M'.$row, $v['product_name']);
+				$sheet->setCellValue('N'.$row, $v['product_spec']);
+				$sheet->setCellValue('O'.$row, $v['product_price']);
+				$sheet->setCellValue('P'.$row, $v['pay_price']);
+				$sheet->setCellValue('Q'.$row, $v['buy_num']);
+				$sheet->setCellValue('R'.$row, $v['coupon_total']);
+				$sheet->setCellValue('S'.$row, $v['pay_total']);
+				$sheet->setCellValue('T'.$row, $value['weiban_extid']);
+				$sheet->setCellValue('U'.$row, date('Y-m-d H:i:s',$value['insert_time']));
 				// 函数自增
 				$row++;
 			}
@@ -524,22 +528,23 @@ class Orders extends Auth{
 		$sheet->getColumnDimension('H')->setWidth(15);
 		$sheet->getColumnDimension('I')->setWidth(15);
 		$sheet->getColumnDimension('J')->setWidth(50);
-		$sheet->getColumnDimension('K')->setWidth(20);
-		$sheet->getColumnDimension('L')->setWidth(80);
+		$sheet->getColumnDimension('K')->setWidth(15);
+		$sheet->getColumnDimension('L')->setWidth(20);
 		$sheet->getColumnDimension('M')->setWidth(80);
-		$sheet->getColumnDimension('N')->setWidth(10);
+		$sheet->getColumnDimension('N')->setWidth(80);
 		$sheet->getColumnDimension('O')->setWidth(10);
 		$sheet->getColumnDimension('P')->setWidth(10);
 		$sheet->getColumnDimension('Q')->setWidth(10);
 		$sheet->getColumnDimension('R')->setWidth(10);
-		$sheet->getColumnDimension('S')->setWidth(50);
-		$sheet->getColumnDimension('T')->setWidth(20);
+		$sheet->getColumnDimension('S')->setWidth(10);
+		$sheet->getColumnDimension('T')->setWidth(50);
+		$sheet->getColumnDimension('U')->setWidth(20);
 		// 默认高度
 		$sheet->getDefaultRowDimension()->setRowHeight(18);
 		// 加粗第一行
-		$sheet->getStyle('A:T')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
-		$sheet->getStyle('A1:T1')->getFont()->setBold(true);
-		$sheet->getStyle('A1:T1')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF00FF00'); // ARGB颜色代码,例如绿色
+		$sheet->getStyle('A:U')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER);
+		$sheet->getStyle('A1:U1')->getFont()->setBold(true);
+		$sheet->getStyle('A1:U1')->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF00FF00'); // ARGB颜色代码,例如绿色
 		// 设置表格标题
 		$sheet
 		->setCellValue('A1', '订单ID')
@@ -552,16 +557,17 @@ class Orders extends Auth{
 		->setCellValue('H1', '市')
 		->setCellValue('I1', '区县')
 		->setCellValue('J1', '收货地址')
-		->setCellValue('K1', '产品编码')
-		->setCellValue('L1', '产品名称')
-		->setCellValue('M1', '产品规格')
-		->setCellValue('N1', '产品单价')
-		->setCellValue('O1', '折后单价')
-		->setCellValue('P1', '产品数量')
-		->setCellValue('Q1', '优惠金额')
-		->setCellValue('R1', '产品金额')
-		->setCellValue('S1', '微伴ID')
-		->setCellValue('T1', '下单时间');
+		->setCellValue('K1', '终端类型')
+		->setCellValue('L1', '产品编码')
+		->setCellValue('M1', '产品名称')
+		->setCellValue('N1', '产品规格')
+		->setCellValue('O1', '产品单价')
+		->setCellValue('P1', '折后单价')
+		->setCellValue('Q1', '产品数量')
+		->setCellValue('R1', '优惠金额')
+		->setCellValue('S1', '产品金额')
+		->setCellValue('T1', '微伴ID')
+		->setCellValue('U1', '下单时间');
 		// 返回结果
 		return 					$sheet;
 	}

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

@@ -52,6 +52,7 @@ class CustomAddr extends Api{
 		$data['contact_addr']			= trim(request('contact_addr',''));
 		$data['contact_name']			= trim(request('contact_name',''));
 		$data['contact_shop']			= trim(request('contact_shop',''));
+		$data['shop_type']				= trim(request('shop_type',0));
 		$data['contact_phone']			= trim(request('contact_phone',''));
 		$data['is_default']				= request('is_default',0);
 		$data['custom_uid']				= $uid;
@@ -101,6 +102,7 @@ class CustomAddr extends Api{
 		$data['contact_addr']			= trim(request('contact_addr',''));
 		$data['contact_name']			= trim(request('contact_name',''));
 		$data['contact_shop']			= trim(request('contact_shop',''));
+		$data['shop_type']				= trim(request('shop_type',0));
 		$data['contact_phone']			= trim(request('contact_phone',''));
 		$data['is_default']				= request('is_default',0);
 		// 获取客户城市ID

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

@@ -20,7 +20,6 @@ use App\Models\ShopCart;
 use Illuminate\Support\Facades\DB;
 use App\Models\WeiBan\Tags as WeiBanTags;
 use App\Models\PromoProduct as PromoProduct;
-use Monolog\Handler\IFTTTHandler;
 
 /**
  * 订单接口
@@ -57,7 +56,7 @@ class Orders extends Api{
 		// 如果不存在数据
 		if( !$addr )					return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
 		// 重组数据
-		$addr							= ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
+		$addr							= ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'shop_type'=>$addr['shop_type'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
 		// 获取客户城市ID
 		$custom							= $Custom->getOne($uid);
 		// 如果不存在的话
@@ -132,7 +131,7 @@ class Orders extends Api{
 				// 是否在限购时间,当前时间大于开始时间,并且小于结束时间
 				if( $productInfo['quota_start'] <= $time && $time <= $productInfo['quota_end'] ){
 					// 通过时间查询商品的购买总数
-					$total 				= $OrdersProduct->query()->where([['custom_uid','=',$uid],['product_id','=',$productInfo['id']],['insert_time','>=',$productInfo['quota_start']],['insert_time','<=',$productInfo['quota_end']]])->sum('buy_num');
+					$total 				= $OrdersProduct->query()->whereIn('status',[0,1,2,3,8,9])->where([['custom_uid','=',$uid],['product_id','=',$productInfo['id']],['insert_time','>=',$productInfo['quota_start']],['insert_time','<=',$productInfo['quota_end']]])->sum('buy_num');
 					// 判断限购数量
 					$total	 			= $buyNum[$buyInfo['product_id']] + $total;
 					// 如果超过数量
@@ -160,7 +159,7 @@ class Orders extends Api{
 					// 是否在限购时间,当前时间大于开始时间,并且小于结束时间
 					if( $productInfo['quota_start'] <= $time && $time <= $productInfo['quota_end'] ){
 						// 通过时间查询商品的购买总数
-						$total 				= $OrdersProduct->query()->where([['custom_uid','=',$uid],['product_id','=',$productInfo['id']],['sku_attr_names','=',$skuInfo['sku_attr_names']],['insert_time','>=',$productInfo['quota_start']],['insert_time','<=',$productInfo['quota_end']]])->sum('buy_num');
+						$total 				= $OrdersProduct->query()->whereIn('status',[0,1,2,3,8,9])->where([['custom_uid','=',$uid],['product_id','=',$productInfo['id']],['sku_attr_names','=',$skuInfo['sku_attr_names']],['insert_time','>=',$productInfo['quota_start']],['insert_time','<=',$productInfo['quota_end']]])->sum('buy_num');
 						// 判断限购数量
 						$total	 			= $buyInfo['buy_num'] + $total;
 						// 如果超过数量

+ 1 - 1
app/Http/Controllers/Api/Score/Orders.php

@@ -42,7 +42,7 @@ class Orders extends Api{
 		// 如果不存在数据
 		if( !$addr )					return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
 		// 重组数据
-		$addr							= ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
+		$addr							= ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'shop_type'=>$addr['shop_type'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
 		// 解码
 		$productList					= $Product->getOne($productId);
 		// 如果产品不存在

+ 105 - 0
app/Models/Custom/Shoptype.php

@@ -0,0 +1,105 @@
+<?php namespace App\Models\Custom;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 客户地址模型
+ * 
+ */
+class Shoptype extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'custom_shoptype';
+    // 是否主动维护时间戳
+    public $timestamps = false;
+    // 定义时间戳字段名
+    // const CREATED_AT = 'insert_time';
+    // const UPDATED_AT = 'update_time';
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function add($data)
+    {
+        // 时间
+        $data['insert_time']				= time();
+        $data['update_time']				= time();
+        // 写入数据表
+        $id						            = $this->query()->insertGetId($data);
+        // 如果操作失败
+        if( !$id )                          return $id;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $id;
+    }
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function edit($id,$data)
+    {
+        // 更新时间
+        $data['update_time']                = time();
+        // 写入数据表
+        $result						        = $this->query()->where(['uid'=>$id])->update($data);
+        // 如果操作失败
+        if( !$result )                      return $result;
+        // 更新缓存
+        $this->getList(true);
+        // 返回结果
+        return                              $result;
+    }
+
+    /**
+     * 获取列表
+     * @param   Bool    $force  是否强制更新
+     * 
+     */
+    public function getList($force = false)
+    {
+        // 结果数据
+        $list                  = $force ? [] : cache('admin:custom:shoptype:list');
+        // 不存在数据
+        if ( !$list ) {
+            // 从数据库获取数据
+            $data              = $this->query()->where(['status'=>0])->get(['id','name']);
+            // 是否有数据
+            $data              = $data ? $data->toArray() : [];
+            // 循环处理数据
+            $list              = [];
+            // 进行更新
+            foreach ($data as $value) {
+                // 重组数据
+                $list[$value['id']] = $value;
+            }
+            // 存起来
+            cache(['admin:custom:shoptype:list'=>$list]);
+        }
+        // 返回结果
+        return                  $list;
+    }
+
+    /**
+     * 获取配置平台对应的应用数据
+     * 
+     * @param   int      用户ID
+     * @param   string     指定字段
+     * 
+     */
+    public function getOne($id,$field='')
+    {
+        // 获取列表数据
+        $list                   = $this->getList();
+        // 获取数据
+        $one                    = isset($list[$id]) ? $list[$id] : [];
+        // 返回值
+        return                  empty($field) ? $one : ( isset($one[$field]) ? $one[$field] : null);
+    }
+
+}

+ 2 - 2
app/Models/CustomAddr.php

@@ -66,7 +66,7 @@ class CustomAddr extends Model
      */
     public function getOne($id,$field=''){
         // 返回结果
-        $result     = $field ? $this->query()->where([['id','=',$id]])->value($field) : $this->query()->where([['id','=',$id]])->first(['id','custom_uid','contact_province','contact_city','contact_area','contact_addr','contact_name','contact_shop','contact_phone','is_default']);
+        $result     = $field ? $this->query()->where([['id','=',$id]])->value($field) : $this->query()->where([['id','=',$id]])->first(['id','custom_uid','contact_province','contact_city','contact_area','contact_addr','contact_name','contact_shop','contact_phone','is_default','shop_type']);
         // 返回结果
         return      $result;
     }
@@ -77,7 +77,7 @@ class CustomAddr extends Model
      */
     public function getListByCustom($uid){
         // 返回结果
-        $result     = $this->query()->where([['custom_uid','=',$uid]])->get(['id','custom_uid','contact_province','contact_city','contact_area','contact_addr','contact_name','contact_shop','contact_phone','is_default']);
+        $result     = $this->query()->where([['custom_uid','=',$uid]])->get(['id','custom_uid','contact_province','contact_city','contact_area','contact_addr','contact_name','contact_shop','contact_phone','is_default','shop_type']);
         // 返回结果
         return      $result;
     }

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

@@ -114,7 +114,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td>¥{{$a['pay_total']}}</td>
 						<td>{{$a['contact_name']}}</td>
 						<td>{{$a['contact_phone']}}</td>
-						<td>{{$a['contact_province']}}/{{$a['contact_city']}}/{{$a['contact_area']}}/{{$a['contact_addr']}} {{$a['contact_shop']}}</td>
+						<td>{{$a['contact_province']}}/{{$a['contact_city']}}/{{$a['contact_area']}}/{{$a['contact_addr']}} {{$a['contact_shop']}} {{$a['shop_type']}}</td>
 						<td>{{$a['state']}}</td>
 						<td>{{date('Y-m-d H:i:s',$a['insert_time'])}}</td>
 						<td>{{$a['regiment_id']>0?'是':'否'}}</td>