Parcourir la source

【Add】订单回执晒单分享送积分

liuxiangxin il y a 6 mois
Parent
commit
2e3cdd442e

+ 44 - 0
app/Http/Controllers/Admin/Orders.php

@@ -7,6 +7,7 @@ use App\Models\CustomScore;
 use App\Models\FilesManager;
 use App\Models\Product;
 use App\Models\Orders as Model;
+use App\Models\Orders\Receipt;
 use App\Models\OrdersAddr;
 use App\Models\OrdersProduct;
 use Illuminate\Support\Facades\DB;
@@ -93,6 +94,49 @@ class Orders extends Auth{
     }
 
 
+	/**
+	 * 首页列表
+	 * 
+	 * */
+    public function detail(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom,OrdersAddr $OrdersAddr,Receipt $Receipt){
+		// 接受参数
+		$id						= request('order_id','');
+		// 查询数据
+		$order					= $Model->query()->find($id);
+		// 查询不到订单
+		if( !$order	)			return $this->error('订单数据不存在');
+		// id转编号
+		$order['order_code']	= $Model->idToCode($order['id']);
+		$order['custom_code']	= $Custom->idToCode($order['custom_uid']);
+		$order['custom_name']	= $Custom->getValue($order['custom_uid'],'username');
+		$order['state']			= $Model->getState($order['status'],'state');
+		// 查询子订单数据
+		$orderItems				= $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();
+		// 地址
+		$orderAddr				= $OrdersAddr->query()->where([['order_id','=',$id]])->first(['contact_name','contact_phone','contact_province','contact_city','contact_area','contact_addr','contact_shop']);
+		// 审核记录
+		$orderReceipt			= $Receipt->query()->where([['order_id','=',$id]])->orderByDesc('id')->get()->toArray();
+		// 循环数据
+		foreach ($orderItems as $key => $value) {
+			$value['product_code']	= $Product->idToCode($value['product_id']);
+			$orderItems[$key]  = $value;
+		}
+		// 循环数据
+		foreach ($orderReceipt as $key => $value) {
+			$value['image']		= path_compat($value['image']);
+			$orderReceipt[$key] = $value;
+		}
+		// 分配数据
+		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+		$this->assign('order', $order);
+		$this->assign('orderAddr', $orderAddr);
+		$this->assign('orderItems', $orderItems);
+		$this->assign('orderReceipt', $orderReceipt);
+		// 加载模板
+		return						$this->fetch();
+    }
+
+
 	/**
 	 * 状态
 	 * 

+ 161 - 0
app/Http/Controllers/Admin/OrdersReceipt.php

@@ -0,0 +1,161 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Http\Requests\Admin\Orders\Receipt as Request;
+use App\Models\Orders\Receipt as Model;
+use App\Models\City;
+use App\Models\CustomScore;
+use App\Models\Orders;
+use App\Models\OrdersProduct;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * Receipt管理
+ *
+ * @author    刘相欣
+ *
+ */
+class OrdersReceipt extends Auth{
+	
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','订单管理');
+		$this->assign('breadcrumb2','订单回执');
+	}
+	
+	/**
+	 * 首页列表
+	 * 
+	 * */
+    public function index(Model $Model){
+		// 接受参数
+		$orderCode				= request('order_code','');
+
+		$orderId				= 0;
+		// 查询条件
+		$map 					= [];
+		// 编码ID
+		if( $orderId )			$map[] = ['order_id','=',$orderId];
+		// 查询数据
+		$list					= $Model->query()->where($map)->orderByDesc('id')->paginate(request('limit',config('page_num',10)))->appends(request()->all());
+		// 循环处理数据
+		foreach ($list as $key => $value) {
+			// id转编号
+			$value['image']		= $value['image'] ? path_compat($value['image']) : '';
+			// 重组
+			$list[$key]			= $value;
+		}
+		// 分配数据
+		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+		$this->assign('list', $list);
+		// 加载模板
+		return $this->fetch();
+    }
+
+	/**
+	 * 通过
+	 * 
+	 * */
+	public function allow( Request $request, Model $Model,Orders $Orders,OrdersProduct $OrdersProduct,CustomScore $CustomScore ){
+		// 接收参数
+		$id							= request('id',0);
+		// 查询数据
+		$oldData					= $Model->where(['id'=>$id])->first();
+		// 参数
+		if( request()->isMethod('post') ){
+			// 验证参数
+			$request->scene('allow')->validate();
+			$status					= request('status',1);
+			$giveScore				= request('give_score',0);
+			$remark					= request('remark','');
+			$remark					= $giveScore ? '已发放'.$giveScore.'积分' : '';
+			// 组合数据,写入订单表,子表
+			DB::beginTransaction();
+			// 判断结果
+			try {
+				// 查询数据
+				$result					= $Model->edit($id,['status'=>$status,'give_score'=>$giveScore,'remark'=>$remark]);
+				// 提示新增失败
+				if( !$result )			return json_send(['code'=>'error','msg'=>'操作失败']);
+				// 发放积分
+				if( $giveScore > 0 ) 	$CustomScore->trade($oldData['custom_uid'],$oldData['order_id'],$giveScore,8,1);
+				// 完成订单
+				$result					= $Orders->setOrderStatus($oldData['order_id'],8,$OrdersProduct);
+				// 提示新增失败
+				if( isset($result['error']) ){
+					// 回退数据
+					DB::rollBack();
+					// 提示信息
+					return				json_send(['code'=>'error','msg'=>'订单状态变更失败,请重试','data'=>['error'=>$result['error']]]);
+				}
+				// 记录行为
+				$this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,[],['status'=>$status,'remark'=>$remark]);
+				// 提交事务
+				DB::commit();
+				// 告知结果
+				return				json_send(['code'=>'success','msg'=>'操作成功','path'=>'']);
+			} catch (\Throwable $th){
+				// 回滚
+				DB::rollBack();
+				// 添加失败
+				return				json_send(['code'=>'error','msg'=>'操作失败','data'=>['error'=>$th->getMessage()]]);
+			}
+		}
+		// 分配数据
+		$this->assign('oldData',$oldData);
+		// 加载模板
+		return				$this->fetch();
+	}
+
+
+	/**
+	 * 状态
+	 * 
+	 * */
+	public function refuse( Request $request, Model $Model,Orders $Orders,OrdersProduct $OrdersProduct ){
+		// 接收参数
+		$id							= request('id',0);
+		// 查询数据
+		$oldData					= $Model->where(['id'=>$id])->first();
+		// 参数
+		if( request()->isMethod('post') ){
+			// 验证参数
+			$request->scene('refuse')->validate();
+			$status					= request('status',2);
+			$remark					= request('remark','');
+			// 组合数据,写入订单表,子表
+			DB::beginTransaction();
+			// 判断结果
+			try {
+				// 查询数据
+				$result				= $Model->edit($id,['status'=>$status,'remark'=>$remark]);
+				// 提示新增失败
+				if( !$result )		return json_send(['code'=>'error','msg'=>'操作失败']);
+				// 恢复订单进行中
+				$result				= $Orders->setOrderStatus($oldData['order_id'],1,$OrdersProduct);
+				// 提示新增失败
+				if( isset($result['error']) ){
+					// 回退数据
+					DB::rollBack();
+					// 提示信息
+					return			json_send(['code'=>'error','msg'=>'订单状态变更失败,请重试','data'=>['error'=>$result['error']]]);
+				}
+				// 记录行为
+				$this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,[],['status'=>$status,'remark'=>$remark]);
+				// 提交事务
+				DB::commit();
+				// 告知结果
+				return				json_send(['code'=>'success','msg'=>'操作成功','path'=>'']);
+			} catch (\Throwable $th){
+				// 回滚
+				DB::rollBack();
+				// 添加失败
+				return				json_send(['code'=>'error','msg'=>'操作失败','data'=>['error'=>$th->getMessage()]]);
+			}
+		}
+		// 分配数据
+		$this->assign('oldData',$oldData);
+		// 加载模板
+		return				$this->fetch();
+	}
+
+}

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

@@ -305,7 +305,7 @@ class Orders extends Api{
 
 
 	/**
-	 * 获取产品列表		 /api/orders/get_list
+	 * 获取列表		 /api/orders/get_list
 	 * 
 	 * @param	string	$name		    产品名称
 	 * @param	int		$page			页码,默认1
@@ -491,6 +491,44 @@ class Orders extends Api{
 	}
 
 
-	
+	/**
+	 * 获取订单子数据		 /api/orders/get_item
+	 * 
+	 * @param	string	$name		    产品名称
+	 * @param	int		$page			页码,默认1
+	 * @param	int		$limit			每页条数,默认10条
+	 * 
+	 * */
+	public function get_item(Request $request,Model $Model,OrdersProduct $OrdersProduct,Business $Business){
+		// 接口验签
+		// $this->verify_sign();
+        // 验证参数
+		$request->scene('get_item')->validate();
+		// 检查登录
+		$uid						= $this->checkLogin();
+		// 接收参数
+		$id							= request('id',0);
+		// 查询
+		$orderInfo					= $Model->query()->where([['id','=',$id],['custom_uid','=',$uid]])->first(['id','pay_total','status','price_total','coupon_total','business_id','pay_total','weizan_orderid','insert_time']);
+		// 如果用户不存在
+		if( !$orderInfo )			return json_send(['code'=>'error','msg'=>'订单不存在']);
+		// 转数组
+		$orderInfo					= $orderInfo->toArray();
+		// 订单产品
+		$orderInfo['product_list'] 	= $OrdersProduct->query()->where([['order_id','=',$id]])->select(['id as item_id','order_id','product_id','buy_num','is_rebate','sku_attr_names as product_spec','product_name','product_thumb'])->get()->toArray();
+		// 循环处理
+		foreach ($orderInfo['product_list'] as $key => $item) {
+			// 产品图路径
+			$item['product_thumb']	= path_compat($item['product_thumb']);
+			// 重组
+			$orderInfo['product_list'][$key] = $item;
+		}
+		// 获取子列表
+		$orderInfo['state']			= (string) $Model->getState($orderInfo['status'],'state');
+		// 获取子列表
+		$orderInfo['business_name']	= (string) ($orderInfo['business_id'] ? $Business->getOne($orderInfo['business_id'],'name') : ($orderInfo['weizan_orderid'] ? '微赞订单' : ''));
+		// 返回结果
+		return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$orderInfo]);
+	}
 
 }

+ 133 - 0
app/Http/Controllers/Api/Orders/Receipt.php

@@ -0,0 +1,133 @@
+<?php namespace App\Http\Controllers\Api\Orders;
+
+use App\Models\Orders;
+use App\Models\FilesManager;
+use App\Http\Controllers\Api\Api;
+use App\Models\Orders\Receipt as Model;
+use App\Models\OrdersProduct as OrdersProduct;
+use App\Http\Requests\Api\Orders\Receipt as Request;
+use Illuminate\Support\Facades\DB;
+use Intervention\Image\Facades\Image;
+use Intervention\Image\Gd\Font;
+
+/**
+ * 订单回执
+ * 
+ * @author 刘相欣
+ * 
+ * */
+class Receipt extends Api{
+	
+	
+	/**
+	 * 提交审核				 /api/orders_receipt/apply
+	 * 
+	 * */
+	public function apply(Request $request,Model $Model,Orders $Orders,OrdersProduct $OrdersProduct,FilesManager $FilesManager){
+		// 接口验签
+		// $this->verify_sign();
+		// 验证参数
+		$request->scene('apply')->validate();
+		// 检查登录
+		$uid							= 2;//$this->checkLogin();
+		// 接收参数
+		$orderId						= request('order_id',0);
+		// 接收文件
+		$file							= request()->file('file');
+		// 图片数据
+		$result 						= $FilesManager->fileStore($file,'orders/receipt/'.$uid);
+		// 上传失败
+		if( isset($result['error']) )	return json_send(['code'=>'error','msg'=>$result['error'],'data'=>'']);
+		// 查询订单信息
+		$orderData						= $Orders->query()->find($orderId,['id','pay_total','status']);
+		// 上传失败
+		if( !$orderData )				return json_send(['code'=>'error','msg'=>'订单数据不存在','data'=>'']);
+		// 上传失败
+		if( $orderData['status'] == 9 )	return json_send(['code'=>'error','msg'=>'订单回执审核中','data'=>'']);
+		// 上传失败
+		if( $orderData['status'] != 1 )	return json_send(['code'=>'success','msg'=>'订单已取消','data'=>'']);
+		// 积分结果
+		$score							= floor( $orderData['pay_total'] * 1 ) > 0  ? floor( $orderData['pay_total'] * 1 ) : 0;
+		// 组合数据,写入订单表,子表
+		DB::beginTransaction();
+		// 组合数据
+		try{
+			// 存入记录
+			$result 					= $Model->add(['order_id'=>$orderId,'custom_uid'=>$uid,'image'=>$result['file_path'],'score'=>$score]);
+			// 提示新增失败
+			if( !$result )				{
+				// 回退数据
+				DB::rollBack();
+				// 提示信息
+				return					json_send(['code'=>'error','msg'=>'记录失败,请重试','data'=>['error'=>'记录失败,请重试']]);
+			}
+			// 查询数据
+			$result						= $Orders->setOrderStatus($orderId,9,$OrdersProduct);
+			// 提示新增失败
+			if( isset($result['error']) ){
+				// 回退数据
+				DB::rollBack();
+				// 提示信息
+				return					json_send(['code'=>'error','msg'=>'订单状态变更失败,请重试','data'=>['error'=>$result['error']]]);
+			}
+			// 提交数据
+			DB::commit();
+			// 获取分享链接
+			$shareImage					= $this->getShareImage($uid,$orderId,$score);
+			$shareImage					= $shareImage ? path_compat($shareImage) : '';
+			// 告知结果
+			return						json_send(['code'=>'success','msg'=>'申请成功','data'=>['share_info'=>['title'=>'我已经完成一笔订单,你也快来吧','path'=>'/pages/index/index','imageUrl'=>$shareImage]]]);
+			// 返回结果
+		} catch (\Throwable $th) 		{
+			// 回退数据
+			DB::rollBack();
+			// 下单失败提示
+			return						json_send(['code'=>'error','msg'=>'申请失败,请重试','data'=>['error'=>$th->getMessage().$th->getLine()]]);
+		}
+	}
+
+	/**
+	 * 分享图片
+	 * 
+	 */
+	private function getShareImage($uid,$orderId,$score=0){
+		// 尝试执行
+		try {
+			// 加载图片
+			$image		= Image::make(public_path('uploads/images/default/').'order_receipt_share.jpg');
+			// 设置文字样式(字体、大小、颜色等)
+			$fontPath	= public_path().'/fonts/msyh14.ttf';// 指定字体文件路径
+			// 文本
+			$text 		= $score ? '我完成了一笔订单,即将获得'.$score.'积分' : '我完成了一笔订单';
+			// 给图片写入文字
+			$image->text($text, 240,80,function (Font $font) use ($fontPath) {
+				$font->file($fontPath);		// 字体文件地址
+				$font->size(24);			// 字体大小
+				$font->color('#FFFFFF');
+				$font->align('center');
+			});
+			// 给图片写入文字
+			$image->text('你也来试试吧', 240,140,function (Font $font) use ($fontPath) {
+				$font->file($fontPath);		// 字体文件地址
+				$font->size(24);			// 字体大小
+				$font->color('#FFFFFF');
+				$font->align('center');
+			});
+			// 路径
+			$path		= public_path('uploads/order_receipt_share/');
+			// 判断路径是不是存在
+			if( !is_dir($path) ) mkdir($path,0755,true);
+			// 路径
+			$filename		= $path.$uid.'_'.$orderId.'.jpg';
+			// 保存图片
+			$image->save($filename);
+			// 返回路径
+			return 			'order_receipt_share/'.$uid.'_'.$orderId.'.jpg';
+		} catch (\Throwable $th) {
+			dd($th);
+			// 返回路径
+			return 			'';
+		}
+	}
+	
+}

+ 48 - 0
app/Http/Requests/Admin/Orders/Receipt.php

@@ -0,0 +1,48 @@
+<?php namespace App\Http\Requests\Admin\Orders;
+
+use App\Http\Requests\BaseRequest;
+
+/**
+ * 类型验证器
+ * 
+ */
+class Receipt extends BaseRequest
+{
+    /**
+     * 获取应用于请求的规则
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        // 返回结果
+        return      [
+            // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
+            // 验证字段,验证规则,提示信息
+	        'remark' 			=> 'required',
+	        'id'                => 'required|integer|gt:0',
+        ];
+    }
+    
+    // 场景列表
+    protected   $scenes         = [
+        'allow'  		        => ['id'],
+        'refuse'  		        => ['id','remark'],
+	];
+
+    /**
+     * 获取已定义验证规则的错误消息
+     *
+     * @return array
+     */
+    public function messages()
+    {
+        return [
+            'remark.required'   => '拒绝原因必填',
+            'id.required'       => 'ID未知',
+            'id.integer'        => 'ID格式错误',
+            'id.gt'   		    => 'ID格式错误',
+        ];
+    }
+    
+}

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

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

+ 50 - 0
app/Http/Requests/Api/Orders/Receipt.php

@@ -0,0 +1,50 @@
+<?php namespace App\Http\Requests\Api\Orders;
+
+use App\Http\Requests\BaseRequest;
+
+/**
+ * 活动
+ * 
+ */
+class Receipt extends BaseRequest
+{
+    /**
+     * 获取应用于请求的规则
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        // 返回结果
+        return      [
+            // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
+            // 验证字段,验证规则,提示信息
+            'order_id'          => 'required|integer|gt:0',
+            'file'              => 'required|file|image|max:5120',
+        ];
+    }
+
+    // 场景列表
+    protected   $scenes         = [
+        'apply'            => ['order_id'],
+	];
+
+    /**
+     * 获取已定义验证规则的错误消息
+     *
+     * @return array
+     */
+    public function messages()
+    {
+        return [
+            'order_id.required'   	=> '请选择订单',
+            'order_id.integer'   	=> '订单ID有误',
+            'order_id.gt'   	    => '订单ID有误',
+            'file.required'   	    => '请上传图片',
+            'file.file'   	        => '请上传图片',
+            'file.image'   	        => '请上传图片',
+            'file.max'   	        => '图片请勿超过5MB',
+        ];
+    }
+
+}

+ 13 - 11
app/Models/FilesManager.php

@@ -65,37 +65,39 @@ class FilesManager extends Model
     public function fileStore($file, $path = 'company/license/')
     {
         // 请指定路径
-        if (!$path)                        return ['error' => '请指定存储路径'];
+        if (!$path)                         return ['error' => '请指定存储路径'];
         // 组装
         $path                               = trim($path, '/') . '/';
         // 判断文件是否有问题
-        if (!is_object($file))             return ['error' => '文件上传失败,请重试'];
+        if (!is_object($file))              return ['error' => '文件上传失败,请重试'];
         // md5
         $fileMd5                            = md5_file($file->getPathName());
         // 通过文件MD5查询是否已经存在
         $data                               = $this->getOneByMd5($fileMd5);
         // 如果存在,直接返回
-        if ($data)                         return $data;
+        if ($data)                          return $data;
         // 文件名
-        $filename                            = html_entity_decode(ltrim($file->getClientOriginalName(), '/'), ENT_QUOTES, 'UTF-8');
-        // 文件名仅支持字母数字中文-_组合
-        if (!preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_\-\+\.\(\)(\x20)]+$/u', $filename)) return ['error' => $filename . '文件名仅支持字母数字中文空格-_组合'];
+        $filename                           = html_entity_decode(ltrim($file->getClientOriginalName(), '/'), ENT_QUOTES, 'UTF-8');
+        // // 文件名仅支持字母数字中文-_组合
+        // if (!preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_\-\+\.\(\)(\x20)]+$/u', $filename)) return ['error' => $filename . '文件名仅支持字母数字中文空格-_组合'];
+        // 文件大小
+        $ext                                = pathinfo($file->getClientOriginalName(),PATHINFO_EXTENSION);
         // 文件名
-        $filename                             = md5($filename);
+        $filename                           = md5($filename).'.'.$ext;
         // 文件大小
         $size                               = $file->getSize();
         // 保存文件
         $objectPath                         = $file->move(public_path('uploads/' . $path), $filename);
         // 如果有错误
-        if (!$objectPath)                    return ['error' => $file->getError()];
+        if (!$objectPath)                   return ['error' => $file->getError()];
         // 保存路径
-        $data                                = ['file_path' => $path . $filename, 'file_size' => $size, 'file_name' => $filename, 'file_md5' => $fileMd5];
+        $data                               = ['file_path' => $path . $filename, 'file_size' => $size, 'file_name' => $filename, 'file_md5' => $fileMd5];
         // 写入数据库
         $data['file_id']                    = $this->add($data);
         // 移动失败
-        if (!$data['file_id'])                return ['error' => '存储失败'];
+        if (!$data['file_id'])              return ['error' => '存储失败'];
         // 返回结果
-        return                                $data;
+        return                              $data;
     }
 
     /**

+ 56 - 0
app/Models/Orders/Receipt.php

@@ -0,0 +1,56 @@
+<?php namespace App\Models\Orders;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * 订单回执
+ * 
+ */
+class Receipt extends Model
+{
+    use HasFactory;
+
+    // 与模型关联的表名
+    protected $table = 'orders_receipt';
+    // 是否主动维护时间戳
+    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 0;
+        // 返回结果
+        return                              $id;
+    }
+
+
+    /**
+     * 添加数据
+     * 
+     */
+    public function edit($id,$data)
+    {
+        // 更新时间
+        $data['update_time']                = time();
+        // 写入数据表
+        $result						        = $this->query()->where(['id'=>$id])->update($data);
+        // 失败结果
+        if( !$result )                      return 0;
+        // 返回结果
+        return                              $result;
+    }
+
+}

+ 4 - 0
app/Models/Traits/Orders/Status.php

@@ -47,6 +47,10 @@ trait Status
                                         'id'            =>8,
                                         'name'          =>'已完成',// 已收货
                                         'state'         =>'已完成',
+                                    ],'9'=>[
+                                        'id'            =>9,
+                                        'name'          =>'回执审核',// 回执审核
+                                        'state'         =>'回执审核',
                                     ]];
 
     /**

+ 6 - 0
app/Models/Traits/Score/BuyType.php

@@ -54,6 +54,12 @@ trait BuyType
                                         'name'          =>'积分抽奖',
                                         // 支付方式  方式名称
                                         'pay_type'      =>['1'=>['id'=>1,'name'=>'抽奖消耗'],'2'=>['id'=>2,'name'=>'中奖积分']],
+                                    ],'8'=>[
+                                        'id'            =>8,
+                                        // 类型名称
+                                        'name'          =>'收货奖励',
+                                        // 支付方式  方式名称
+                                        'pay_type'      =>['1'=>['id'=>1,'name'=>'回执审核']],
                                     ]];
 
     /**

BIN
public/fonts/msyh14.ttf


BIN
public/uploads/images/default/order_receipt_share.jpg


+ 93 - 48
resources/views/admin/orders/detail.blade.php

@@ -10,50 +10,27 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			<table class="table table-bordered text-center">
 				<tbody>
 					<tr>
-						<th>订单ID</th>
-						<th>订单状态</th>
-						<th>订单描述</th>
-					</tr>
-					<tr>
-						<td>{{$order['order_id']}}</td>
-						<td>
-						    @if ( isset($order['order_status_id']) )
-    							@switch ($order['order_status_id'])
-    								@case(config('default_order_status')) 
-    									<span class="text-red">待支付</span>
-    								@break
-    								@case(config('paid_order_status')) 
-    									<span class="text-success">已支付</span>
-    								@break
-    								@default
-    									未知
-    							@endswitch
-							@endif
-						</td>
-						<td>{{$order['order_subject']?? ''}}</td>
+						<th>下单用户</th>
+						<th>收货地址</th>
 					</tr>
 					<tr>
-						<th>下单地区</th>
-						<th>下单系统</th>
-						<th>下单终端</th>
+						<td> {{$order['custom_name']}} </td>
+						<td> {{$orderAddr['contact_name']}} {{$orderAddr['contact_phone']}} {{$orderAddr['contact_province']}}/{{$orderAddr['contact_city']}}/{{$orderAddr['contact_area']}}/{{$orderAddr['contact_addr']}} {{$orderAddr['contact_shop']}} </td>
 					</tr>
+				</tbody>
+			</table>
+			<table class="table table-bordered text-center">
+				<tbody>
 					<tr>
-						<td>{{$order['buyer_area'] ?? '未知'}}</td>
-						<td>{{$order['buyer_system'] ?? '未知'}}</td>
-						<td>{{$order['buyer_client'] ?? '未知'}}</td>
-					</tr>
-					@if (!empty($order['pay_id']))
-					<tr>
-						<th>支付类型--支付ID</th>
-						<th>支付时间</th>
-						<th>实际支付</th>
+						<th>订单编号</th>
+						<th>下单时间</th>
+						<th>订单状态</th>
 					</tr>
 					<tr>
-						<td>{{$order['payment_code'] ?? ''}} -- {{$order['pay_id'] ?? ''}}</td>
-						<td>{{date('Y-m-d H:i:s',$order['pay_time'])}}</td>
-						<td>{{$order['pay_fee'] ?? ''}}</td>
+						<td> {{$order['order_code']}} </td>
+						<td> {{date('Y-m-d H:i:s',$order['insert_time'])}} </td>
+						<td> {{$order['state']}} </td>
 					</tr>
-					@endif
 				</tbody>
 			</table>
 		</div>
@@ -62,23 +39,91 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			<table class="table table-striped table-bordered text-center table-hover">
 				<thead>
 					<tr>
-						<th>表盘ID</th>
+						<th>产品编码</th>
+						<th>产品名称</th>
+						<th>产品规格</th>
 						<th>购买数量</th>
-						<th>购买单价</th>
+						<th>产品价格</th>
 					</tr>
 				</thead>
 				<tbody>
-				    @if ( !empty($order['orders_dial'][0]) )
-    					@foreach ($order['orders_dial'] as $a)
-    					<tr class="active">
-    						<td>ID:{{$a['dial_id']}}</td>
-    						<td>{{$a['buy_num']}}件</td>
-    						<td>{{$a['buy_price']}}元</td>
-    					</tr>
-    					@endforeach
-					@endif
+					@foreach ($orderItems as $a)
+						<tr class="active">
+							<td> @if($a['is_rebate']) 【赠品】 @endif {{$a['product_code']}}</td>
+							<td>{{$a['product_name']}}</td>
+							<td>{{$a['product_spec']}}</td>
+							<td>{{$a['buy_num']}}</td>
+							<td>{{$a['pay_total']}}</td>
+						</tr>
+					@endforeach
 				</tbody>
 			</table>
+			<table class="table table-striped table-bordered text-center table-hover">
+				<tbody>
+					<tr>
+						<th style="text-align: right;">
+							<p>订单总价: {{$order['price_total']}}</p>
+							<p>优惠扣减: {{$order['coupon_total']}}</p>
+							<p>订单金额: {{$order['pay_total']}}</p>
+						</th>
+					</tr>
+				</tbody>
+			</table>
+		</div>
+	</div>
+</div>
+<div class="row">
+	<div class="col-xs-12">
+		<div class="table-responsive">
+			<label for="">回执审核</label>
+			<table class="table table-bordered text-center">
+				<tbody>
+					<tr>
+						<th>回执图片</th>
+						<th>提交时间</th>
+						<th>审核状态</th>
+						<th>备注</th>
+						<th>修改时间</th>
+						<th>操作</th>
+					</tr>
+					@foreach ($orderReceipt as $a)
+					<tr>
+						<td> <img src="{{$a['image']}}" height="100"> </td>
+						<td> {{date('Y-m-d H:i:s',$a['insert_time'])}} </td>
+						<td> {{$a['status'] == 1 ? '通过': ( $a['status'] == 2?'不通过':'待审核')}} </td>
+						<td> {{$a['remark']}} </td>
+						<td> {{date('Y-m-d H:i:s',$a['update_time'])}} </td>
+						<td> 
+							@if( !$a['status'] )
+								@if( check_auth('admin/orders_receipt/refuse') )
+								<a class="modal_show btn btn-sm btn-danger" href="javascript:;" data-url="{{url('admin/orders_receipt/refuse?'.http_build_query(['id'=>$a['id'],'status'=>2]))}}" title="不通过">
+									不通过
+								</a>
+								@endif
+								@if( check_auth('admin/orders_receipt/allow') )
+								<a class="modal_show btn btn-sm btn-success" href="javascript:;" data-url="{{url('admin/orders_receipt/allow?'.http_build_query(['id'=>$a['id'],'status'=>1]))}}" title="通过">
+									通过
+								</a>
+								@endif
+							@endif
+						</td>
+					</tr>
+					@endforeach
+				</tbody>
+			</table>
+		</div>
+	</div>
+</div>
+<!-- Modal -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
+	<div class="modal-dialog" role="document">
+		<div class="modal-content">
+			<div class="modal-header">
+				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+				<h4 class="modal-title" id="myModalLabel"></h4>
+			</div>
+			<div class="modal-body"></div>
+			<div class="modal-footer"></div>
 		</div>
 	</div>
 </div>

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

@@ -94,11 +94,11 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td>{{$a['contact_phone']}}</td>
 						<td>{{$a['contact_province']}}/{{$a['contact_city']}}/{{$a['contact_area']}}/{{$a['contact_addr']}} {{$a['contact_shop']}}</td>
 						<td>{{$a['state']}}</td>
-						<td>{{date('Y-m-d H:i:s',$a['insert_time']??0)}}</td>
+						<td>{{date('Y-m-d H:i:s',$a['insert_time'])}}</td>
 						<td>
-							@if( $a['status'] != 8 && check_auth('admin/orders_transport/add') )
-							<a class="btn btn-sm btn-primary" href="{{url('admin/orders_transport/add?'.http_build_query(['order_code'=>$a['order_code']]))}}" title="查看">
-								出库
+							@if( check_auth('admin/orders/detail') )
+							<a class="btn btn-sm btn-primary" href="{{url('admin/orders/detail?'.http_build_query(['order_id'=>$a['order_id']]))}}" title="查看">
+								{{$a['status']==9?'审核':'查看'}}
 							</a>
 							@endif
 							@if( $a['status'] == 1 && check_auth('admin/orders/set_status') )

+ 11 - 0
resources/views/admin/orders_receipt/allow.blade.php

@@ -0,0 +1,11 @@
+<form class="post-form" action="{{url('admin/orders_receipt/allow')}}" method="post">
+	<div class="form-group col-sm-12">
+		<label class="control-label">赠送积分</label>
+		<input class="form-control" required="required" type="text" placeholder="赠送积分" maxlength="50" name="give_score" value="{{$oldData['score']??0}}" />
+	</div>
+	<div class="form-group col-sm-12">
+		@csrf
+		<input type="hidden" name="id" value="{{$oldData['id']}}">
+		<input id="send" type="submit" value="审核通过" class="btn btn-primary btn-block" />
+	</div>
+</form>

+ 68 - 0
resources/views/admin/orders_receipt/index.blade.php

@@ -0,0 +1,68 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+<div class="page-header">
+	<a href="{{url('admin/orders_banner/add')}}" class="btn btn-primary">新增</a>
+</div>
+<form action="" method="get" class="form-horizontal form-line">
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="name" value="{{request('name','')}}" placeholder="请输入banner名称查询" />
+	</div>
+	<input type="submit" class="btn btn-sm btn-primary" value="查询"/>
+	<a href="{{url('admin/orders_banner/index')}}" class="btn btn-sm btn-default" >重置</a>
+</form>
+<div class="row">
+	<div class="col-xs-12">
+		<div class="table-responsive">
+			<table class="table table-striped table-bordered table-hover">
+				<thead>
+					<tr>
+						<th>ID</th>
+						<th>名称</th>
+						<th>活动图片</th>
+						<th>跳转链接</th>
+						<th>状态</th>
+						<th>修改时间</th>
+						<th>操作</th>
+					</tr>
+				</thead>
+				<tbody>
+					@foreach ($list as $a)
+					<tr>
+						<td> {{$a['id']}}</td>
+						<td> {{$a['name']}}</td>
+						<td> <img src="{{$a['thumb']}}" alt="" height="50"> </td>
+						<td> {{$a['link_url']}} </td>
+						<td> {{$a['status']?'停用':'启用'}} </td>
+						<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>
+						<td>
+							<a class="btn btn-sm btn-warning" href="{{url('admin/orders_banner/edit?'.http_build_query(['id'=>$a['id']]))}}" title="查看">
+								编辑
+							</a>
+							@if ($a['status'])
+								<a class="delete btn btn-sm btn-success" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'0']))}}">
+									启用
+								</a>
+							@else
+								<a class="delete btn btn-sm btn-danger" data-url="{{url('admin/orders_banner/set_status?'.http_build_query(['id'=>$a['id'],'status'=>'1']))}}">
+									停用
+								</a>
+							@endif
+						</td>
+					</tr>
+					@endforeach
+					<tr>
+						<td colspan="20" class="page">{{$list->render()}}</td>
+					</tr>
+					<tr>
+						<td colspan="20">总计 {{$list->total()}} 个Banner</td>
+					</tr>
+				</tbody>
+
+			</table>
+		</div>
+	</div>
+</div>
+@endsection

+ 11 - 0
resources/views/admin/orders_receipt/refuse.blade.php

@@ -0,0 +1,11 @@
+<form class="post-form" action="{{url('admin/orders_receipt/refuse')}}" method="post">
+	<div class="form-group col-sm-12">
+		<label class="control-label">拒绝原因</label>
+		<input class="form-control" required="required" type="text" placeholder="拒绝原因" maxlength="45" name="remark" value="" />
+	</div>
+	<div class="form-group col-sm-12">
+		@csrf
+		<input type="hidden" name="id" value="{{$oldData['id']}}">
+		<input id="send" type="submit" value="审核不通过" class="btn btn-primary btn-block" />
+	</div>
+</form>

+ 10 - 1
routes/api.php

@@ -41,6 +41,8 @@ Route::any('orders/create',[\App\Http\Controllers\Api\Orders::class,'create']);
 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('shop_cart/add',[\App\Http\Controllers\Api\ShopCart::class,'add']);
@@ -168,4 +170,11 @@ Route::any('lottery_order_record/set_addr',[\App\Http\Controllers\Api\Lottery\Or
  * 微赞订单
  */
 // 导入接口
-Route::any('weizan_orders/import',[\App\Http\Controllers\Api\WeiZan\Orders::class,'import']);
+Route::any('weizan_orders/import',[\App\Http\Controllers\Api\WeiZan\Orders::class,'import']);
+
+
+/**
+ * 订单回执上传
+ * 
+ * */
+Route::any('orders_receipt/apply',[\App\Http\Controllers\Api\Orders\Receipt::class,'apply']);

+ 11 - 0
routes/web.php

@@ -161,6 +161,8 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     /* 订单管理 */
     // 列表
     Route::any('orders/index',[App\Http\Controllers\Admin\Orders::class,'index']);
+    // 列表
+    Route::any('orders/detail',[App\Http\Controllers\Admin\Orders::class,'detail']);
     // 状态
     Route::any('orders/set_status',[App\Http\Controllers\Admin\Orders::class,'set_status']); 
     // 订单导入
@@ -415,4 +417,13 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     // 状态
     Route::any('lottery_order_product/set_status',[App\Http\Controllers\Admin\LotteryOrderProduct::class,'set_status']);
 
+
+    /* 下单抽奖-商品范围 */
+    // 列表
+    Route::any('orders_receipt/index',[App\Http\Controllers\Admin\OrdersReceipt::class,'index']);
+    // 详情
+    Route::any('orders_receipt/allow',[App\Http\Controllers\Admin\OrdersReceipt::class,'allow']);
+    // 详情
+    Route::any('orders_receipt/refuse',[App\Http\Controllers\Admin\OrdersReceipt::class,'refuse']);
+
 });