29 changed files with 663 additions and 186 deletions
-
24app/Constants/v3/ErrorCode.php
-
10app/Constants/v3/LogLabel.php
-
4app/Constants/v3/OrderState.php
-
2app/Controller/v3/HomeController.php
-
17app/Controller/v3/LocationController.php
-
2app/Controller/v3/OrderOfflineController.php
-
90app/Controller/v3/OrderOnlineController.php
-
48app/Controller/v3/PaymentController.php
-
87app/JsonRpc/OrderOnlineService.php
-
8app/JsonRpc/OrderOnlineServiceInterface.php
-
21app/Model/v3/Market.php
-
2app/Model/v3/OrderMain.php
-
2app/Model/v3/ServiceReward.php
-
2app/Model/v3/UserRelationBind.php
-
37app/Request/v3/OrderOnlineStateRequest.php
-
7app/Service/v3/Implementations/ActivityService.php
-
12app/Service/v3/Implementations/BannerService.php
-
2app/Service/v3/Implementations/CouponRecService.php
-
112app/Service/v3/Implementations/CouponService.php
-
37app/Service/v3/Implementations/GoodsActivityService.php
-
8app/Service/v3/Implementations/OrderOfflineService.php
-
167app/Service/v3/Implementations/OrderOnlineService.php
-
66app/Service/v3/Implementations/SeparateAccountsService.php
-
15app/Service/v3/Interfaces/CouponServiceInterface.php
-
2app/Service/v3/Interfaces/GoodsActivityServiceInterface.php
-
50app/Service/v3/Interfaces/OrderOnlineServiceInterface.php
-
5app/Service/v3/Interfaces/SeparateAccountsServiceInterface.php
-
4config/autoload/wechat.php
-
6config/routes.php
@ -1,48 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Controller\v3; |
|||
|
|||
use App\Controller\BaseController; |
|||
use App\Model\v3\OrderMain; |
|||
use App\Service\v3\Interfaces\PaymentServiceInterface; |
|||
use Hyperf\Di\Annotation\Inject; |
|||
use Hyperf\Validation\ValidationException; |
|||
|
|||
class PaymentController extends BaseController |
|||
{ |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var PaymentServiceInterface |
|||
*/ |
|||
protected $paymentService; |
|||
|
|||
/** |
|||
* 微信线上订单支付 |
|||
* 主要用户待付款订单中的付款操作 |
|||
*/ |
|||
public function wechatpayOnline() |
|||
{ |
|||
$validator = $this->validationFactory->make( |
|||
$this->request->all(), |
|||
[ |
|||
'global_order_id' => 'required|nonempty', |
|||
'user_id' => 'required|nonempty', |
|||
], |
|||
[ |
|||
'global_order_id.*' => '订单号错误' |
|||
] |
|||
); |
|||
|
|||
if ($validator->fails()) { |
|||
throw new ValidationException($validator); |
|||
} |
|||
|
|||
$params = $validator->validated(); |
|||
$orderMain = OrderMain::query()->select('global_order_id', 'money', 'user_id') |
|||
->where(['global_order_id' => $params['global_order_id']])->first(); |
|||
$parameters = $this->paymentService->do($orderMain->global_order_id, $orderMain->money, $orderMain->user_id); |
|||
|
|||
return $this->success(['parameters' => $parameters]); |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
<?php |
|||
|
|||
namespace App\JsonRpc; |
|||
|
|||
use App\Commons\Log; |
|||
use App\Constants\v3\ErrorCode; |
|||
use App\Exception\ErrorCodeException; |
|||
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface; |
|||
use Hyperf\DbConnection\Db; |
|||
use Hyperf\RpcServer\Annotation\RpcService; |
|||
use Hyperf\Di\Annotation\Inject; |
|||
use App\Constants\v3\LogLabel; |
|||
|
|||
/** |
|||
* @RpcService(name="OrderOnlineService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="") |
|||
*/ |
|||
class OrderOnlineService implements OrderOnlineServiceInterface |
|||
{ |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var Log |
|||
*/ |
|||
protected $log; |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var \App\Service\v3\Interfaces\OrderOnlineServiceInterface |
|||
*/ |
|||
protected $orderOnlineService; |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var SeparateAccountsServiceInterface |
|||
*/ |
|||
protected $separateAccountsService; |
|||
|
|||
public function onlineComplete($orderMainId, $userId) |
|||
{ |
|||
Db::beginTransaction(); |
|||
try { |
|||
|
|||
$this->orderOnlineService->doComplete($orderMainId, $userId); |
|||
$this->separateAccountsService->orderOnlineCompleted($orderMainId, $userId); |
|||
|
|||
Db::commit(); |
|||
return [ |
|||
"status" => 200, |
|||
"code" => 0, |
|||
"result" => [], |
|||
"message" => '调用成功' |
|||
]; |
|||
} catch (\Exception $e) { |
|||
|
|||
Db::rollBack(); |
|||
$this->log->event(LogLabel::ORDER_COMPLETE_LOG, ['exception' => $e->getMessage()]); |
|||
throw new ErrorCodeException(ErrorCode::ORDER_COMPLETE_FAIL, $e->getMessage()); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 线上订单退款 |
|||
* 申请退款 state = 8 |
|||
* 退款成功 state = 9 |
|||
*/ |
|||
public function onlineRefund($global_order_id){ |
|||
$result = [ |
|||
"status" => 200, |
|||
"code" => ErrorCode::ORDER_FAILURE, |
|||
"result" => [], |
|||
"message" => '' |
|||
]; |
|||
|
|||
$res = $this->orderOnlineService->onlineRefund($global_order_id); |
|||
if($res['code'] > 0){ |
|||
$result['result'] = $res; |
|||
$result['message'] = '退款失败'; |
|||
}else{ |
|||
$result['code'] = 0; |
|||
$result['result'] = $res; |
|||
$result['message'] = '退款成功'; |
|||
}; |
|||
|
|||
return $result; |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
namespace App\JsonRpc; |
|||
|
|||
interface OrderOnlineServiceInterface |
|||
{ |
|||
public function onlineComplete($orderMainId, $userId); |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
<?php |
|||
|
|||
declare(strict_types=1); |
|||
|
|||
namespace App\Request\v3; |
|||
|
|||
use App\Request\BaseFormRequest; |
|||
|
|||
class OrderOnlineStateRequest extends BaseFormRequest |
|||
{ |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
*/ |
|||
public function rules(): array |
|||
{ |
|||
return [ |
|||
'order_id' => 'required|nonempty|integer', |
|||
'user_id' => 'required|nonempty|integer', |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
public function messages(): array |
|||
{ |
|||
return [ |
|||
'*.*' => ':attribute无效', |
|||
]; |
|||
} |
|||
|
|||
public function attributes(): array |
|||
{ |
|||
return parent::attributes(); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue