Browse Source
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
master
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
master
48 changed files with 989 additions and 221 deletions
-
30app/Constants/v3/ErrorCode.php
-
10app/Constants/v3/LogLabel.php
-
4app/Constants/v3/OrderState.php
-
39app/Controller/v3/GoodsRecommendController.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
-
4app/Controller/v3/SearchController.php
-
29app/JsonRpc/FeieService.php
-
87app/JsonRpc/OrderOnlineService.php
-
8app/JsonRpc/OrderOnlineServiceInterface.php
-
10app/JsonRpc/PrintServiceInterface.php
-
25app/Model/v3/Goods.php
-
12app/Model/v3/GoodsActivity.php
-
21app/Model/v3/Market.php
-
2app/Model/v3/OrderMain.php
-
2app/Model/v3/ServiceReward.php
-
2app/Model/v3/UserRelationBind.php
-
6app/Request/v3/OrderOnlineRequest.php
-
37app/Request/v3/OrderOnlineStateRequest.php
-
7app/Service/v3/Implementations/ActivityService.php
-
87app/Service/v3/Implementations/AttachmentService.php
-
12app/Service/v3/Implementations/BannerService.php
-
2app/Service/v3/Implementations/CouponRecService.php
-
112app/Service/v3/Implementations/CouponService.php
-
13app/Service/v3/Implementations/FeiePrintService.php
-
37app/Service/v3/Implementations/GoodsActivityService.php
-
8app/Service/v3/Implementations/OrderOfflineService.php
-
167app/Service/v3/Implementations/OrderOnlineService.php
-
10app/Service/v3/Implementations/SearchService.php
-
66app/Service/v3/Implementations/SeparateAccountsService.php
-
4app/Service/v3/Implementations/UserCenterBlockService.php
-
2app/Service/v3/Implementations/VerifyCodeService.php
-
6app/Service/v3/Implementations/WxLoginService.php
-
25app/Service/v3/Interfaces/AttachmentServiceInterface.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
-
3composer.json
-
75composer.lock
-
2config/autoload/dependencies.php
-
2config/autoload/feie.php
-
4config/autoload/wechat.php
-
1config/config.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,29 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\JsonRpc; |
||||
|
|
||||
|
use App\Service\v3\Interfaces\FeiePrintServiceInterface; |
||||
|
use Hyperf\RpcServer\Annotation\RpcService; |
||||
|
|
||||
|
use Hyperf\Di\Annotation\Inject; |
||||
|
/** |
||||
|
* @RpcService(name="FeieService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="") |
||||
|
* Class FeieService |
||||
|
* @package App\JsonRpc |
||||
|
*/ |
||||
|
class FeieService implements PrintServiceInterface |
||||
|
{ |
||||
|
/** |
||||
|
* @Inject |
||||
|
* @var FeiePrintServiceInterface |
||||
|
*/ |
||||
|
private $feieprintService; |
||||
|
|
||||
|
public function doPrint($oid) |
||||
|
{ |
||||
|
// TODO: Implement doPrint() method.
|
||||
|
return $this->feieprintService->feiePrint($oid); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -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,10 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\JsonRpc; |
||||
|
|
||||
|
|
||||
|
interface PrintServiceInterface |
||||
|
{ |
||||
|
public function doPrint($oid); |
||||
|
} |
||||
@ -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(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,87 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\Service\v3\Implementations; |
||||
|
|
||||
|
use App\Constants\v3\ErrorCode; |
||||
|
use App\Service\v3\Interfaces\AttachmentServiceInterface; |
||||
|
use League\Flysystem\FilesystemNotFoundException; |
||||
|
|
||||
|
class AttachmentService implements AttachmentServiceInterface |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* @inheritDoc |
||||
|
*/ |
||||
|
public function formUpload($file, $path, $filesystem, $attachmenttype = 'image') |
||||
|
{ |
||||
|
|
||||
|
$fileRealPath = $file->getRealPath(); |
||||
|
$fileHash = md5_file($fileRealPath); |
||||
|
|
||||
|
$path = $this->getBasePath($path, $attachmenttype); |
||||
|
$fileName = $path . '/' . $fileHash . '.' . $file->getExtension(); |
||||
|
|
||||
|
$stream = fopen($fileRealPath, 'r+'); |
||||
|
$filesystem->writeStream($fileName, $stream); |
||||
|
fclose($stream); |
||||
|
|
||||
|
return $fileName; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @inheritDoc |
||||
|
*/ |
||||
|
public function base64Upload($contents, $path, $filesystem) |
||||
|
{ |
||||
|
|
||||
|
preg_match('/^(data:\s*image\/(\w+);base64,)/', $contents, $result); |
||||
|
if (empty($result)) { |
||||
|
throw new FilesystemNotFoundException(ErrorCode::getMessage(ErrorCode::UPLOAD_INVALID),ErrorCode::UPLOAD_INVALID); |
||||
|
} |
||||
|
|
||||
|
$contents = base64_decode(str_replace($result[1], '', $contents)); |
||||
|
|
||||
|
$fileHash = md5($contents); |
||||
|
$path = $this->getBasePath($path); |
||||
|
$fileName = $path . '/' . $fileHash . '.' . $result[2]; |
||||
|
|
||||
|
$filesystem->write($fileName, $contents); |
||||
|
|
||||
|
return $fileName; |
||||
|
} |
||||
|
|
||||
|
protected function getBasePath($path, $attachmenttype = 'image') |
||||
|
{ |
||||
|
switch ($attachmenttype) { |
||||
|
case 'image': |
||||
|
$baseDir = env('IMAGE_BASE', '/attachment/images'); |
||||
|
break; |
||||
|
|
||||
|
case 'file': |
||||
|
$baseDir = env('FILES_BASE', '/attachment/files'); |
||||
|
break; |
||||
|
|
||||
|
default: |
||||
|
$baseDir = env('FILES_BASE', '/attachment'); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
$path = $path ? '/'.$path : ''; |
||||
|
$path .= '/'.date('Y').'/'.date('m').'/'.date('d'); |
||||
|
return $baseDir.$path; |
||||
|
} |
||||
|
|
||||
|
public function switchImgToAliOss($path, $bucket = 'thumbnail_q50') |
||||
|
{ |
||||
|
if (strpos($path, 'http') === false || strpos($path, 'https') === false) { |
||||
|
$path = config('alioss.img_host') . '/' . $path; |
||||
|
} else { |
||||
|
$temp = explode('//', $path); |
||||
|
$temp = explode('/', $temp[1]); |
||||
|
unset($temp[0]); |
||||
|
$path = config('alioss.img_host') . '/' . implode('/', $temp); |
||||
|
} |
||||
|
return $path . '!' . $bucket; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface AttachmentServiceInterface |
||||
|
{ |
||||
|
/** |
||||
|
* 表单上传,单文件 |
||||
|
* @param $file |
||||
|
* @param $path |
||||
|
* @param $filesystem |
||||
|
* @param string $attachmenttype |
||||
|
*/ |
||||
|
public function formUpload($file, $path, $filesystem, $attachmenttype = 'image'); |
||||
|
|
||||
|
/** |
||||
|
* base64code上传,单文件 |
||||
|
* @param $contents |
||||
|
* @param $path |
||||
|
* @param $filesystem |
||||
|
*/ |
||||
|
public function base64Upload($contents, $path, $filesystem); |
||||
|
|
||||
|
public function switchImgToAliOss($path, $bucket = ''); |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue