|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
use App\Http\Requests\Admin\Orders as Request;
|
|
|
use App\Models\Custom;
|
|
|
+use App\Models\CustomAddr;
|
|
|
use App\Models\FilesManager;
|
|
|
use App\Models\Product;
|
|
|
use App\Models\Orders as Model;
|
|
@@ -120,7 +121,7 @@ class Orders extends Auth{
|
|
|
* 表格导入
|
|
|
*
|
|
|
* */
|
|
|
- public function import_execl( Request $request,Model $Model,Custom $Custom,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct, FilesManager $FilesManager){
|
|
|
+ public function import_execl( Request $request,Model $Model,Custom $Custom,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct, FilesManager $FilesManager,CustomAddr $CustomAddr){
|
|
|
// 验证参数
|
|
|
$request->scene('import_execl')->validate();
|
|
|
// 获取表格信息
|
|
@@ -186,11 +187,20 @@ class Orders extends Auth{
|
|
|
$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
|
|
|
+ // 订单地址ID
|
|
|
$value['contact']['id'] = (int)$addrId;
|
|
|
// 不存在地址的话
|
|
|
$newAddrList[] = $value['contact'];
|