|
@@ -2,10 +2,19 @@
|
|
|
|
|
|
namespace App\Imports;
|
|
namespace App\Imports;
|
|
|
|
|
|
-use App\Order;
|
|
|
|
|
|
+use App\Models\Docter;
|
|
|
|
+use App\Models\Order;
|
|
|
|
+use App\Models\OrderPatient;
|
|
|
|
+use App\Models\Organization;
|
|
|
|
+use App\Models\Patient;
|
|
|
|
+use App\User;
|
|
use Maatwebsite\Excel\Concerns\ToModel;
|
|
use Maatwebsite\Excel\Concerns\ToModel;
|
|
|
|
+use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
|
|
+use Maatwebsite\Excel\Concerns\WithBatchInserts;
|
|
|
|
+use Maatwebsite\Excel\Concerns\WithChunkReading;
|
|
|
|
+use Maatwebsite\Excel\Concerns\WithProgressBar;
|
|
|
|
|
|
-class chatOrder implements ToModel
|
|
|
|
|
|
+class chatOrder implements ToModel,WithBatchInserts,WithChunkReading
|
|
{
|
|
{
|
|
/**
|
|
/**
|
|
* @param array $row
|
|
* @param array $row
|
|
@@ -14,10 +23,83 @@ class chatOrder implements ToModel
|
|
*/
|
|
*/
|
|
public function model(array $row)
|
|
public function model(array $row)
|
|
{
|
|
{
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if($row[0] == '订单编号') return '';
|
|
|
|
+ [
|
|
|
|
+ 0 => "im20210118173813522",
|
|
|
|
+ 1 => "云南运营主体",
|
|
|
|
+ 2 => "熊振宇",
|
|
|
|
+ 3 => "13708872753",
|
|
|
|
+ 4 => "文菊焱",
|
|
|
|
+ 5 => "",
|
|
|
|
+ 6 => "云南省昆明市昆明市盘龙区联盟街道金康园社区卫生服务站",
|
|
|
|
+ 7 => "妇保科",
|
|
|
|
+ 8 => "否",
|
|
|
|
+ 9 => "进行中",
|
|
|
|
+ 10 => "",
|
|
|
|
+ 11 => "否",
|
|
|
|
+ 12 => "1.99",
|
|
|
|
+ 13 => "0.00",
|
|
|
|
+ 14 => "1.99",
|
|
|
|
+ 15 => "1.99",
|
|
|
|
+ 16 => "微信支付",
|
|
|
|
+ 17 => "单次图文咨询",
|
|
|
|
+ 18 => "已付款",
|
|
|
|
+ 19 => "2021-01-18 17:38:13",
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $patient_id = $this->getValue(new Patient(),['name'=>$row[2]],'id');
|
|
|
|
+ $user_id = $this->getValue(new User(),['phone'=>$row[3]],'id');
|
|
|
|
+ $docter_id = $this->getValue(new Docter(),['name'=>$row[4]],'id');
|
|
|
|
+ $org_id = $this->getValue(new Organization(),['name'=>$row[6]],'id');
|
|
|
|
+ $order_status = $row[9];
|
|
|
|
+ $evaluate = $row[10] == '已评价'? 1 : 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// 14
|
|
|
|
+ $orderInfo = [
|
|
|
|
+ 'order_sn'=>$row[0],
|
|
|
|
+ 'patient_id'=>$patient_id,
|
|
|
|
+ 'user_id'=>$user_id,
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'order_status'=>$order_status,
|
|
|
|
+ 'organization_id'=>$org_id,
|
|
|
|
+ 'is_evaluate'=>$evaluate,
|
|
|
|
+ 'is_discount'=>$row[11],
|
|
|
|
+ 'total_amount'=>$row[12],
|
|
|
|
+ 'discount_amount'=>$row[13],
|
|
|
|
+ 'payment_amount'=>$row[15],
|
|
|
|
+ 'payment_type'=>$row[16],
|
|
|
|
+ 'payment_status'=>$row[18],
|
|
|
|
+ 'created_at'=>$row[19],
|
|
|
|
+ ];
|
|
|
|
+ dd($orderInfo);
|
|
//处理逻辑
|
|
//处理逻辑
|
|
- dd($row);
|
|
|
|
return new Order([
|
|
return new Order([
|
|
//
|
|
//
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function startRow(): int
|
|
|
|
+ {
|
|
|
|
+ return 2;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function batchSize(): int
|
|
|
|
+ {
|
|
|
|
+ return 1000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function chunkSize(): int
|
|
|
|
+ {
|
|
|
|
+ return 1000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getValue($model,$where,$field)
|
|
|
|
+ {
|
|
|
|
+ return $model->where($where)->value($field);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|