From baec35939eea6d35002e3d6afaea12597017c984 Mon Sep 17 00:00:00 2001 From: liapples Date: Fri, 17 Sep 2021 18:18:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/lang/zh_CN/agent-info.php | 3 ++- resources/lang/zh_CN/agent-product.php | 1 + resources/lang/zh_CN/waterfall-ad.php | 18 ------------------ 3 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 resources/lang/zh_CN/waterfall-ad.php diff --git a/resources/lang/zh_CN/agent-info.php b/resources/lang/zh_CN/agent-info.php index 9a4f497..ea913d2 100644 --- a/resources/lang/zh_CN/agent-info.php +++ b/resources/lang/zh_CN/agent-info.php @@ -1,8 +1,9 @@ - [ 'AgentInfo' => '代理商信息', 'agent-info' => '代理商信息', + 'agent_info' => '代理商信息', ], 'fields' => [ 'about' => '关于我们', diff --git a/resources/lang/zh_CN/agent-product.php b/resources/lang/zh_CN/agent-product.php index 82cfb69..d2a72ad 100644 --- a/resources/lang/zh_CN/agent-product.php +++ b/resources/lang/zh_CN/agent-product.php @@ -3,6 +3,7 @@ return [ 'labels' => [ 'AgentProduct' => '产品', 'agent-product' => '产品', + 'agent_product' => '产品', ], 'fields' => [ 'agent_id' => '代理商ID', diff --git a/resources/lang/zh_CN/waterfall-ad.php b/resources/lang/zh_CN/waterfall-ad.php deleted file mode 100644 index 996e9d4..0000000 --- a/resources/lang/zh_CN/waterfall-ad.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'WaterfallAd' => '产品列表内嵌广告', - 'waterfall-ad' => '产品列表内嵌广告', - ], - 'fields' => [ - 'title' => '广告名称', - 'agent_id' => '代理商ID', - 'picture' => '广告图片', - 'type' => '链接', - 'url' => '链接地址', - 'sort' => '排序', - 'status' => '状态', - ], - 'options' => [ - ], -]; From 1c426a482c65705413caa8c7f4bc9712a1bdf234 Mon Sep 17 00:00:00 2001 From: liapples Date: Sat, 18 Sep 2021 10:25:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A1=8C=E4=B8=9A=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=A0=B8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/VerificationController.php | 52 ++++++++++++++++--- routes/api.php | 2 +- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Api/VerificationController.php b/app/Http/Controllers/Api/VerificationController.php index 768830c..ab85138 100644 --- a/app/Http/Controllers/Api/VerificationController.php +++ b/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(); diff --git a/routes/api.php b/routes/api.php index c6bace0..701e304 100644 --- a/routes/api.php +++ b/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'); //行业产品订单核销 }); # 短信息 From 4ac40834db7acf0f1dd5fb6ccffef1a9676881d5 Mon Sep 17 00:00:00 2001 From: liapples Date: Sat, 18 Sep 2021 10:46:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A0=B8=E9=94=80?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/OrderController.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/OrderController.php b/app/Http/Controllers/Api/OrderController.php index f903bcd..8630e35 100644 --- a/app/Http/Controllers/Api/OrderController.php +++ b/app/Http/Controllers/Api/OrderController.php @@ -14,11 +14,11 @@ use App\Models\OrderProductItem; use App\Models\Product; use App\Models\User; use App\Models\Order; +use App\Service\OpenPlatform; use EasyWeChat\Factory; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException; use GuzzleHttp\Exception\GuzzleException; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Common\OrderStatus as Status; @@ -427,16 +427,8 @@ class OrderController extends Controller //如果有核销码,生成核销二维码 if ($order->verify_code) { - $setting = AdminSetting::val(['service_appid', 'service_appsecret', 'service_token', 'service_aeskey']); - $config = [ - 'app_id' => $setting['service_appid'], - 'secret' => $setting['service_appsecret'], - 'token' => $setting['service_token'], - 'aes_key' => $setting['service_aeskey'], - ]; - - $app = Factory::openPlatform($config); - $refreshToken = $app->getAuthorizer($order->agent->appid)['authorization_info']['authorizer_refresh_token'] ?? null; + $app = new OpenPlatform(); + $refreshToken = $app->refreshToken($order->agent->appid); if (!$refreshToken) { return $this->error('获取refresh_token失败'); } From 19834e3e21a350e46aa3f83627144b2df892023a Mon Sep 17 00:00:00 2001 From: liapples Date: Sat, 18 Sep 2021 10:55:24 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/TestController.php | 37 ++------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/Api/TestController.php b/app/Http/Controllers/Api/TestController.php index 5e490d2..e3115fb 100644 --- a/app/Http/Controllers/Api/TestController.php +++ b/app/Http/Controllers/Api/TestController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; +use App\Common\ProductStatus; use App\Models\AdminSetting; use App\Models\AgentProduct; use App\Models\MiniProgramUploadLog; @@ -19,41 +20,7 @@ class TestController { public function index() { - $appid = 'wx5bd5789ad8f89524'; - $message = json_decode('{"ToUserName":"gh_f4ab40774bed","FromUserName":"o4seR5d-TVCImgh2aE6UtrQn6LIM","CreateTime":"1631670431","MsgType":"event","Event":"weapp_audit_success","SuccTime":"1631670431"}', true); - DB::table('mini_program_events') - ->insert([ - 'type' => 1, - 'response' => json_encode($message), - 'event' => $message['MsgType'] ?? '', - 'created_at' => now() - ]); - - $openPlatform = new OpenPlatform(); - $refreshToken = $openPlatform->refreshToken($appid); - - //审核结果通知 - if (isset($message['MsgType'], $message['Event']) && $message['MsgType'] == 'event') { - $auditArr = [ - 'weapp_audit_success' => 0, //成功 - 'weapp_audit_fail' => 1, //拒绝 - 'weapp_audit_delay' => 4, //审核延后 - ]; - - //如果审核成功则发布 - if ($message['Event'] == 'weapp_audit_success') { - $code = $openPlatform->code($appid, $refreshToken); - $res = $code->release(); - dump($res); - } - - $log = MiniProgramUploadLog::query() - ->where('appid', $appid) - ->orderBy('id', 'desc') - ->first(); - $log->is_success = $auditArr[$message['Event']] ?? -1; - $log->save(); - } + return $this->login(12); } /**