Browse Source

行业产品订单核销

master
李可松 4 years ago
parent
commit
1c426a482c
  1. 52
      app/Http/Controllers/Api/VerificationController.php
  2. 2
      routes/api.php

52
app/Http/Controllers/Api/VerificationController.php

@ -7,35 +7,36 @@ use App\Common\StatementType;
use App\Http\Controllers\Controller;
use App\Models\Agent;
use App\Models\Guide;
use App\Models\IndustryOrder;
use App\Models\Order;
use App\Models\Supplier;
use App\Models\Product;
use App\Models\OrderProductItem;
use App\Models\User;
use App\Common\OrderStatus;
use App\Service\SmsService;
use App\Service\WithdrawalService;
use App\Traits\DemandTraits;
use App\Traits\SmsTraits;
use App\Traits\StatementTraits;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
/**
* 订单核销
* Class VerificationController
* @package App\Http\Controllers\Api
*/
class VerificationController extends Controller
{
//核销订单
//核销小程序订单
public function verify()
{
$input_verify_code = request()->input('verify_code'); //订单ID
$input_verify_code = request()->input('verify_code'); //核销码
$code_arr = explode('-', $input_verify_code);
if (count($code_arr) != 2) {
return $this->error('参数错误');
}
list($id, $verify_code) = $code_arr;
$order = Order::with(['agentProduct:id,verifier', 'user', 'agent', 'guide'])
->where(['verify_code' => $verify_code])
$order = Order::where(['verify_code' => $verify_code])
->whereIn('status', [OrderStatus::PAID, OrderStatus::PAID_RETAINAGE, OrderStatus::OFFLINE_PAID, OrderStatus::REFUSED_REFUND])
->find($id);
if (!$order) {
@ -62,6 +63,41 @@ class VerificationController extends Controller
return $this->success();
}
//行业产品订单核销
public function industry_verify()
{
$input_verify_code = request()->input('verify_code'); //核销码
$code_arr = explode('-', $input_verify_code);
if (count($code_arr) != 2) {
return $this->error('参数错误');
}
list($id, $verify_code) = $code_arr;
$order = IndustryOrder::with('industryProduct:id,verify_mobile')
->where(['status' => OrderStatus::OFFLINE_PAID, 'verify_code' => $verify_code])->find($id);
if (!$order) {
return $this->error('订单不存在或订单状态不允许核销');
}
$user = User::find($this->user_id);
if (!$user->mobile) {
return $this->error('获取手机号失败,请先授权获取手机号');
} else if ($user->mobile != $order->industryProduct->verify_mobile) {
return $this->error('对不起,你没有该订单的核销权限');
}
try {
//改变订单状态为已完成
$order->status = OrderStatus::SUCCESS;
$order->save();
return $this->success();
} catch (\Exception $e) {
return $this->error($e->getMessage());
}
}
public function fund($order)
{
$service = new WithdrawalService();

2
routes/api.php

@ -114,7 +114,7 @@ Route::namespace('App\Http\Controllers\Api')
# 核销订单
Route::prefix('verification')->group(function () {
Route::post('verify', 'VerificationController@verify');
Route::post('qrcode', 'VerificationController@qrcode');
Route::post('industry_verify', 'VerificationController@industry_verify'); //行业产品订单核销
});
# 短信息

Loading…
Cancel
Save