|
|
@ -4,9 +4,13 @@ namespace App\Http\Controllers\Api; |
|
|
use App\Http\Controllers\Controller; |
|
|
use App\Http\Controllers\Controller; |
|
|
use App\Models\Agent; |
|
|
use App\Models\Agent; |
|
|
use App\Models\Order; |
|
|
use App\Models\Order; |
|
|
|
|
|
use App\Models\Supplier; |
|
|
use App\Models\Product; |
|
|
use App\Models\Product; |
|
|
|
|
|
use App\Models\OrderProductItem; |
|
|
use App\Models\User; |
|
|
use App\Models\User; |
|
|
use App\Common\OrderStatus; |
|
|
use App\Common\OrderStatus; |
|
|
|
|
|
use App\Service\SmsService; |
|
|
|
|
|
use App\Traits\SmsTraits; |
|
|
use EasyWeChat\Factory; |
|
|
use EasyWeChat\Factory; |
|
|
use Illuminate\Support\Facades\Storage; |
|
|
use Illuminate\Support\Facades\Storage; |
|
|
|
|
|
|
|
|
@ -22,9 +26,8 @@ class VerificationController extends Controller |
|
|
return $this->error('参数错误'); |
|
|
return $this->error('参数错误'); |
|
|
} |
|
|
} |
|
|
list($id, $verify_code) = $code_arr; |
|
|
list($id, $verify_code) = $code_arr; |
|
|
|
|
|
|
|
|
$order = Order::with('agentProduct:id,verifier') |
|
|
|
|
|
->where(['agent_id' => $this->agent_id, 'verify_code' => $verify_code]) |
|
|
|
|
|
|
|
|
$order = Order::with(['agentProduct:id,verifier','user','agent']) |
|
|
|
|
|
->where(['verify_code' => $verify_code]) |
|
|
->whereIn('status', [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID]) |
|
|
->whereIn('status', [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID]) |
|
|
->find($id); |
|
|
->find($id); |
|
|
if (!$order) { |
|
|
if (!$order) { |
|
|
@ -39,7 +42,17 @@ class VerificationController extends Controller |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$order->status = OrderStatus::SUCCESS; |
|
|
$order->status = OrderStatus::SUCCESS; |
|
|
$order->save(); |
|
|
|
|
|
|
|
|
if ($order->save()) { |
|
|
|
|
|
if(env('SMS_SWITCH','') == true) { |
|
|
|
|
|
if (!empty($order->user->mobile)) { |
|
|
|
|
|
(new SmsService)->send('verify', [$order->order_no,SmsTraits::$systeaNameText['user']], [$order->user->mobile]);//用户
|
|
|
|
|
|
} |
|
|
|
|
|
$supplierIds = OrderProductItem::query()->with('supplier')->where('order_id',$order->id)->distinct()->pluck('supplier_id'); |
|
|
|
|
|
$phone = Supplier::query()->whereIn('id',$supplierIds)->pluck('contact_phone')->toArray(); |
|
|
|
|
|
(new SmsService)->send('verify', [$order->order_no,SmsTraits::$systeaNameText['supplier']], $phone);//供应商
|
|
|
|
|
|
(new SmsService)->send('verify', [$order->order_no,SmsTraits::$systeaNameText['agent']], [$order->agent->contact_phone]);//代理商
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $this->success(); |
|
|
return $this->success(); |
|
|
} |
|
|
} |
|
|
|