Browse Source

Merge remote-tracking branch 'origin/jun' into liuxiangxin

liuxiangxin 4 months ago
parent
commit
72a5e7e595

+ 28 - 2
app/Http/Controllers/Admin/Orders.php

@@ -12,6 +12,7 @@ use App\Models\Orders\Receipt;
 use App\Models\OrdersAddr;
 use App\Models\OrdersProduct;
 use Illuminate\Support\Facades\DB;
+use Kra8\Snowflake\Snowflake;
 use PhpOffice\PhpSpreadsheet\Cell\DataType;
 use PhpOffice\PhpSpreadsheet\IOFactory;
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
@@ -19,6 +20,7 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
 use PhpOffice\PhpSpreadsheet\Style\Fill;
 use Intervention\Image\Facades\Image;
 use Intervention\Image\Gd\Font;
+use App\Servers\WechatPay\Payment;
 
 /**
  * 订单管理
@@ -215,8 +217,32 @@ class Orders extends Auth{
 			return			json_send(['code'=>'error','msg'=>'设置失败','data'=>['error'=>$th->getMessage().$th->getLine()]]);
 		}
 	}
-	
-
+    /**
+     * 退款
+     *
+     * */
+    public function refund( Request $request, Model $Model,OrdersProduct $OrdersProduct,CustomScore $CustomScore,Payment $Payment){
+        // 验证参数
+        $request->scene('refund')->validate();
+        // 接收参数
+        $id				= request('id',0);
+        $orderInfo		= $Model->query()->find($id);
+        if (!$orderInfo)    return json_send(['code'=>'error','msg'=>'订单不存在']);
+        $params['out_trade_no']   =   (string)$orderInfo['snowflake_id'];
+        $Snowflake = new Snowflake();
+        $out_refund_no = $Snowflake->next();
+        $params['out_refund_no']    =   (string)$out_refund_no;
+        $params['refund']           =   (int)$orderInfo['pay_total'];
+        $params['total']            =   (int)$orderInfo['pay_total'];
+        $params['reason']           =   '用户退款';
+        $res                        =   $Payment->refund($params);
+        if (!$res)                  return json_send(['code'=>'error','msg'=>'退款失败']);
+        //修改订单状态
+        $res                        =   $Model->query()->where('snowflake_id','=',$orderInfo['snowflake_id'])->update(['out_refund_no'=>$out_refund_no,'status'=>5]);
+        //修改订单产品状态
+        $res                        =   $OrdersProduct->query()->where('order_id','=',$id)->update(['status'=>5]);
+        return json_send(['code'=>'success','msg'=>'退款成功']);
+    }
 	/**
 	 * 表格导入
 	 * 

+ 647 - 0
app/Http/Controllers/Admin/OrdersClassSummary.php

@@ -0,0 +1,647 @@
+<?php namespace App\Http\Controllers\Admin;
+
+use App\Http\Requests\Admin\Orders as Request;
+use App\Models\AdminUser;
+use App\Models\Custom;
+use App\Models\CustomAddr;
+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;
+use PhpOffice\PhpSpreadsheet\Cell\DataType;
+use PhpOffice\PhpSpreadsheet\IOFactory;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\Fill;
+use Intervention\Image\Facades\Image;
+use Intervention\Image\Gd\Font;
+
+/**
+ * 订单管理  班级汇总
+ *
+ * @author    刘相欣
+ *
+ */
+class OrdersClassSummary extends Auth{
+	
+	protected function _initialize(){
+		parent::_initialize();
+		$this->assign('breadcrumb1','订单管理');
+		$this->assign('breadcrumb2','班级汇总');
+	}
+
+	/**
+	 * 首页列表
+	 * 
+	 * */
+    public function index(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom){
+		// 接受参数
+		$semester				= request('semester','');
+		$contact_school			= request('contact_school','');
+		//$status					= 2;
+		$startTime				= request('start_time','');
+		$endTime				= request('end_time','');
+		// 查询条件
+		$map 					= [];
+		if( $semester )			$map[] = ['orders_product.semester','LIKE','%'.$semester.'%'];
+		if( $contact_school )	$map[] = ['orders_addr.contact_school','LIKE','%'.$contact_school.'%'];
+		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];
+		// 查询数据
+		$list					= $OrdersProduct->query()
+									->join('custom','orders_product.custom_uid','=','custom.uid')
+									->join('orders_addr','orders_addr.order_id','=','orders_product.order_id')
+                                    ->where($map)
+                                    ->where([['orders_product.status','=',2]])
+                                    ->groupBy('orders_addr.contact_area','orders_addr.contact_school','orders_addr.contact_school','orders_addr.contact_grade','orders_addr.contact_class')
+									->select([
+										'orders_addr.contact_area','orders_addr.contact_school','orders_addr.contact_grade','orders_addr.contact_class','orders_product.semester','orders_product.id',
+                                        DB::raw('SUM(pay_total) as total'),DB::raw('SUM(buy_num) as buy_num_total'),
+									])
+									->paginate(request('limit',config('page_num',10)))->appends(request()->all());
+        //收款统计
+        $paymentList			 = $Model->query()
+            ->join('orders_addr','orders_addr.order_id','=','orders.id')
+            ->where($map)
+            ->where([['orders.status','=',2]])
+            ->select([
+                DB::raw('SUM(pay_total) as total'),DB::raw('COUNT(*) as pay_num_total'),
+            ])
+            ->get()
+            ->toArray();
+        //退款统计
+        $refundList			 = $Model->query()
+            ->join('orders_addr','orders_addr.order_id','=','orders.id')
+            ->where($map)
+            ->where([['orders.status','=',6]])
+            ->select([
+                DB::raw('SUM(pay_total) as total'),DB::raw('COUNT(*) as refund_num_total'),
+            ])
+            ->get()
+            ->toArray();
+		// 循环处理数据
+		/*foreach ($list as $key => $value) {
+			// id转编号
+			$value['order_code']	= $Model->idToCode($value['order_id']);
+			$value['custom_code']	= $Custom->idToCode($value['custom_uid']);
+			$value['state']			= $Model->getState($value['status'],'state');
+			$value['product_code']	= $value['product_id'] ? $Product->idToCode($value['product_id']) : '— —';
+			// 重组
+			$list[$key]				= $value;
+		}*/
+		// 分配数据
+		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
+		$this->assign('list', $list);
+		$this->assign('paymentList', $paymentList[0]);
+		$this->assign('refundList', $refundList[0]);
+		// 加载模板
+		return						$this->fetch();
+    }
+
+
+	/**
+	 * 首页列表
+	 * 
+	 * */
+    public function detail(Model $Model,AdminUser $AdminUser,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['admin_name']= $AdminUser->getOne($value['admin_uid'],'username');
+			$value['image']		= path_compat($value['image']);
+			$orderReceipt[$key] = $value;
+		}
+		// 积分
+		$score					= $orderReceipt ? max(array_column($orderReceipt,'give_score')) : 0;
+		// 恭喜
+		$shopName				= $orderAddr['contact_shop'] ? $orderAddr['contact_shop'] : $order['custom_name'];
+		// 结果
+		$shareImage				= $this->getShareImage($shopName,$score);
+		// 分配数据
+		$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);
+		$this->assign('shareImage', $shareImage);
+		// 加载模板
+		return						$this->fetch();
+    }
+
+
+	/**
+	 * 状态
+	 * 
+	 * */
+	public function set_status( Request $request, Model $Model,OrdersProduct $OrdersProduct,CustomScore $CustomScore){
+		// 验证参数
+		$request->scene('set_status')->validate();
+		// 接收参数
+		$id				= request('id',0);
+		$status			= request('status',0);
+		// 获取产品和数量
+		$oldData 		= $Model->query()->find($id,['id','order_score','custom_uid','insert_time']);
+		// 如果用户不存在
+		if( !$oldData )	return json_send(['code'=>'error','msg'=>'订单不存在']);
+		// 组合数据,写入订单表,子表
+		DB::beginTransaction();
+		try{
+			// 查询数据
+			$result			= $Model->setOrderStatus($id,$status,$OrdersProduct);
+			// 提示新增失败
+			if( isset($result['error']) )	{
+				// 回退数据
+				DB::rollBack();
+				// 提示信息
+				return		json_send(['code'=>'error','msg'=>$result['error'],'data'=>['error'=>$result['error']]]);
+			}
+			if( $status == 4 ){
+				// 取消积分
+				if( $oldData['order_score'] > 0 ) {
+					// 如果扣减失败
+					$result 	= $CustomScore->trade($oldData['custom_uid'],$oldData['id'],($oldData['order_score']*-1),6,1);
+					// 提示新增失败
+					if( isset($result['error']) )	{
+						// 回退数据
+						DB::rollBack();
+						// 提示信息
+						return json_send(['code'=>'error','msg'=>'取消赠送积分失败','data'=>['error'=>$result['error']]]);
+					}
+				}
+				// 取消关联订单
+				$result			= $Model->cancelRelate($oldData['insert_time'],$oldData['custom_uid'],$OrdersProduct,$CustomScore);
+				// 提示新增失败
+				if( isset($result['error']) )	{
+					// 回退数据
+					DB::rollBack();
+					// 提示信息
+					return		json_send(['code'=>'error','msg'=>'取消关联订单失败','data'=>['error'=>$result['error']]]);
+				}
+			}
+			// 提交数据
+			DB::commit();
+			// 告知结果
+			return			json_send(['code'=>'success','msg'=>'设置成功','path'=>'']);
+			// 返回结果
+		} catch (\Throwable $th) {
+			// 回退数据
+			DB::rollBack();
+			// 下单失败提示
+			return			json_send(['code'=>'error','msg'=>'设置失败','data'=>['error'=>$th->getMessage().$th->getLine()]]);
+		}
+	}
+	
+
+	/**
+	 * 表格导入
+	 * 
+	 * */
+	public function import_execl( Request $request,Model $Model,Custom $Custom,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct, FilesManager $FilesManager,CustomAddr $CustomAddr){
+		// 验证参数
+		$request->scene('import_execl')->validate();
+		// 获取表格信息
+		$file								= request()->file('order_file');
+		// 返回结果
+		$sheetList							= $FilesManager->excelToOrder($file);
+		// 如果不存在结果
+		if( isset($sheetList['error']) )	return json_send(['code'=>'error','msg'=>$sheetList['error']]);
+		// 订单列表
+		$orderList							= [];
+		// 当前时间
+		$time								= time();
+		// 循环表格数据
+		foreach ($sheetList as $value) 		{
+			// 状态更改
+			$value['status']				= $Model->getWeibanStatus($value['status']);
+			// 客户手机号
+			$orderList[$value['weizan_orderid']]['custom']				= ['phone'=>$value['contact_phone'],'username'=>$value['buyer_nick']];
+			// 组合成订单的收件地址
+			$orderList[$value['weizan_orderid']]['contact']				= [
+																			'contact_name'=>$value['contact_name'],
+																			'contact_phone'=>$value['contact_phone'],
+																			'contact_province'=>$value['contact_province'],
+																			'contact_city'=>$value['contact_city'],
+																			'contact_area'=>$value['contact_area'],
+																			'contact_addr'=>$value['contact_addr']
+																		];
+			
+			// 组合成订单的收件地址
+			$orderList[$value['weizan_orderid']]['product'][]			= [
+																			'status'=>$value['status'],
+																			'product_name'=>$value['product_name'],
+																			'sku_attr_names'=>$value['sku_attr_names'],
+																			'buy_num'=>$value['buy_num'],
+																			'pay_total'=>$value['pay_total'],
+																			'price_total'=>$value['pay_total'],
+																			'insert_time'=>$value['insert_time'],
+																			'update_time'=>$time,
+																		];
+			// 组合成订单的需要的数据
+			if( !isset($orderList[$value['weizan_orderid']]['order']) )	$orderList[$value['weizan_orderid']]['order'] = ['weizan_orderid'=>$value['weizan_orderid'],'status'=>$value['status'],'pay_total'=>0,'price_total'=>0,'insert_time'=>$value['insert_time']];
+			// 价格
+			$orderList[$value['weizan_orderid']]['order']['pay_total']  = $orderList[$value['weizan_orderid']]['order']['pay_total'] + $value['pay_total'];
+			$orderList[$value['weizan_orderid']]['order']['price_total']  = $orderList[$value['weizan_orderid']]['order']['pay_total'];
+		}
+		// 新增地址
+		$newAddrList						= [];
+		// 要更新的订单子表
+		$orderProduct						= [];
+		// 循环订单列表
+		foreach ($orderList as $value) 		{
+			// 获取手机号,查询是否用客户
+			$custom							= $Custom->getOneByPhone($value['custom']['phone']);
+			// 如果存在手机号
+			$uid							= $custom ? $custom['uid'] : $Custom->add($value['custom']);
+			// 如果客户存在
+			if( !$uid )						return json_send(['code'=>'error','msg'=>$value['custom']['username'].'【'.$value['custom']['phone'].'】'.'无法创建用户']);
+			// 通过订单号查询是否存在系统订单
+			$orderId						= $Model->query()->where([['weizan_orderid','=',$value['order']['weizan_orderid']]])->value('id');
+			// 客户ID
+			$value['order']['custom_uid'] 	= $uid;
+			// 存在订单获取订单ID,不存在则新增
+			$orderId						= $orderId ? $Model->edit($orderId,$value['order']) : $Model->add($value['order']);
+			// 如果客户存在
+			if( !$orderId )					return json_send(['code'=>'error','msg'=>$orderId.'订单写入失败']);
+			// 联系地址
+			$contact						= $value['contact'];
+			// 存在详细地址,才创建地址库
+			if( $contact['contact_name'] && $contact['contact_phone'] && $contact['contact_province'] && $contact['contact_city'] && $contact['contact_area'] && $contact['contact_addr'] )	{
+				// 收件地址是否存在
+				$oldAddr					= $CustomAddr->query()->where([['custom_uid','=',$uid]])->first();
+				// 如果不存在地址
+				if( !$oldAddr )				$CustomAddr->add(['custom_uid'=>$uid,'contact_name'=>$contact['contact_name'],'contact_phone'=>$contact['contact_phone'],'contact_province'=>$contact['contact_province'],'contact_city'=>$contact['contact_city'],'contact_area'=>$contact['contact_area'],'contact_addr'=>$contact['contact_addr']]);
+			}
+			// 订单地址库
+			$addrId							= $OrdersAddr->query()->where([['order_id','=',$orderId]])->value('id');
+			// 订单ID
+			$value['contact']['order_id']	= $orderId;
+			// 订单地址ID
+			$value['contact']['id'] 		= (int)$addrId;
+			// 不存在地址的话
+			$newAddrList[] 					= $value['contact'];
+			// 循环子订单
+			foreach ( $value['product'] as 	$product ) {
+				// 数据结果
+				$product['order_id']		= $orderId;
+				$product['custom_uid']		= $uid;
+				$product['id']				= (int) $OrdersProduct->query()->where([['order_id','=',$orderId],'product_name'=>$product['product_name'],'sku_attr_names'=>$product['sku_attr_names']])->value('id');
+				$orderProduct[]				= $product;
+			}
+		}
+		// 新地址写入
+		$OrdersProduct->query()->upsert($orderProduct,'id',['product_name','sku_attr_names','buy_num','pay_total','price_total','update_time']);
+		// 新地址写入
+		$OrdersAddr->query()->upsert($newAddrList,'id',['contact_name','contact_phone','contact_province','contact_city','contact_area','contact_addr']);
+		// 提示成功
+		return								json_send(['code'=>'success','msg'=>'订单导入成功','path'=>'']);
+	}
+
+	/**
+	 * 批量修改状态
+	 * 
+	 * */
+	public function import_execl_status( Request $request,Model $Model,OrdersProduct $OrdersProduct,FilesManager $FilesManager){
+		// 验证参数
+		$request->scene('import_execl_status')->validate();
+		// 获取表格信息
+		$file								= request()->file('order_file');
+		// 返回结果
+		$sheetList							= $FilesManager->excelToOrderStatus($file);
+		// 如果不存在结果
+		if( isset($sheetList['error']) )	return json_send(['code'=>'error','msg'=>$sheetList['error']]);
+		// 循环表格数据
+		foreach ($sheetList as $key=>$value) 		{
+			// 客户ID
+			$orderId						= $Model->codeToId($value['order_code']);
+			// 如果客户ID有误
+			if( !$orderId )					return json_send(['code'=>'error','msg'=>$value['order_code'].'编码有误']);
+			// 订单状态
+			$status							= $Model->getWeibanStatus($value['status']);
+			// 状态提示
+			if( $status < 0 )				return json_send(['code'=>'error','msg'=>$value['order_code'].'状态有误']);
+			// 修改数据
+			$result							= $Model->setOrderStatus($orderId,$status,$OrdersProduct);
+			// 提示
+			if( isset($result['error'])	)	return json_send(['code'=>'error','msg'=>$value['order_code'].$result['error']]);
+		}
+		// 提示成功
+		return								json_send(['code'=>'success','msg'=>'订单导入成功','path'=>'']);
+	}
+
+	/**
+	 * 导出表格导入
+	 * 
+	 * */
+	public function down_excel(Model $Model,OrdersProduct $OrdersProduct,Product $Product,Custom $Custom){
+		// 接受参数
+		$code					= request('order_code','');
+		$productCode			= request('product_code','');
+		$orders_other			= request('orders_other',0);
+		$customCode				= request('custom_code','');
+		$productName			= request('product_name','');
+		$phone					= request('phone','');
+		$province				= request('contact_province','');
+		$city					= request('contact_city','');
+		$area					= request('contact_area','');
+		$status					= request('status',0);
+		$startTime				= request('start_time','');
+		$endTime				= request('end_time','');
+		// 编码转ID
+		$id						= $code ? $Model->codeToId($code) : 0;
+		$productId				= $productCode ? $Product->codeToId($productCode) : 0;
+		$uid					= $customCode ? $Custom->codeToId($customCode) : 0;
+		// 查询条件
+		$map 					= [];
+		// 编码ID
+		if( $id )				$map[] = ['orders_product.order_id','=',$id];
+		if( $uid )				$map[] = ['custom.uid','=',$uid];
+		// 编码ID
+		if( $orders_other )		$map[] = $orders_other == 1 ? ['orders_product.product_id','>',0] : ['orders_product.product_id','=',0];
+		if( $productId )		$map[] = ['orders_product.product_id','=',$productId];
+		if( $productName )		$map[] = ['orders_product.product_name','=',$productName];
+		if( $phone )			$map[] = ['orders_addr.contact_phone','=',$phone];
+		if( $province )			$map[] = ['orders_addr.contact_province','LIKE','%'.$province.'%'];
+		if( $city )				$map[] = ['orders_addr.contact_city','LIKE','%'.$city.'%'];
+		if( $area )				$map[] = ['orders_addr.contact_area','LIKE','%'.$area.'%'];
+		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];
+		// 查询数据
+		$list					= $OrdersProduct->query()
+									->join('custom','orders_product.custom_uid','=','custom.uid')
+									->join('orders_addr','orders_addr.order_id','=','orders_product.order_id')
+									->where($map)
+									->orderByDesc('orders_product.id')
+									->select([
+										'orders_product.id as id',
+										'orders_product.order_id',
+										'orders_product.custom_uid',
+										'orders_product.product_id',
+										'orders_product.product_name',
+										'orders_product.sku_attr_names as product_spec',
+										'orders_product.product_thumb',
+										'orders_product.buy_num',
+										'orders_product.price_total',
+										'orders_product.coupon_total',
+										'orders_product.pay_total',
+										'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'
+									])->get()->toArray();
+		// 返回结果
+		$data						= [];
+		// 循环处理数据
+		foreach ($list as $value) {
+			// id转编号
+			$value['order_id']		= $Model->idToCode($value['order_id']);
+			$value['status']		= $Model->getState($value['status'],'state');
+			$value['custom_uid']	= $Custom->idToCode($value['custom_uid']);
+			$value['product_price']	= $value['buy_num'] ? ($value['price_total'] / $value['buy_num']) : $value['buy_num'];
+			$value['pay_price']		= $value['buy_num'] ? ($value['pay_total'] / $value['buy_num']) : $value['buy_num'];
+			// 重组
+			$data[$value['order_id']]['order_id'] = $value['order_id'];
+			$data[$value['order_id']]['custom_uid'] = $value['custom_uid'];
+			$data[$value['order_id']]['custom_name'] = $value['custom_name'];
+			$data[$value['order_id']]['weiban_extid'] = $value['weiban_extid'];
+			$data[$value['order_id']]['status'] = $value['status'];
+			$data[$value['order_id']]['insert_time'] = $value['insert_time'];
+			// 地址
+			$data[$value['order_id']]['contact_name'] = $value['contact_name'];
+			$data[$value['order_id']]['contact_phone'] = $value['contact_phone'];
+			$data[$value['order_id']]['contact_province'] = $value['contact_province'];
+			$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']]['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']];
+		}
+
+		try {
+			// 去下载
+			$this->toDown($data);
+		} catch (\Throwable $th) {
+			echo $th->getMessage();
+		}
+		
+	}
+
+
+	/**
+	 * 去下载
+	 */
+	private function  toDown($data){
+		// 创建新的电子表格对象
+		$spreadsheet			= new Spreadsheet();
+		// 设置合并单元格的行和列,例如合并A1到B2的单元格
+		$sheet					= $this->setStyle($spreadsheet);
+		// 从第二行写入
+		$row					= 2;
+		// 循环写入
+		foreach ($data as $key => $value) {
+			// 如果有多个商品
+			$count				= count($value['product']);
+			// 如果有多个商品
+			if( $count > 1 )	{
+				// 合并单元格
+				$sheet->mergeCells('A'.$row.':'.'A'.($row+$count-1));
+				$sheet->mergeCells('B'.$row.':'.'B'.($row+$count-1));
+				$sheet->mergeCells('C'.$row.':'.'C'.($row+$count-1));
+				$sheet->mergeCells('D'.$row.':'.'D'.($row+$count-1));
+				$sheet->mergeCells('E'.$row.':'.'E'.($row+$count-1));
+				$sheet->mergeCells('F'.$row.':'.'F'.($row+$count-1));
+				$sheet->mergeCells('G'.$row.':'.'G'.($row+$count-1));
+				$sheet->mergeCells('H'.$row.':'.'H'.($row+$count-1));
+				$sheet->mergeCells('I'.$row.':'.'I'.($row+$count-1));
+				$sheet->mergeCells('J'.$row.':'.'J'.($row+$count-1));
+				$sheet->mergeCells('R'.$row.':'.'R'.($row+$count-1));
+				$sheet->mergeCells('S'.$row.':'.'S'.($row+$count-1));
+			}
+			// 单元格内容写入
+			$sheet->setCellValue('A'.$row, $value['order_id']);
+			$sheet->setCellValue('B'.$row, $value['custom_uid']);
+            //避免 = + - 识别成公式
+            $sheet->setCellValueExplicit('C'.$row, $value['custom_name'],DataType::TYPE_STRING);
+			$sheet->setCellValue('D'.$row, $value['status']);
+			$sheet->setCellValue('E'.$row, $value['contact_name']);
+			$sheet->setCellValue('F'.$row, $value['contact_phone']);
+			$sheet->setCellValue('G'.$row, $value['contact_province']);
+			$sheet->setCellValue('H'.$row, $value['contact_city']);
+			$sheet->setCellValue('I'.$row, $value['contact_area']);
+			$sheet->setCellValue('J'.$row, $value['contact_addr']);
+			$sheet->setCellValue('S'.$row, $value['weiban_extid']);
+			$sheet->setCellValue('T'.$row, date('Y-m-d H:i:s',$value['insert_time']));
+			// 循环产品
+			foreach ($value['product'] as $v) {
+				$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']);
+				// 函数自增
+				$row++;
+			}
+		}
+		// 
+		// 创建内容
+		$writer 				= IOFactory::createWriter($spreadsheet, 'Xlsx');
+		header('Pragma: public');
+		header('Content-type:application/vnd.ms-excel');
+		header('Content-Disposition: inline;filename=下载订单.xlsx');
+		// 输出数据流
+		return $writer->save('php://output');
+	}
+
+	/**
+	 * 设置表格样式
+	 * 
+	 */
+	private function setStyle(Spreadsheet $spreadsheet){
+		// 选择当前活动的工作表
+		$sheet					= $spreadsheet->getActiveSheet();
+		// 宽
+		$sheet->getColumnDimension('A')->setWidth(15);
+		$sheet->getColumnDimension('B')->setWidth(15);
+		$sheet->getColumnDimension('C')->setWidth(15);
+		$sheet->getColumnDimension('D')->setWidth(15);
+		$sheet->getColumnDimension('E')->setWidth(15);
+		$sheet->getColumnDimension('F')->setWidth(15);
+		$sheet->getColumnDimension('G')->setWidth(15);
+		$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('M')->setWidth(80);
+		$sheet->getColumnDimension('N')->setWidth(10);
+		$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->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
+		->setCellValue('A1', '订单ID')
+		->setCellValue('B1', '客户ID')
+		->setCellValue('C1', '客户昵称')
+		->setCellValue('D1', '订单状态')
+		->setCellValue('E1', '收货人')
+		->setCellValue('F1', '收货人手机号')
+		->setCellValue('G1', '省')
+		->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', '下单时间');
+		// 返回结果
+		return 					$sheet;
+	}
+
+	/**
+	 * 分享图片
+	 * 
+	 */
+	private function getShareImage($shopName,$score=0){
+		// 尝试执行
+		try {
+			// 加载图片
+			$image		= Image::make(public_path('uploads/images/default/').'order_receipt_share.jpg');
+			// 加载图片
+			$qrcode		= Image::make(public_path('uploads/images/default/').'mp_qrcode.jpg')->resize(100,100);
+			// 设置文字样式(字体、大小、颜色等)
+			$fontPath	= public_path().'/fonts/msyh14.ttf';// 指定字体文件路径
+			// 文本
+			$score 		= $score ? '即将获得'.$score.'积分' : '';
+
+			// 给图片写入文字
+			$image->text('恭喜 '.$shopName, 240,60,function (Font $font) use ($fontPath) {
+				$font->file($fontPath);		// 字体文件地址
+				$font->size(24);			// 字体大小
+				$font->color('#FFFFFF');
+				$font->align('center');
+			});
+
+			// 给图片写入文字
+			$image->text('完成了一笔订单', 240,100,function (Font $font) use ($fontPath) {
+				$font->file($fontPath);		// 字体文件地址
+				$font->size(24);			// 字体大小
+				$font->color('#FFFFFF');
+				$font->align('center');
+			});
+			// 是否有积分
+			if( $score ){
+				// 给图片写入文字
+				$image->text($score, 240,140,function (Font $font) use ($fontPath) {
+					$font->file($fontPath);		// 字体文件地址
+					$font->size(24);			// 字体大小
+					$font->color('#FFFFFF');
+					$font->align('center');
+				});
+			}
+			// 给图片写入文字
+			$image->text('你也来试试吧', 240,$score?180:140,function (Font $font) use ($fontPath) {
+				$font->file($fontPath);		// 字体文件地址
+				$font->size(24);			// 字体大小
+				$font->color('#FFFFFF');
+				$font->align('center');
+			});
+			// 插入图片
+			$image->insert($qrcode,'bottom-right',10,10);
+			// 转码成字符串
+			$image		= $image->encode('jpg', 90)->__toString();
+			// 转base64
+			$base64		= 'data:image/jpg;base64,' . base64_encode($image);
+
+			return		$base64;
+		} catch (\Throwable $th) {
+			// 返回路径
+			return 			'';
+		}
+	}
+
+}

+ 17 - 1
app/Http/Controllers/Api/Product.php

@@ -1,5 +1,6 @@
 <?php namespace App\Http\Controllers\Api;
 
+use App\Http\Controllers\Admin\ProductType;
 use App\Http\Controllers\Api\Api;
 use App\Http\Requests\Api\Product as Request;
 use App\Models\Business;
@@ -16,6 +17,7 @@ use App\Models\PromoRebate;
 use App\Models\RegimentActive;
 use App\Models\Regiment;
 use App\Models\WeiBan\Tags as WeiBanTags;
+use App\Models\Product\Type;
 
 /**
  * 产品接口
@@ -359,6 +361,20 @@ class Product extends Api{
 		// 返回结果
 		return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$data]);
 	}
-
+    /**
+     * 获取产品类型列表		 /api/product/get_type
+     *
+     *
+     * */
+    public function get_type(Request $request,Type $ProductType){
+        // 接口验签
+        // $this->verify_sign();
+        // 检查登录
+        $uid						= $this->checkLogin();
+        // 获取产品类型
+        $list						= $ProductType->getList();
+        // 返回结果
+        return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
+    }
 
 }

+ 104 - 0
app/Http/Controllers/Api/WechatPay.php

@@ -249,5 +249,109 @@ class WechatPay extends Api{
         }
     }
 
+    /**
+     * 小程序微信支付 退款回调				/api/wechat_pay/refund_notify
+     *
+     * */
+    public function refund_notify(Custom $Custom,CustomScore $CustomScore)
+    {
+        $content = file_get_contents("php://input");
+        if (!empty($content)) {
+            //直接json字符串
+            $params = $content;
+        } elseif (!empty($_POST)) {
+            //直接POST数据
+            $params = $_POST;
+        } else {
+            $params = [];
+        }
+        $post_data = $params;
+        Log::log('notify_refund_wechat_pay', 'post_data:' . $post_data);
+        //获取headers参数
+        $headers = request()->header();
+        Log::log('notify_refund_wechat_pay', '微信支付回调返回headers参数:' . json_encode($headers));
 
+        $inWechatpaySignature = $headers['wechatpay-signature'][0];
+        $inWechatpayTimestamp = $headers['wechatpay-timestamp'][0];
+        $inWechatpaySerial = $headers['wechatpay-serial'][0];
+        $inWechatpayNonce = $headers['wechatpay-nonce'][0];
+        $inBody = $post_data;
+        Log::log('notify_refund_wechat_pay', 'wechatpay-timestamp:' . $inWechatpayTimestamp);
+        $apiv3Key = Config('notify_refund_wechat_pay.APIV3');// 在商户平台上设置的APIv3密钥
+        // 根据通知的平台证书序列号,查询本地平台证书文件,
+        $platformCertificateFilePath = Config('wechatpay.platformCertificate');
+        $platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
+        try {
+            // 检查通知时间偏移量,允许5分钟之内的偏移
+            $timeOffsetStatus = 300 >= abs(Formatter::timestamp() - (int)$inWechatpayTimestamp);
+            Log::log('notify_wechat_pay', '时间偏移量:' . $timeOffsetStatus);
+            $verifiedStatus = Rsa::verify(
+            // 构造验签名串
+                Formatter::joinedByLineFeed($inWechatpayTimestamp, $inWechatpayNonce, $inBody),
+                $inWechatpaySignature,
+                $platformPublicKeyInstance
+            );
+        }catch (\Exception $e){
+            Log::log('notify_refund_wechat_pay', '错误getMessage:' . $e->getMessage());
+        }
+        Log::log('notify_refund_wechat_pay', '验签:' . $verifiedStatus.'验签inWechatpayTimestamp:' . $inWechatpayTimestamp.'验签verifiedStatus:' . $inWechatpayNonce);
+        if ($timeOffsetStatus && $verifiedStatus) {
+            // 转换通知的JSON文本消息为PHP Array数组
+            $inBodyArray = (array)json_decode($inBody, true);
+            // 使用PHP7的数据解构语法,从Array中解构并赋值变量
+            ['resource' => [
+                'ciphertext' => $ciphertext,
+                'nonce' => $nonce,
+                'associated_data' => $aad
+            ]] = $inBodyArray;
+            // 加密文本消息解密
+            $inBodyResource = AesGcm::decrypt($ciphertext, $apiv3Key, $nonce, $aad);
+            // 把解密后的文本转换为PHP Array数组
+            $inBodyResourceArray = (array)json_decode($inBodyResource, true);
+            Log::log('notify_refund_wechat_pay', '打印解密后的结果:' . json_encode($inBodyResourceArray));
+            Log::log('notify_refund_wechat_pay', '参数:' . $inBodyResourceArray['trade_state'] . '订单号' . $inBodyResourceArray['out_trade_no'] . '微信支付号' . $inBodyResourceArray['transaction_id']);
+            if ($inBodyResourceArray['refund_status'] == "SUCCESS") {
+                Log::log('notify_refund_wechat_pay', '通知订单');
+                $orderInfo   = Orders::query()->where('snowflake_id','=',$inBodyResourceArray['out_trade_no'])->first()->toArray();
+                $status      =  6;
+                //更新订单支付状态
+                $orderData = [
+                    'status'=>$status,
+                ];
+                // 组合数据,写入订单表,子表
+                DB::beginTransaction();
+                try {
+                    $res = Orders::query()->where('snowflake_id','=',$inBodyResourceArray['out_trade_no'])->update($orderData);
+                    Log::log('notify_refund_wechat_pay', '更新订单,snowflake_id:'.$inBodyResourceArray['out_trade_no'].';'. json_encode($res));
+                    if (!$res) {
+                        // 回退数据
+                        DB::rollBack();
+                        Log::log('notify_refund_wechat_pay', '更新订单失败' . json_encode($res));
+                        return json_send(['code'=>'FAIL']);
+                    }
+                    //更新子订单
+                    $res         =  OrdersProduct::query()->where('order_id','=',$orderInfo['id'])->update(['status'=>$status]);
+                    Log::log('notify_refund_wechat_pay', '更新子订单,order_id:'.$orderInfo['id'].';'. json_encode($res));
+                    if (!$res) {
+                        Log::log('notify_refund_wechat_pay', '更新子订单失败:'.$orderInfo['id'].':'.$status . json_encode($res));
+                        // 回退数据
+                        DB::rollBack();
+                        return json_send(['code'=>'FAIL']);
+                    }
+                    // 提交数据
+                    DB::commit();
+                }catch (\Exception $e){
+                    Log::log('notify_refund_wechat_pay', '更新订单失败' . json_encode($e));
+                    return json_send(['code'=>'FAIL']);
+                }
+                $orderInfo   = Orders::query()->where('snowflake_id','=',$inBodyResourceArray['out_trade_no'])->first()->toArray();
+                Log::log('notify_refund_wechat_pay', '支付回调完成 通知返回' . json_encode($orderInfo));
+                return json_send(['code'=>'SUCCESS']);
+
+            }
+            return json_send(['code'=>'SUCCESS']);
+        }else{
+            return json_send(['code'=>'FAIL']);
+        }
+    }
 }

+ 2 - 1
app/Http/Requests/Admin/Orders.php

@@ -32,7 +32,8 @@ class Orders extends BaseRequest
         'edit'                  => ['id','product_code'],
         'set_status'            => ['id','status'],
         'import_execl'          => ['order_file'],
-        'import_execl_status'   => ['order_file']
+        'import_execl_status'   => ['order_file'],
+        'refund'                => ['id'],
 	];
 
     /**

+ 2 - 2
app/Models/Traits/Orders/Status.php

@@ -17,8 +17,8 @@ trait Status
                                         'state'         =>'待支付',
                                     ],'2'=>[
                                         'id'            =>2,
-                                        'name'          =>'已付款待上课',// 已付款待上课
-                                        'state'         =>'待上课',
+                                        'name'          =>'已付款',// 已付款待上课
+                                        'state'         =>'已付款',
                                     ],'3'=>[
                                         'id'            =>3,
                                         'name'          =>'已上课未上完',// 已上课未上完

+ 11 - 10
app/Servers/WechatPay/Payment.php

@@ -68,8 +68,8 @@ class Payment
                     /*'time_expire'  => $this->timestampToRfc3339(time() + env('ORDER_OUT_TIME')*60),*/
                     'notify_url'   => env('APP_URL').'/api/wechat_pay/notify',
                     'amount'       => [
-                        'total'    => 1,
-                        //'total'    => $params['total_price']*100,
+                        //'total'    => 1,
+                        'total'    => $params['total_price']*100,
                         'currency' => 'CNY'
                     ],
                     'payer'        => [
@@ -130,24 +130,25 @@ class Payment
             $resp = $this->instance
                 ->chain('v3/refund/domestic/refunds')
                 ->post(['json' => [
-                    'transaction_id'  => $params['transaction_id'],
+                    'out_trade_no'      => $params['out_trade_no'],
                     'out_refund_no'   => $params['out_refund_no'],
-                    'reason'          => $params['reason'] ?? '',
-                    'notify_url'      => $notify_url,
+                    'reason'          => $params['reason'] ?? '用户退款',
+                    'notify_url'      => env('APP_URL').'/api/wechat_pay/refund_notify',
                     'amount'          => [
-                        'refund'      => $params['refund'],
-                        'total'       => $params['total'],
+                        'refund'      => $params['refund'] * 100,
+                        'total'       => $params['total'] * 100,
                         'currency'    => 'CNY'
                     ],
                 ]]);
+            $result = json_decode($resp->getBody(),true);
         } catch (\Exception $e) {
             if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
                 $r = $e->getResponse();
-                Log::error('wechat/Payment','订单微信退款,出现错误'.$r->getBody());
+                Log::error('wechat/payment_refund','订单微信退款,出现错误'.$r->getBody());
             }
-            return response()->json(['error' => '订单微信退款失败'], 500);
+            return false;
         }
-        return response()->json($resp);
+        return true;
     }
     //Rfc3339时间日期格式
     public function timestampToRfc3339($timestamp)

+ 13 - 2
resources/views/admin/orders/index.blade.php

@@ -87,7 +87,10 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>成交总价</th>
 						<th>收货人</th>
 						<th>联系方式</th>
-						<th>收货地址</th>
+						<th>区域</th>
+						<th>学校</th>
+						<th>年级</th>
+						<th>班级</th>
 						<th>订单状态</th>
 						<th>下单时间</th>
 						<th>操作</th>
@@ -106,7 +109,10 @@ 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_area']}}</td>
+						<td>{{$a['contact_school']}}</td>
+						<td>{{$a['contact_grade']}}</td>
+						<td>{{$a['contact_class']}}</td>
 						<td>{{$a['state']}}</td>
 						<td>{{date('Y-m-d H:i:s',$a['insert_time'])}}</td>
 						<td>
@@ -126,6 +132,11 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 								取消
 							</a>
 							@endif
+							@if( $a['status'] == 2 && check_auth('admin/orders/refund') )
+								<a class="delete btn btn-sm btn-danger " data-url="{{url('admin/orders/refund?'.http_build_query(['id'=>$a['order_id']]))}}" title="退款">
+									退款
+								</a>
+							@endif
 						</td>
 					</tr>
 					@endforeach

+ 170 - 0
resources/views/admin/orders_class_summary/index.blade.php

@@ -0,0 +1,170 @@
+@extends('admin.public.base')
+@section('body_class')
+style="margin: 0 auto;width: 96%;padding: 30px 0px;"
+@endsection
+@section('content')
+
+<form action="" method="get" name="thisform" class="form-horizontal form-line">
+
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="semester" value="{{request('semester','')}}" placeholder="请输入学期" />
+	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="contact_school" value="{{request('contact_school','')}}" placeholder="请输入学校" />
+	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="start_time" value="{{request('start_time','')}}" placeholder="请输入开始时间查询" />
+	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-12" style="margin-right: 2px;">
+		<input type="text" class="form-control" name="end_time" value="{{request('end_time','')}}" placeholder="请输入结束时间查询" />
+	</div>
+	<div class="form-group col col-xs-4 col-md-2" style="margin-right: 2px;">
+		<button type="button" onclick="alter_from_attr({'method':'get','action':''})" class="btn btn-sm btn-primary" style="margin-right: 20px;"> 查询</button>
+		<a href="{{url('admin/orders/index')}}" class="btn btn-sm btn-default" style="margin-right: 20px;" >重置</a>
+		@if( check_auth('admin/orders/down_excel') )
+		<button type="button" onclick="alter_from_attr({'method':'get','action':`{{url('admin/orders/down_excel')}}`})" class="btn btn-sm btn-primary"> 下载表格</button>
+		@endif
+	</div>
+	@csrf
+</form>
+<div class="col-xs-12">收款{{$paymentList && $paymentList['pay_num_total'] ? $paymentList['pay_num_total'] : 0}}笔,收款{{$paymentList&&$paymentList['total'] ? $paymentList['total'] : 0}}元; 退款{{$refundList&&$refundList['refund_num_total'] ? $refundList['refund_num_total'] : 0}}笔,退款{{$refundList && $refundList['total'] ? $refundList['total'] : 0}}元;</div>
+<div class="row">
+	<div class="col-xs-12">
+		<div class="table-responsive">
+			<table class="table table-striped table-bordered table-hover">
+				<thead>
+					<tr>
+						<th>序号</th>
+						<th>学期</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['semester']}}</td>
+						<td>{{$a['contact_area']}}</td>
+						<td>{{$a['contact_school']}}</td>
+						<td>{{$a['contact_grade']}}</td>
+						<td>{{$a['contact_class']}}</td>
+						<td>{{$a['buy_num_total']}}</td>
+						<td>¥{{$a['total']}}</td>
+					</tr>
+					@endforeach
+					<tr>
+						<td colspan="20" class="page">{{$list->render()}}</td>
+					</tr>
+					<tr>
+						<td colspan="20">总计 {{$list->total()}} 个订单</td>
+					</tr>
+				</tbody>
+
+			</table>
+		</div>
+	</div>
+</div>
+@endsection
+@section('javascript')
+<script src="/static/fileupload/jquery.ui.widget.js"></script>
+<script src="/static/fileupload/jquery.fileupload.js"></script>
+<script type="text/javascript">
+ $(function(){
+	$('.upload').on('click', function() {
+		$('#form-upload').remove();
+		$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_file" type="file" name="order_file" multiple="multiple" /></form>');
+		$('#form-upload input[name=\'order_file\']').trigger('click');
+		$('[osctype="btn_upload_file"]').fileupload({
+			dataType: 'json',
+			url: "{{url('admin/orders/import_execl')}}",
+			singleFileUploads: false,
+			beforeSend: function() {
+				art.dialog({
+					id: 'loading',
+					lock: true,
+					title: '文件上传中'
+				});
+			},
+			done: function(e, data) {
+				art.dialog.list['loading'].close();
+				var result = data.result;
+				if (result.code == 'error') {
+					art.dialog({
+						content: result.msg,
+						lock: true,
+						ok: function() {}
+					});
+				}
+				if (result.code == 'success') {
+					art.dialog({
+						content: result.msg,
+						lock: true,
+						ok: function() {
+							location.reload();
+						}
+					});
+				}
+			},
+			fail: function(e,c) {
+				art.dialog.list['loading'].close();
+				art.dialog({
+					content: '<p>'+c.jqXHR.status+'=>'+c.jqXHR.statusText+'</p>',
+					lock: true,
+					ok: function() {}
+				});
+			}
+		});
+	});
+	$('.upload_status').on('click', function() {
+		$('#form-upload').remove();
+		$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_file" type="file" name="order_file" multiple="multiple" /></form>');
+		$('#form-upload input[name=\'order_file\']').trigger('click');
+		$('[osctype="btn_upload_file"]').fileupload({
+			dataType: 'json',
+			url: "{{url('admin/orders/import_execl_status')}}",
+			singleFileUploads: false,
+			beforeSend: function() {
+				art.dialog({
+					id: 'loading',
+					lock: true,
+					title: '文件上传中'
+				});
+			},
+			done: function(e, data) {
+				art.dialog.list['loading'].close();
+				var result = data.result;
+				if (result.code == 'error') {
+					art.dialog({
+						content: result.msg,
+						lock: true,
+						ok: function() {}
+					});
+				}
+				if (result.code == 'success') {
+					art.dialog({
+						content: result.msg,
+						lock: true,
+						ok: function() {
+							location.reload();
+						}
+					});
+				}
+			},
+			fail: function(e,c) {
+				art.dialog.list['loading'].close();
+				art.dialog({
+					content: '<p>'+c.jqXHR.status+'=>'+c.jqXHR.statusText+'</p>',
+					lock: true,
+					ok: function() {}
+				});
+			}
+		});
+	});
+ })
+</script>
+@endsection

+ 5 - 0
routes/api.php

@@ -214,6 +214,8 @@ Route::any('course/cancel_reservation',[\App\Http\Controllers\Api\Course::class,
 Route::any('wechat_pay/pay',[\App\Http\Controllers\Api\WechatPay::class,'pay']);
 // 微信支付回调
 Route::any('wechat_pay/notify',[\App\Http\Controllers\Api\WechatPay::class,'notify']);
+// 微信支付  退款回调
+Route::any('wechat_pay/refund_notify',[\App\Http\Controllers\Api\WechatPay::class,'refund_notify']);
 
 // 学校列表
 Route::any('school/get_list',[\App\Http\Controllers\Api\School::class,'get_list']);
@@ -228,3 +230,6 @@ Route::any('student_addr/del',[\App\Http\Controllers\Api\StudentAddr::class,'del
 Route::any('student_addr/get_list',[\App\Http\Controllers\Api\StudentAddr::class,'get_list']);
 // 列表
 Route::any('student_addr/set_default',[\App\Http\Controllers\Api\StudentAddr::class,'set_default']);
+
+// 产品类型列表
+Route::any('product/get_type',[\App\Http\Controllers\Api\Product::class,'get_type']);

+ 7 - 1
routes/web.php

@@ -20,7 +20,7 @@ Route::any('/',function () {
     // 从缓存获取
     $link                       = cache('redirect_mini_url','');
     // 跳转链接
-    $link						= $link ? '' : Mini::getUrlLink('pages/index/index');
+    $link						= $link ? $link : Mini::getUrlLink('pages/index/index');
     // 时间
     if( $link )                 cache(['redirect_mini_url'=>$link],now()->addDays(20));
     // 跳转
@@ -191,6 +191,8 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     Route::any('orders/down_excel',[App\Http\Controllers\Admin\Orders::class,'down_excel']);
     // 订单批量更新状态
     Route::any('orders/import_execl_status',[App\Http\Controllers\Admin\Orders::class,'import_execl_status']);
+    // 退款
+    Route::any('orders/refund',[App\Http\Controllers\Admin\Orders::class,'refund']);
 
     /* 订单物流-发货 */
     // 列表
@@ -610,4 +612,8 @@ Route::middleware('admin')->prefix('admin')->group(function(){
     // 状态
     Route::any('school/set_status',[App\Http\Controllers\Admin\School::class,'set_status']);
 
+    /* 订单管理 班级汇总 */
+    // 列表
+    Route::any('orders_class_summary/index',[App\Http\Controllers\Admin\OrdersClassSummary::class,'index']);
+
 });