mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-14 18:42:49 +00:00
up
This commit is contained in:
parent
0b5b0de1db
commit
d792963b14
@ -255,4 +255,17 @@ class Diy extends BaseAdminController
|
||||
{
|
||||
return success(( new DiyService() )->getApps());
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制模版
|
||||
* @return Response
|
||||
*/
|
||||
public function copy()
|
||||
{
|
||||
$params = $this->request->params([
|
||||
[ 'id', '' ],
|
||||
]);
|
||||
$id = ( new DiyService() )->copy($params);
|
||||
return success('ADD_SUCCESS', [ 'id' => $id ]);
|
||||
}
|
||||
}
|
||||
|
||||
93
niucloud/app/adminapi/controller/member/Address.php
Normal file
93
niucloud/app/adminapi/controller/member/Address.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的多应用管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\member;
|
||||
|
||||
use app\service\admin\member\AddressService;
|
||||
use core\base\BaseAdminController;
|
||||
|
||||
|
||||
/**
|
||||
* 会员收货地址控制器
|
||||
*/
|
||||
class Address extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* 获取会员收货地址列表
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function lists(){
|
||||
$data = $this->request->params([
|
||||
["member_id",""],
|
||||
]);
|
||||
return success((new AddressService())->getList($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址详情
|
||||
* @param $id 会员收货地址id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function info($id){
|
||||
$data = $this->request->params([
|
||||
["member_id",""],
|
||||
]);
|
||||
return success((new AddressService())->getInfo($id, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员收货地址
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function add(){
|
||||
$data = $this->request->params([
|
||||
["member_id",""],
|
||||
["name",""],
|
||||
["mobile",""],
|
||||
["province_id",0],
|
||||
["city_id",0],
|
||||
["district_id",0],
|
||||
["address",""],
|
||||
["address_name", ""],
|
||||
["full_address",""],
|
||||
["lng",""],
|
||||
["lat",""],
|
||||
["is_default",0],
|
||||
]);
|
||||
$id = (new AddressService())->add($data);
|
||||
return success('ADD_SUCCESS', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址编辑
|
||||
* @param $id 会员收货地址id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id){
|
||||
$data = $this->request->params([
|
||||
["member_id",""],
|
||||
["name",""],
|
||||
["mobile",""],
|
||||
["province_id",0],
|
||||
["city_id",0],
|
||||
["district_id",0],
|
||||
["address",""],
|
||||
["address_name", ""],
|
||||
["full_address",""],
|
||||
["lng",""],
|
||||
["lat",""],
|
||||
["is_default",0],
|
||||
]);
|
||||
(new AddressService())->edit($id, $data);
|
||||
return success('EDIT_SUCCESS');
|
||||
}
|
||||
|
||||
}
|
||||
@ -56,4 +56,57 @@ class Pay extends BaseAdminController
|
||||
$reason = input('reason', '');
|
||||
return success(data: (new PayService())->refuse($out_trade_no, $reason));
|
||||
}
|
||||
|
||||
/**
|
||||
* 去支付
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
|
||||
$data = $this->request->params([
|
||||
['type', ''],
|
||||
['trade_type', ''],//业务类型
|
||||
['trade_id', ''],//业务id
|
||||
['quit_url', ''],
|
||||
['buyer_id', ''],
|
||||
['return_url', ''],
|
||||
['voucher', ''],
|
||||
['openid', '']
|
||||
]);
|
||||
|
||||
return success('SUCCESS',(new PayService())->pay($data['type'], $data['trade_type'], $data['trade_id'], $data['return_url'], $data['quit_url'], $data['buyer_id'], $data['voucher'], $data['openid']));
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付信息
|
||||
* @param $trade_type
|
||||
* @param $trade_id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function info($trade_type, $trade_id)
|
||||
{
|
||||
return success((new PayService())->getInfoByTrade($trade_type, $trade_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 找朋友帮忙付支付信息
|
||||
* @param $trade_type
|
||||
* @param $trade_id
|
||||
* @param $channel
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function friendspayInfo($trade_type, $trade_id, $channel)
|
||||
{
|
||||
return success(data:(new PayService())->getFriendspayInfoByTrade($trade_type, $trade_id, $channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function payTypeList()
|
||||
{
|
||||
return success(data:(new PayService())->getPayTypeList());
|
||||
}
|
||||
}
|
||||
37
niucloud/app/adminapi/controller/poster/Poster.php
Normal file
37
niucloud/app/adminapi/controller/poster/Poster.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\poster;
|
||||
|
||||
use core\base\BaseAdminController;
|
||||
|
||||
/**
|
||||
* 海报
|
||||
*/
|
||||
class Poster extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取海报
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$data = $this->request->params([
|
||||
[ 'id', 0 ], // 海报id
|
||||
[ 'type', '' ], // 海报类型
|
||||
[ 'param', [] ], // 数据参数
|
||||
[ 'channel', 'h5' ], // 数据参数
|
||||
]);
|
||||
return success(data: poster($this->request->siteId(), ...$data));
|
||||
}
|
||||
|
||||
}
|
||||
@ -107,8 +107,12 @@ class Site extends BaseAdminController
|
||||
{
|
||||
$data = $this->request->params([
|
||||
['site_name', ''],
|
||||
['expire_time', 0],
|
||||
['uid', 0],
|
||||
['username', ''],
|
||||
['real_name', ''],
|
||||
['password', ''],
|
||||
['group_id',0],
|
||||
['expire_time', 0],
|
||||
['site_domain', ''],
|
||||
]);
|
||||
$this->validate(array_merge($data, ['site_id' => $id]), 'app\validate\site\Site.edit');
|
||||
|
||||
@ -21,6 +21,7 @@ use think\facade\Route;
|
||||
Route::group('diy', function() {
|
||||
|
||||
/***************************************************** 自定义页面管理 ****************************************************/
|
||||
|
||||
// 自定义页面分页列表
|
||||
Route::get('diy', 'diy.Diy/lists');
|
||||
|
||||
@ -80,6 +81,9 @@ Route::group('diy', function() {
|
||||
// 获取模板页面(存在的应用插件列表)
|
||||
Route::get('apps', 'diy.Diy/getApps');
|
||||
|
||||
// 复制模版
|
||||
Route::post('copy', 'diy.Diy/copy');
|
||||
|
||||
/***************************************************** 配置相关 *****************************************************/
|
||||
|
||||
// 底部导航列表
|
||||
@ -91,8 +95,9 @@ Route::group('diy', function() {
|
||||
// 设置底部导航
|
||||
Route::post('bottom', 'diy.Config/setBottomConfig');
|
||||
|
||||
|
||||
})->middleware([
|
||||
AdminCheckToken::class,
|
||||
AdminCheckRole::class,
|
||||
AdminLog::class
|
||||
]);
|
||||
]);
|
||||
|
||||
@ -152,6 +152,15 @@ Route::group('member', function() {
|
||||
Route::get('sign/config', 'member.MemberSign/getSign');
|
||||
//签到记录
|
||||
Route::get('sign', 'member.MemberSign/lists');
|
||||
/***************************************************** 会员地址 ****************************************************/
|
||||
//会员收货地址列表
|
||||
Route::get('address', 'member.Address/lists');
|
||||
//会员收货地址详情
|
||||
Route::get('address/:id', 'member.Address/info');
|
||||
//添加会员收货地址
|
||||
Route::post('address', 'member.Address/add');
|
||||
//编辑会员收货地址
|
||||
Route::put('address/:id', 'member.Address/edit');
|
||||
})->middleware([
|
||||
AdminCheckToken::class,
|
||||
AdminCheckRole::class,
|
||||
|
||||
@ -50,6 +50,15 @@ Route::group('pay', function () {
|
||||
Route::post('refund/transfer', 'pay.PayRefund/transfer');
|
||||
// 获取全部支付方式
|
||||
Route::get('type/all', 'pay.PayChannel/getPayTypeList');
|
||||
/***************************************************** 支付 *************************************************/
|
||||
//去支付
|
||||
Route::post('', 'pay.Pay/pay');
|
||||
//支付信息
|
||||
Route::get('info/:trade_type/:trade_id', 'pay.Pay/info');
|
||||
//支付方式列表
|
||||
Route::get('type/list', 'pay.Pay/payTypeList');
|
||||
//找朋友帮忙付支付信息
|
||||
Route::get('friendspay/info/:trade_type/:trade_id/:channel', 'pay.Pay/friendspayInfo');
|
||||
})->middleware([
|
||||
AdminCheckToken::class,
|
||||
AdminCheckRole::class,
|
||||
|
||||
@ -259,6 +259,9 @@ Route::group('sys', function() {
|
||||
// 自定义海报预览
|
||||
Route::get('poster/preview', 'sys.Poster/preview');
|
||||
|
||||
//获取海报
|
||||
Route::get('poster/generate', 'poster.Poster/poster');
|
||||
|
||||
/***************************************************** 百度编辑器 ****************************************************/
|
||||
// 获取百度编辑器配置
|
||||
Route::get('ueditor', 'sys.Ueditor/getConfig');
|
||||
|
||||
43
niucloud/app/api/controller/diy/DiyForm.php
Normal file
43
niucloud/app/api/controller/diy/DiyForm.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller\diy;
|
||||
|
||||
use app\service\api\diy_form\DiyFormService;
|
||||
use core\base\BaseApiController;
|
||||
use think\Response;
|
||||
|
||||
class DiyForm extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* 系统表单详情
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function info(int $id)
|
||||
{
|
||||
return success(( new DiyFormService() )->getInfo($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加使用记录
|
||||
* @return Response
|
||||
*/
|
||||
public function addRecord()
|
||||
{
|
||||
$data = $this->request->params([
|
||||
[ 'form_id', '' ],
|
||||
[ 'value', [] ],
|
||||
[ 'relate_id', '' ],
|
||||
]);
|
||||
return success(( new DiyFormService())->addRecord($data));
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,19 @@ class Pay extends BaseApiController
|
||||
|
||||
public function info($trade_type, $trade_id)
|
||||
{
|
||||
return success((new PayService())->getInfoByTrade($trade_type, $trade_id));
|
||||
$data = $this->request->params([
|
||||
['scene', '']
|
||||
]);
|
||||
return success((new PayService())->getInfoByTrade($trade_type, $trade_id, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取找朋友帮忙付支付信息
|
||||
* @return Response
|
||||
*/
|
||||
public function friendspayInfo($trade_type, $trade_id)
|
||||
{
|
||||
return success((new PayService())->getFriendspayInfoByTrade($trade_type, $trade_id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -32,11 +32,13 @@ class Verify extends BaseApiController
|
||||
|
||||
/**
|
||||
* 获取核销码信息
|
||||
* @param $code
|
||||
* @return Response
|
||||
*/
|
||||
public function getInfoByCode($code){
|
||||
return success(data:(new VerifyService())->getInfoByCode($code));
|
||||
public function getInfoByCode(){
|
||||
$data = $this->request->params([
|
||||
['code', ''],
|
||||
]);
|
||||
return success(data:(new VerifyService())->getInfoByCode($data['code']));
|
||||
}
|
||||
/**
|
||||
* 核销
|
||||
|
||||
@ -39,6 +39,8 @@ class ApiCheckToken
|
||||
$request->appType(AppTypeDict::API);
|
||||
//检测站点
|
||||
( new AuthService() )->checkSite($request);
|
||||
// 校验渠道
|
||||
( new AuthService() )->checkChannel($request);
|
||||
//通过配置来设置系统header参数
|
||||
try {
|
||||
$token = $request->apiToken();
|
||||
@ -48,8 +50,6 @@ class ApiCheckToken
|
||||
}
|
||||
//校验会员和站点
|
||||
( new AuthService() )->checkSiteAuth($request);
|
||||
// 校验渠道
|
||||
( new AuthService() )->checkChannel($request);
|
||||
} catch (AuthException $e) {
|
||||
//是否将登录错误抛出
|
||||
if ($is_throw_exception)
|
||||
|
||||
@ -29,4 +29,19 @@ Route::group('diy', function() {
|
||||
Route::get('share', 'diy.Diy/share');
|
||||
|
||||
})->middleware(ApiLog::class)
|
||||
->middleware(ApiCheckToken::class, false);
|
||||
->middleware(ApiCheckToken::class, false);
|
||||
|
||||
|
||||
/**
|
||||
* 自定义页面
|
||||
*/
|
||||
Route::group('diy', function() {
|
||||
// 系统表单详情
|
||||
Route::get('form/:id', 'diy.DiyForm/info');
|
||||
|
||||
//添加使用记录
|
||||
Route::post('form/records', 'diy.DiyForm/addRecord');
|
||||
|
||||
})->middleware(ApiLog::class)
|
||||
->middleware(ApiCheckToken::class,true);
|
||||
|
||||
|
||||
@ -22,6 +22,14 @@ Route::any('pay/notify/:site_id/:channel/:type/:action', 'pay.Pay/notify')
|
||||
/**
|
||||
* 路由
|
||||
*/
|
||||
Route::group('pay',function () {
|
||||
//找朋友帮忙付支付信息
|
||||
Route::get('friendspay/info/:trade_type/:trade_id', 'pay.Pay/friendspayInfo');
|
||||
|
||||
})->middleware(ApiChannel::class)
|
||||
->middleware(ApiCheckToken::class)
|
||||
->middleware(ApiLog::class);
|
||||
|
||||
Route::group('pay',function () {
|
||||
//去支付
|
||||
Route::post('', 'pay.Pay/pay');
|
||||
@ -33,5 +41,5 @@ Route::group('pay',function () {
|
||||
Route::post('close', 'pay.Pay/close');
|
||||
|
||||
})->middleware(ApiChannel::class)
|
||||
->middleware(ApiCheckToken::class)
|
||||
->middleware(ApiCheckToken::class, true)//表示验证登录
|
||||
->middleware(ApiLog::class);
|
||||
@ -134,7 +134,7 @@ Route::group(function() {
|
||||
//核销详情
|
||||
Route::get('verify_detail/:code', 'sys.Verify/detail');
|
||||
//通过code码获取核销信息
|
||||
Route::get('get_verify_by_code/:code', 'sys.Verify/getInfoByCode');
|
||||
Route::get('get_verify_by_code', 'sys.Verify/getInfoByCode');
|
||||
//核销操作
|
||||
Route::post('verify/:code', 'sys.Verify/verify');
|
||||
|
||||
|
||||
@ -288,7 +288,7 @@ return [
|
||||
'sort' => '0',
|
||||
'status' => '1',
|
||||
'is_show' => '0',
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
||||
@ -19,7 +19,8 @@ class PayDict
|
||||
public const ALIPAY = 'alipay';//支付宝支付
|
||||
//const UNIPAY = 'unipay';//银联
|
||||
public const OFFLINEPAY = 'offlinepay';//线下支付
|
||||
public const BALANCEPAY = 'balancepay';//线下支付
|
||||
public const BALANCEPAY = 'balancepay';//余额支付
|
||||
public const FRIENDSPAY = 'friendspay';//找朋友帮忙付
|
||||
|
||||
|
||||
public const ON = '1';
|
||||
@ -31,10 +32,12 @@ class PayDict
|
||||
//上传方式 视频
|
||||
public const ALIPAY_ICON = self::PAY_ICON_PATH . 'alipay.png';//支付宝支付
|
||||
|
||||
public const BALANCEPAY_ICON = self::PAY_ICON_PATH . 'balancepay.png';//支付宝支付
|
||||
public const BALANCEPAY_ICON = self::PAY_ICON_PATH . 'balancepay.png';//余额支付
|
||||
|
||||
public const OFFLINEPAY_ICON = self::PAY_ICON_PATH . 'offlinepay.png';//线下支付
|
||||
|
||||
public const FRIENDSPAY_ICON = self::PAY_ICON_PATH . 'friendspay.png';//找朋友帮忙付
|
||||
|
||||
//支付状态
|
||||
public const STATUS_WAIT = '0';//待支付
|
||||
public const STATUS_ING = '1';//支付中
|
||||
@ -53,27 +56,38 @@ class PayDict
|
||||
public static function getPayType(array $types = [])
|
||||
{
|
||||
$list = [
|
||||
// 微信支付
|
||||
self::WECHATPAY => [
|
||||
'name' => get_lang('dict_pay.type_wechatpay'),
|
||||
'key' => self::WECHATPAY,
|
||||
'icon' => self::WECHATPAY_ICON,
|
||||
'setting_component' => '/src/app/views/setting/components/pay-wechatpay.vue',
|
||||
'encrypt_params' => ['mch_public_cert_path', 'mch_secret_cert', 'mch_secret_key', 'wechat_public_cert_path'],
|
||||
],//微信支付
|
||||
'encrypt_params' => [ 'mch_public_cert_path', 'mch_secret_cert', 'mch_secret_key', 'wechat_public_cert_path' ],
|
||||
],
|
||||
// 支付宝支付
|
||||
self::ALIPAY => [
|
||||
'name' => get_lang('dict_pay.type_alipay'),
|
||||
'key' => self::ALIPAY,
|
||||
'icon' => self::ALIPAY_ICON,
|
||||
'setting_component' => '/src/app/views/setting/components/pay-alipay.vue',
|
||||
'encrypt_params' => ['app_secret_cert', 'app_public_cert_path', 'alipay_public_cert_path', 'alipay_root_cert_path'],
|
||||
],//支付宝支付
|
||||
'encrypt_params' => [ 'app_secret_cert', 'app_public_cert_path', 'alipay_public_cert_path', 'alipay_root_cert_path' ],
|
||||
],
|
||||
// 余额支付
|
||||
self::BALANCEPAY => [
|
||||
'name' => get_lang('dict_pay.type_balancepay'),
|
||||
'key' => self::BALANCEPAY,
|
||||
'icon' => self::BALANCEPAY_ICON,
|
||||
'setting_component' => '',
|
||||
'encrypt_params' => ['secret_key'],
|
||||
],//微信支付
|
||||
'encrypt_params' => [ 'secret_key' ],
|
||||
],
|
||||
// 找朋友帮忙付
|
||||
self::FRIENDSPAY => [
|
||||
'name' => get_lang('dict_pay.type_friendspay'),
|
||||
'key' => self::FRIENDSPAY,
|
||||
'icon' => self::FRIENDSPAY_ICON,
|
||||
'setting_component' => '/src/app/views/setting/components/pay-friendspay.vue',
|
||||
'encrypt_params' => [],
|
||||
],
|
||||
];
|
||||
|
||||
$list = array_merge($list, ...event('PayType'));
|
||||
@ -81,7 +95,7 @@ class PayDict
|
||||
if (!empty($types)) {
|
||||
foreach ($list as $k => $v) {
|
||||
if (!in_array($k, $types)) {
|
||||
unset($list[$k]);
|
||||
unset($list[ $k ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
niucloud/app/dict/pay/PaySceneDict.php
Normal file
25
niucloud/app/dict/pay/PaySceneDict.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\dict\pay;
|
||||
|
||||
|
||||
/**
|
||||
* 支付场景枚举类
|
||||
* Class PaySceneDict
|
||||
* @package app\dict\pay
|
||||
*/
|
||||
class PaySceneDict
|
||||
{
|
||||
//找朋友帮忙付
|
||||
public const FRIENDSPAY = 'friendspay';
|
||||
|
||||
}
|
||||
@ -114,7 +114,38 @@ class ComponentDict
|
||||
'points' => [], // [x,y]:左上,右上,右下,左下
|
||||
],
|
||||
],
|
||||
|
||||
'FriendsPayMessage' => [
|
||||
'title' => "帮付留言",
|
||||
'type' => 'text',
|
||||
'icon' => "nc-iconfont nc-icon-daifuliuyanV6xx",
|
||||
'path' => "friendspay-message",
|
||||
'uses' => 1,
|
||||
'sort' => 10006,
|
||||
'relate' => 'friendspay_message', // 关联字段,空为不处理
|
||||
'value' => get_lang('dict_pay_config.pay_leave_message'),
|
||||
'template' => [
|
||||
"width" => 611,
|
||||
"height" => 85,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 44,
|
||||
]
|
||||
],
|
||||
'FriendsPayMoney' => [
|
||||
'title' => "帮付金额",
|
||||
'type' => 'text',
|
||||
'icon' => "nc-iconfont nc-icon-daifujineV6xx",
|
||||
'path' => "friendspay-money",
|
||||
'uses' => 1,
|
||||
'sort' => 10007,
|
||||
'relate' => 'friendspay_money', // 关联字段,空为不处理
|
||||
'value' => '帮付金额',
|
||||
'template' => [
|
||||
"width" => 436,
|
||||
"height" => 50,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 44,
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
170
niucloud/app/dict/poster/template.php
Normal file
170
niucloud/app/dict/poster/template.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
return [
|
||||
[
|
||||
"name" => "找朋友帮忙付模板", // 海报模板名称
|
||||
'type' => 'friendspay', // 海报类型
|
||||
"data" => [
|
||||
"global" => [
|
||||
"width" => 720,
|
||||
"height" => 1280,
|
||||
"bgType" => "url",
|
||||
"bgColor" => "#ffffff",
|
||||
"bgUrl" => "static/resource/images/pay/friendspay_bg.jpg"
|
||||
],
|
||||
"value" => [
|
||||
[
|
||||
"type" => "text",
|
||||
"path" => "text",
|
||||
"uses" => 0,
|
||||
"relate" => "",
|
||||
"value" => "您的帮付金额",
|
||||
"id" => "wgvspr9fafk",
|
||||
"componentName" => "Text",
|
||||
"componentTitle" => "文本",
|
||||
"width" => 518,
|
||||
"height" => 48,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 44,
|
||||
"x" => "center",
|
||||
"y" => 759,
|
||||
"angle" => 0,
|
||||
"zIndex" => 8,
|
||||
"fontFamily" => "static/font/SourceHanSansCN-Regular.ttf",
|
||||
"fontSize" => 24,
|
||||
"weight" => false,
|
||||
"lineHeight" => 20,
|
||||
"fontColor" => "#333333"
|
||||
],
|
||||
[
|
||||
"type" => "text",
|
||||
"path" => "friendspay-money",
|
||||
"uses" => 1,
|
||||
"relate" => "friendspay_money",
|
||||
"value" => "¥369.00",
|
||||
"id" => "2waud25nthq0",
|
||||
"componentName" => "FriendsPayMoney",
|
||||
"componentTitle" => "帮付金额",
|
||||
"width" => 518,
|
||||
"height" => 58,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 44,
|
||||
"x" => "center",
|
||||
"y" => 694,
|
||||
"angle" => 0,
|
||||
"zIndex" => 9,
|
||||
"fontFamily" => "static/font/price.ttf",
|
||||
"fontSize" => 56,
|
||||
"weight" => false,
|
||||
"lineHeight" => 10,
|
||||
"fontColor" => "#FF4142"
|
||||
],
|
||||
[
|
||||
"type" => "text",
|
||||
"path" => "text",
|
||||
"uses" => 0,
|
||||
"relate" => "",
|
||||
"value" => "长按识别二维码,帮我付款",
|
||||
"id" => "639vjo8ebo40",
|
||||
"componentName" => "Text",
|
||||
"componentTitle" => "文本",
|
||||
"width" => 518,
|
||||
"height" => 59,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 44,
|
||||
"x" => "center",
|
||||
"y" => 1097,
|
||||
"angle" => 0,
|
||||
"zIndex" => 10,
|
||||
"fontFamily" => "static/font/SourceHanSansCN-Regular.ttf",
|
||||
"fontSize" => 26,
|
||||
"weight" => false,
|
||||
"lineHeight" => 26,
|
||||
"fontColor" => "#333333"
|
||||
],
|
||||
[
|
||||
"type" => "text",
|
||||
"path" => "friendspay-message",
|
||||
"uses" => 1,
|
||||
"relate" => "friendspay_message",
|
||||
"value" => "帮我付一下这笔订单吧,谢谢啦~",
|
||||
"id" => "5oyikcgoylo0",
|
||||
"componentName" => "FriendsPayMessage",
|
||||
"componentTitle" => "帮付留言",
|
||||
"width" => 600,
|
||||
"height" => 48,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 44,
|
||||
"x" => "center",
|
||||
"y" => 570,
|
||||
"angle" => 0,
|
||||
"zIndex" => 4,
|
||||
"fontFamily" => "static/font/SourceHanSansCN-Regular.ttf",
|
||||
"fontSize" => 26,
|
||||
"weight" => false,
|
||||
"lineHeight" => 10,
|
||||
"fontColor" => "#666666"
|
||||
],
|
||||
[
|
||||
"type" => "qrcode",
|
||||
"path" => "qrcode",
|
||||
"uses" => 1,
|
||||
"relate" => "url",
|
||||
"value" => "",
|
||||
"id" => "3m6szk6d98m0",
|
||||
"componentName" => "Qrcode",
|
||||
"componentTitle" => "二维码",
|
||||
"width" => 214,
|
||||
"height" => 214,
|
||||
"minWidth" => 60,
|
||||
"minHeight" => 60,
|
||||
"x" => 254,
|
||||
"y" => 844,
|
||||
"angle" => 0,
|
||||
"zIndex" => 8
|
||||
],
|
||||
[
|
||||
"type" => "text",
|
||||
"path" => "nickname",
|
||||
"uses" => 1,
|
||||
"relate" => "nickname",
|
||||
"value" => "",
|
||||
"id" => "31wsjudfc7m0",
|
||||
"componentName" => "NickName",
|
||||
"componentTitle" => "昵称",
|
||||
"width" => 600,
|
||||
"height" => 40,
|
||||
"minWidth" => 120,
|
||||
"minHeight" => 50,
|
||||
"x" => "center",
|
||||
"y" => 512,
|
||||
"angle" => 0,
|
||||
"zIndex" => 6,
|
||||
"fontFamily" => "static/font/SourceHanSansCN-Regular.ttf",
|
||||
"fontSize" => 30,
|
||||
"weight" => false,
|
||||
"lineHeight" => 10,
|
||||
"fontColor" => "#303133"
|
||||
],
|
||||
[
|
||||
"type" => "image",
|
||||
"path" => "headimg",
|
||||
"uses" => 1,
|
||||
"relate" => "headimg",
|
||||
"value" => "",
|
||||
"id" => "5asgzwz9f5s0",
|
||||
"componentName" => "HeadImg",
|
||||
"componentTitle" => "头像",
|
||||
"width" => 149,
|
||||
"height" => 149,
|
||||
"minWidth" => 60,
|
||||
"minHeight" => 60,
|
||||
"x" => 286,
|
||||
"y" => 344,
|
||||
"angle" => 0,
|
||||
"zIndex" => 7,
|
||||
"shape" => "circle"
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
@ -104,6 +104,7 @@ $system_event = [
|
||||
'StatField' => [],
|
||||
|
||||
// 获取海报数据
|
||||
'GetPosterType' => [ 'app\listener\system\PosterType' ],
|
||||
'GetPosterData' => [ 'app\listener\system\Poster' ],
|
||||
|
||||
// 小程序授权变更事件
|
||||
|
||||
@ -368,6 +368,7 @@ CREATE TABLE `pay` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`site_id` int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
|
||||
`main_id` int(11) NOT NULL DEFAULT 0 COMMENT '支付会员id',
|
||||
`from_main_id` INT(11) NOT NULL DEFAULT 0 COMMENT '发起支付会员id',
|
||||
`out_trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '支付流水号',
|
||||
`trade_type` varchar(255) NOT NULL DEFAULT '' COMMENT '业务类型',
|
||||
`trade_id` int(11) NOT NULL DEFAULT 0 COMMENT '业务id',
|
||||
@ -1051,7 +1052,7 @@ INSERT INTO `site`(site_id, site_name, group_id, keywords, app_type, logo, `desc
|
||||
|
||||
UPDATE `site` SET site_id = 0 WHERE site_id = 1;
|
||||
|
||||
INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
|
||||
-- INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
|
||||
|
||||
INSERT INTO `sys_user_role` VALUES ('1', '1', '0', '', '0', '1', '1', '0');
|
||||
|
||||
|
||||
@ -163,6 +163,9 @@ return [
|
||||
'LEVEL_NOT_ALLOWED_DELETE' => '该等级下存在会员不允许删除',
|
||||
'MEMBER_LEVEL_MAX' => '最多只能有十个等级',
|
||||
|
||||
// 地址相关
|
||||
'ADDRESS_ANALYSIS_ERROR' => '地址解析异常',
|
||||
|
||||
//会员提现
|
||||
'CASHOUT_NOT_OPEN' => '会员提现业务未开启',
|
||||
'CASHOUT_TYPE_NOT_OPEN' => '当前会员提现方式未启用',
|
||||
@ -177,6 +180,12 @@ return [
|
||||
'MEMBER_CASHOUT_TRANSFER' => '会员提现转账',
|
||||
'CASH_OUT_ACCOUNT_NOT_EXIST' => '提现账户不存在',
|
||||
|
||||
//DIY
|
||||
'PAGE_NOT_EXIST' => '页面不存在',
|
||||
|
||||
//系统表单
|
||||
'DIY_FORM_NOT_EXIT' => '表单不存在',
|
||||
'DIY_FORM_EXCEEDING_LIMIT' => '已达提交次数上限',
|
||||
|
||||
//渠道相关 占用 4******
|
||||
//微信
|
||||
@ -224,6 +233,8 @@ return [
|
||||
'VOUCHER_NOT_EMPTY' => '支付单据不能为空',
|
||||
'ONLY_PAYING_CAN_AUDIT' => '只有待支付的订单才可以操作',
|
||||
'ONLY_OFFLINEPAY_CAN_AUDIT' => '只有线下支付的单据才可以审核',
|
||||
'TRADE_NOT_EXIST' => '支付单据不存在',
|
||||
'PAY_NOT_FOUND_TRADE' => '找不到可支付的交易',
|
||||
//退款相关
|
||||
'REFUND_NOT_EXIST' => '退款单据不存在',
|
||||
//订单相关 8***
|
||||
|
||||
@ -177,6 +177,7 @@ return [
|
||||
'type_unipay' => '银联支付',
|
||||
'type_offline' => '线下支付',
|
||||
'type_balancepay' => '余额支付',
|
||||
'type_friendspay' => '找朋友帮忙付',
|
||||
|
||||
'status_wait' => '待支付',
|
||||
'status_ing' => '支付中',
|
||||
@ -187,6 +188,14 @@ return [
|
||||
'refund' => '退款',
|
||||
'transfer' => '转账',
|
||||
],
|
||||
//支付配置相关
|
||||
'dict_pay_config' => [
|
||||
'pay_leave_message' => '帮我付一下这笔订单吧,谢谢啦~',
|
||||
'pay_button_name' => '慷慨付款',
|
||||
'pay_page_name' => '帮我付款',
|
||||
'pay_explain_title' => '帮付说明',
|
||||
'pay_explain_content' => "1.付款前请务必和好友进行确认,以避免给你造成损失。\n2.当帮付订单退款成功后,实付金额将原路退还到帮付人账户。\n3.帮付订单信息中显示的金额为单价,但因优惠活动等因素,实付金额可能会发生变化,具体金额以页面显示为准。",
|
||||
],
|
||||
//转账相关
|
||||
'dict_transfer' => [
|
||||
'type_wechat' => '微信',
|
||||
@ -248,6 +257,11 @@ return [
|
||||
'dict_diy_poster' => [
|
||||
'component_type_basic' => '基础组件',
|
||||
],
|
||||
// 系统自定义表单
|
||||
'dict_diy_form' => [
|
||||
'component_type_form' => '表单组件',
|
||||
'type_diy_form' => '自定义表单',
|
||||
],
|
||||
//短信相关
|
||||
'dict_sms' => [
|
||||
'status_sending' => '发送中',
|
||||
|
||||
102
niucloud/app/listener/poster/FriendspayPoster.php
Normal file
102
niucloud/app/listener/poster/FriendspayPoster.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
declare ( strict_types = 1 );
|
||||
|
||||
namespace app\listener\poster;
|
||||
|
||||
use app\dict\pay\PayDict;
|
||||
use app\model\member\Member;
|
||||
use app\model\pay\Pay;
|
||||
use app\service\core\pay\CorePayChannelService;
|
||||
use app\service\core\sys\CoreSysConfigService;
|
||||
|
||||
/**
|
||||
* 找朋友帮忙付海报数据
|
||||
*/
|
||||
class FriendspayPoster
|
||||
{
|
||||
/**
|
||||
* 找朋友帮忙付海报
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function handle($data)
|
||||
{
|
||||
$type = $data[ 'type' ];
|
||||
if ($type == 'friendspay') {
|
||||
// 找朋友帮忙付 海报模板数据
|
||||
|
||||
$site_id = $data[ 'site_id' ];
|
||||
$channel = $data[ 'channel' ];
|
||||
$param = $data[ 'param' ];
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
$trade_id = $param[ 'id' ] ?? 0;//交易id
|
||||
$trade_type = $param[ 'type' ] ?? '';//交易类型
|
||||
$mode = $param[ 'mode' ] ?? '';
|
||||
|
||||
$url_data = [
|
||||
[ 'key' => 'id', 'value' => $trade_id ],
|
||||
[ 'key' => 'type', 'value' => $trade_type ]
|
||||
];
|
||||
|
||||
if ($mode == 'preview') {
|
||||
// 预览模式
|
||||
$return_data = [
|
||||
'nickname' => '会员昵称的帮付',
|
||||
'headimg' => 'static/resource/images/default_headimg.png',
|
||||
'friendspay_message' => get_lang('dict_pay_config.pay_leave_message'),
|
||||
'friendspay_money' => '¥369.00',
|
||||
'url' => [
|
||||
'url' => ( new CoreSysConfigService() )->getSceneDomain($site_id)[ 'wap_url' ],
|
||||
'page' => 'app/pages/friendspay/money',
|
||||
'data' => $url_data,
|
||||
],
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
$pay_info = ( new Pay() )->field('money')->where([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'trade_id', '=', $trade_id ],
|
||||
[ 'trade_type', '=', $trade_type ],
|
||||
[ 'status', '<>', PayDict::STATUS_CANCLE ],///不查询已取消的单据
|
||||
])->findOrEmpty()->toArray();
|
||||
|
||||
if (empty($pay_info)) return [];
|
||||
|
||||
$member_info = [];
|
||||
|
||||
if ($member_id > 0) {
|
||||
//查询会员信息
|
||||
$member_info = ( new Member() )->where([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $site_id ] ])->findOrEmpty();
|
||||
|
||||
if (!empty($member_info)) {
|
||||
if (empty($member_info[ 'headimg' ])) {
|
||||
$member_info[ 'headimg' ] = 'static/resource/images/default_headimg.png';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pay_config = [];
|
||||
$pay_type_list = ( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $trade_type);
|
||||
if (!empty($pay_type_list) && !empty($pay_type_list[ PayDict::FRIENDSPAY ])) {
|
||||
$pay_config = $pay_type_list[ PayDict::FRIENDSPAY ][ 'config' ];
|
||||
}
|
||||
|
||||
$return_data = [
|
||||
'friendspay_message' => $pay_config[ 'pay_leave_message' ] ?? get_lang('dict_pay_config.pay_leave_message'),
|
||||
'friendspay_money' => '¥' . $pay_info[ 'money' ],
|
||||
'url' => [
|
||||
'url' => ( new CoreSysConfigService() )->getSceneDomain($site_id)[ 'wap_url' ],
|
||||
'page' => 'app/pages/friendspay/money',
|
||||
'data' => $url_data,
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($member_info)) {
|
||||
$return_data[ 'nickname' ] = mb_strlen($member_info[ 'nickname' ]) > 12 ? mb_substr($member_info[ 'nickname' ], 0, 12, 'utf-8') . '...的帮付' : $member_info[ 'nickname' ] . '的帮付';
|
||||
$return_data[ 'headimg' ] = $member_info[ 'headimg' ];
|
||||
}
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,8 +10,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\listener\system;
|
||||
|
||||
use app\model\sys\Poster;
|
||||
use app\model\sys\SysAttachment;
|
||||
use app\model\sys\SysAttachmentCategory;
|
||||
use app\service\core\poster\CorePosterService;
|
||||
|
||||
/**
|
||||
* 站点创建之后
|
||||
@ -507,6 +509,24 @@ class AddSiteAfterListener
|
||||
$attachment_model->insertAll($attachment_list);
|
||||
}
|
||||
|
||||
$poster_model = new Poster();
|
||||
$poster_count = $poster_model->where([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'type', '=', 'friendspay' ]
|
||||
])->count();
|
||||
if ($poster_count == 0) {
|
||||
// 创建默认找朋友帮忙付海报
|
||||
$poster = new CorePosterService();
|
||||
$template = $poster->getTemplateList('', 'friendspay')[ 0 ];
|
||||
$poster->add($site_id, '', [
|
||||
'name' => $template[ 'name' ],
|
||||
'type' => $template[ 'type' ],
|
||||
'value' => $template[ 'data' ],
|
||||
'status' => 1,
|
||||
'is_default' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ declare ( strict_types = 1 );
|
||||
namespace app\listener\system;
|
||||
|
||||
|
||||
use app\listener\poster\FriendspayPoster;
|
||||
use app\model\member\Member;
|
||||
|
||||
/**
|
||||
@ -18,34 +19,41 @@ class Poster
|
||||
*/
|
||||
public function handle($data)
|
||||
{
|
||||
$type = $data[ 'type' ] ?? '';
|
||||
switch ($type) {
|
||||
case 'friendspay':// 找朋友帮忙付海报
|
||||
return ( new FriendspayPoster() )->handle($data);
|
||||
break;
|
||||
default:
|
||||
$site_id = $data[ 'site_id' ];
|
||||
$param = $data[ 'param' ];
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
|
||||
$site_id = $data[ 'site_id' ];
|
||||
$param = $data[ 'param' ];
|
||||
$member_id = $param[ 'member_id' ] ?? 0;
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->where([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'member_id', '=', $member_id ]
|
||||
])->field('nickname,headimg')->findOrEmpty()->toArray();
|
||||
|
||||
$member_model = new Member();
|
||||
$member_info = $member_model->where([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'member_id', '=', $member_id ]
|
||||
])->field('nickname,headimg')->findOrEmpty()->toArray();
|
||||
if (empty($member_info)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (empty($member_info)) {
|
||||
return [];
|
||||
$nickname = $member_info[ 'nickname' ];
|
||||
if (mb_strlen($nickname, 'UTF-8') > 10) {
|
||||
$nickname = mb_strlen($nickname) > 10 ? mb_substr($nickname, 0, 7, 'UTF-8') . '...' : $nickname;
|
||||
}
|
||||
|
||||
$headimg = $member_info[ 'headimg' ];
|
||||
if (empty($headimg)) {
|
||||
$headimg = 'static/resource/images/default_headimg.png';
|
||||
}
|
||||
$return_data = [
|
||||
'nickname' => $nickname,
|
||||
'headimg' => $headimg,
|
||||
];
|
||||
return $return_data;
|
||||
break;
|
||||
}
|
||||
|
||||
$nickname = $member_info[ 'nickname' ];
|
||||
if (mb_strlen($nickname, 'UTF-8') > 10) {
|
||||
$nickname = mb_strlen($nickname) > 10 ? mb_substr($nickname, 0, 7, 'UTF-8') . '...' : $nickname;
|
||||
}
|
||||
|
||||
$headimg = $member_info[ 'headimg' ];
|
||||
if (empty($headimg)) {
|
||||
$headimg = 'static/resource/images/default_headimg.png';
|
||||
}
|
||||
$return_data = [
|
||||
'nickname' => $nickname,
|
||||
'headimg' => $headimg,
|
||||
];
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
|
||||
30
niucloud/app/listener/system/PosterType.php
Normal file
30
niucloud/app/listener/system/PosterType.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare ( strict_types = 1 );
|
||||
|
||||
namespace app\listener\system;
|
||||
|
||||
|
||||
/**
|
||||
* 系统海报类型
|
||||
*/
|
||||
class PosterType
|
||||
{
|
||||
/**
|
||||
* 系统海报
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function handle($data = [])
|
||||
{
|
||||
return [
|
||||
[
|
||||
'type' => 'friendspay',
|
||||
'addon' => '',
|
||||
'name' => '找朋友帮忙付海报',
|
||||
'decs' => '找朋友帮忙付,分享后进入帮付页面',
|
||||
'icon' => 'static/resource/images/poster/type_friendspay.png'
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
@ -787,4 +787,26 @@ class DiyService extends BaseAdminService
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制自定义页面
|
||||
* @param array $param
|
||||
* @return mixed
|
||||
*/
|
||||
public function copy($param)
|
||||
{
|
||||
$info = $this->model->where([ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
|
||||
if (empty($info)) throw new AdminException('PAGE_NOT_EXIST');
|
||||
|
||||
unset($info[ 'id' ]);
|
||||
$info[ 'page_title' ] = $info[ 'page_title' ] . '_副本';
|
||||
$info[ 'is_default' ] = 0;
|
||||
$info[ 'is_change' ] = 0;
|
||||
$info[ 'share' ] = '';
|
||||
$info[ 'create_time' ] = time();
|
||||
$info[ 'update_time' ] = time();
|
||||
|
||||
$res = $this->model->create($info);
|
||||
return $res->id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
87
niucloud/app/service/admin/member/AddressService.php
Normal file
87
niucloud/app/service/admin/member/AddressService.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的多应用管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\service\admin\member;
|
||||
|
||||
use app\model\member\MemberAddress;
|
||||
use app\service\admin\sys\AreaService;
|
||||
use app\service\core\member\CoreMemberAddressService;
|
||||
use core\base\BaseAdminService;
|
||||
use core\exception\AdminException;
|
||||
|
||||
|
||||
/**
|
||||
* 会员收货地址服务层
|
||||
*/
|
||||
class AddressService extends BaseAdminService
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->model = new MemberAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员收货地址列表
|
||||
* @param array $where
|
||||
* @return array
|
||||
*/
|
||||
public function getList(array $where = [])
|
||||
{
|
||||
$where['site_id'] = $this->site_id;
|
||||
return ( new CoreMemberAddressService() )->getList($where);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员收货地址信息
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getInfo($id, $data)
|
||||
{
|
||||
$data['site_id'] = $this->site_id;
|
||||
return ( new CoreMemberAddressService() )->getInfo($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员收货地址
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function add(array $data)
|
||||
{
|
||||
$analysis_res = ( new AreaService() )->getAddress($data['full_address']);
|
||||
if ($analysis_res['status'] == 0 && $analysis_res['message'] == 'Success' && !empty($analysis_res['result'])) {
|
||||
$data['lng'] = $analysis_res['result']['location']['lng'];
|
||||
$data['lat'] = $analysis_res['result']['location']['lat'];
|
||||
}
|
||||
$data['site_id'] = $this->site_id;
|
||||
return ( new CoreMemberAddressService() )->add($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址编辑
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function edit(int $id, array $data)
|
||||
{
|
||||
$analysis_res = ( new AreaService() )->getAddress($data['full_address']);
|
||||
if ($analysis_res['status'] == 0 && $analysis_res['message'] == 'Success' && !empty($analysis_res['result'])) {
|
||||
$data['lng'] = $analysis_res['result']['location']['lng'];
|
||||
$data['lat'] = $analysis_res['result']['location']['lat'];
|
||||
}
|
||||
return ( new CoreMemberAddressService() )->edit($id, $data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -108,11 +108,14 @@ class PayChannelService extends BaseAdminService
|
||||
if ($config_v !== '' && in_array($config_k, $encrypt_params)) $temp_v_item['config'][$config_k] = CommonDict::ENCRYPT_STR;
|
||||
}
|
||||
} else {
|
||||
$temp_v_item = [ 'status' => 0, 'config' => [ 'name' => '' ], 'sort' => 0 ];
|
||||
$temp_v_item = [ 'status' => 0, 'config' => $this->getConfigByPayType([], $item_k), 'sort' => 0 ];
|
||||
}
|
||||
$item_v[ 'config' ] = $temp_v_item[ 'config' ];
|
||||
$item_v[ 'status' ] = $temp_v_item[ 'status' ];
|
||||
$item_v[ 'sort' ] = $temp_v_item[ 'sort' ];
|
||||
if ($item_k == PayDict::FRIENDSPAY) {
|
||||
$item_v[ 'name' ] = $temp_v_item[ 'config' ][ 'pay_type_name' ] ?? get_lang('dict_pay.type_friendspay');
|
||||
}
|
||||
$channel_list[ $k ][ 'pay_type' ][ $item_k ] = $item_v;
|
||||
}
|
||||
$temp_pay_type = array_values($channel_list[ $k ][ 'pay_type' ]);
|
||||
@ -187,6 +190,18 @@ class PayChannelService extends BaseAdminService
|
||||
'collection_desc' => $data[ 'collection_desc' ] ?? '',// 必填-转账说明
|
||||
];
|
||||
break;
|
||||
case PayDict::FRIENDSPAY:
|
||||
$config = [
|
||||
'pay_type_name' => $data[ 'pay_type_name' ] ?? get_lang('dict_pay.type_friendspay'),// 支付方式名称
|
||||
'pay_leave_message' => $data[ 'pay_leave_message' ] ?? get_lang('dict_pay_config.pay_leave_message'),// 发起帮付默认留言
|
||||
'pay_button_name' => $data[ 'pay_button_name' ] ?? get_lang('dict_pay_config.pay_button_name'),// 支付按钮名称
|
||||
'pay_page_name' => $data[ 'pay_page_name' ] ?? get_lang('dict_pay_config.pay_page_name'),// 帮付页面名称
|
||||
'pay_explain_switch' => $data[ 'pay_explain_switch' ] ?? 1,// 帮付说明开关, 1开启,0关闭
|
||||
'pay_explain_title' => $data[ 'pay_explain_title' ] ?? get_lang('dict_pay_config.pay_explain_title'),// 帮付说明标题
|
||||
'pay_explain_content' => $data[ 'pay_explain_content' ] ?? get_lang('dict_pay_config.pay_explain_content'),// 帮付说明内容
|
||||
'pay_info_switch' => $data[ 'pay_info_switch' ] ?? 1// 订单信息, 1开启,0关闭
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$config = $data;
|
||||
}
|
||||
|
||||
@ -11,10 +11,20 @@
|
||||
|
||||
namespace app\service\admin\pay;
|
||||
|
||||
use app\dict\common\ChannelDict;
|
||||
use app\dict\pay\PayDict;
|
||||
use app\dict\pay\PaySceneDict;
|
||||
use app\model\member\Member;
|
||||
use app\model\pay\Pay;
|
||||
use app\model\sys\Poster;
|
||||
use app\service\core\pay\CorePayService;
|
||||
use app\service\core\paytype\CoreOfflineService;
|
||||
use app\service\core\sys\CoreSysConfigService;
|
||||
use core\base\BaseAdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 支付服务层
|
||||
@ -33,9 +43,10 @@ class PayService extends BaseAdminService
|
||||
* @param array $where
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuditPage(array $where){
|
||||
public function getAuditPage(array $where)
|
||||
{
|
||||
$field = 'id, out_trade_no, type, money, body, voucher, create_time, trade_id, trade_type, status';
|
||||
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ], ['type', '=', PayDict::OFFLINEPAY] ])->withSearch([ 'create_time', 'out_trade_no', 'status' ], $where)->field($field)->append([ 'type_name' ])->order('create_time desc');
|
||||
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ], [ 'type', '=', PayDict::OFFLINEPAY ] ])->withSearch([ 'create_time', 'out_trade_no', 'status' ], $where)->field($field)->append([ 'type_name' ])->order('create_time desc');
|
||||
return $this->pageQuery($search_model);
|
||||
}
|
||||
|
||||
@ -44,9 +55,10 @@ class PayService extends BaseAdminService
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function getDetail(int $id){
|
||||
public function getDetail(int $id)
|
||||
{
|
||||
$field = 'id,out_trade_no,trade_type,trade_id,trade_no,body,money,voucher,status,create_time,pay_time,cancel_time,type,channel,fail_reason';
|
||||
return $this->model->where([ [ 'site_id', '=', $this->site_id ], ['id', '=', $id ] ])
|
||||
return $this->model->where([ [ 'site_id', '=', $this->site_id ], [ 'id', '=', $id ] ])
|
||||
->field($field)
|
||||
->append([ 'type_name', 'channel_name', 'status_name' ])
|
||||
->findOrEmpty()
|
||||
@ -58,8 +70,9 @@ class PayService extends BaseAdminService
|
||||
* @param string $out_trade_no
|
||||
* @return null
|
||||
*/
|
||||
public function pass(string $out_trade_no) {
|
||||
return (new CoreOfflineService())->pass($this->site_id, $out_trade_no);
|
||||
public function pass(string $out_trade_no)
|
||||
{
|
||||
return ( new CoreOfflineService() )->pass($this->site_id, $out_trade_no);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,8 +80,9 @@ class PayService extends BaseAdminService
|
||||
* @param string $out_trade_no
|
||||
* @param string $reason
|
||||
*/
|
||||
public function refuse(string $out_trade_no, string $reason) {
|
||||
return (new CoreOfflineService())->refuse($this->site_id, $out_trade_no, $reason);
|
||||
public function refuse(string $out_trade_no, string $reason)
|
||||
{
|
||||
return ( new CoreOfflineService() )->refuse($this->site_id, $out_trade_no, $reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,4 +95,131 @@ class PayService extends BaseAdminService
|
||||
{
|
||||
return $this->model->where($where)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 去支付
|
||||
* @param string $type
|
||||
* @param string $trade_type
|
||||
* @param int $trade_id
|
||||
* @param string $return_url
|
||||
* @param string $quit_url
|
||||
* @param string $buyer_id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function pay(string $type, string $trade_type, int $trade_id, string $return_url = '', string $quit_url = '', string $buyer_id = '', string $voucher = '', string $openid = '')
|
||||
{
|
||||
return ( new CorePayService() )->pay($this->site_id, $trade_type, $trade_id, $type, ChannelDict::PC, $openid, $return_url, $quit_url, $buyer_id, $voucher);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付信息
|
||||
* @param string $trade_type
|
||||
* @param int $trade_id
|
||||
* @return array
|
||||
*/
|
||||
public function getInfoByTrade(string $trade_type, int $trade_id)
|
||||
{
|
||||
return ( new CorePayService() )->getInfoByTrade($this->site_id, $trade_type, $trade_id, ChannelDict::H5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取找朋友帮忙付支付信息
|
||||
* @param string $trade_type
|
||||
* @param int $trade_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFriendspayInfoByTrade(string $trade_type, int $trade_id, string $channel)
|
||||
{
|
||||
$pay_info = ( new CorePayService() )->getInfoByTrade($this->site_id, $trade_type, $trade_id, ChannelDict::H5, PaySceneDict::FRIENDSPAY);
|
||||
if (!empty($pay_info)) {
|
||||
//海报
|
||||
$poster = ( new Poster() )->field('id')->where([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', 'friendspay' ],
|
||||
[ 'status', '=', 1 ],
|
||||
[ 'is_default', '=', 1 ]
|
||||
])->findOrEmpty()->toArray();
|
||||
if (!empty($poster)) {
|
||||
$pay_info[ 'poster_id' ] = $poster[ 'id' ];
|
||||
}
|
||||
//发起帮付会员信息
|
||||
$member = ( new Member() )->field('member_id,nickname,headimg')->where([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'member_id', '=', $pay_info[ 'from_main_id' ] ]
|
||||
])->findOrEmpty()->toArray();
|
||||
$pay_info[ 'member' ] = $member;
|
||||
//二维码
|
||||
$qrcode = $this->getQrcode($trade_type, $trade_id, $channel);
|
||||
$pay_info[ 'link' ] = $qrcode[ 'url' ];
|
||||
$pay_info[ 'qrcode' ] = $qrcode[ 'path' ];
|
||||
}
|
||||
return $pay_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取找朋友帮忙付二维码
|
||||
* @param string $trade_type
|
||||
* @param int $trade_id
|
||||
* @return array
|
||||
*/
|
||||
public function getQrcode(string $trade_type, int $trade_id, string $channel)
|
||||
{
|
||||
$url = ( new CoreSysConfigService() )->getSceneDomain($this->site_id)[ 'wap_url' ];
|
||||
$page = 'app/pages/friendspay/money';
|
||||
|
||||
$data = [
|
||||
[
|
||||
'key' => 'id',
|
||||
'value' => $trade_id
|
||||
],
|
||||
[
|
||||
'key' => 'type',
|
||||
'value' => $trade_type
|
||||
]
|
||||
];
|
||||
$dir = 'upload/' . $this->site_id . '/friendspay_qrcode';
|
||||
|
||||
$path = '';
|
||||
try {
|
||||
$path = qrcode($url, $page, $data, $this->site_id, $dir, $channel);
|
||||
} catch (\Exception $e) {
|
||||
Log::write('找朋友帮忙付二维码生成error' . $e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
|
||||
$url = $url . '/' . $page;
|
||||
$scene = [];
|
||||
foreach ($data as $v) {
|
||||
$scene[] = $v[ 'key' ] . '=' . $v[ 'value' ];
|
||||
}
|
||||
$url .= '?' . implode('&', $scene);
|
||||
|
||||
return [
|
||||
'url' => $url,
|
||||
'path' => $path
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付方式列表
|
||||
* @return array|array[]
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getPayTypeList()
|
||||
{
|
||||
$pay_type_list = ( new CorePayService() )->getPayTypeByTrade($this->site_id, '', ChannelDict::H5);
|
||||
if (!empty($pay_type_list)) {
|
||||
foreach ($pay_type_list as $k => $v) {
|
||||
if (!in_array($v['key'], [ PayDict::BALANCEPAY, PayDict::FRIENDSPAY ])) {
|
||||
unset($pay_type_list[ $k ]);
|
||||
}
|
||||
}
|
||||
$pay_type_list = array_values($pay_type_list);
|
||||
}
|
||||
return $pay_type_list;
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,6 +88,7 @@ class SiteService extends BaseAdminService
|
||||
if (!empty($info)) {
|
||||
$site_addons = ( new CoreSiteService() )->getAddonKeysBySiteId($site_id);
|
||||
$info[ 'site_addons' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ] ])->field('key,title,desc,icon,type')->select()->toArray();
|
||||
$info['uid'] = ( new SysUserRole() )->where([ [ 'site_id', '=', $site_id ], [ 'is_admin', '=', 1 ] ])->value('uid');
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
@ -164,7 +165,6 @@ class SiteService extends BaseAdminService
|
||||
{
|
||||
$site = $this->model->where([ [ 'site_id', '=', $site_id ] ])->with([ 'site_group' ])->findOrEmpty();
|
||||
if ($site->isEmpty()) throw new AdminException('SITE_NOT_EXIST');
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
if (isset($data[ 'group_id' ]) && $site[ 'group_id' ] != $data[ 'group_id' ]) {
|
||||
@ -189,6 +189,26 @@ class SiteService extends BaseAdminService
|
||||
if (isset($data[ 'expire_time' ]) && !empty($data[ 'expire_time' ])) {
|
||||
$data[ 'status' ] = strtotime($data[ 'expire_time' ]) > time() ? SiteDict::ON : SiteDict::EXPIRE;
|
||||
}
|
||||
|
||||
if (isset($data['uid'])){
|
||||
if ($data[ 'uid' ] > 0) {
|
||||
( new UserRoleService() )->editAdmin($site_id,$data['uid']);
|
||||
} else {
|
||||
//添加用户
|
||||
$data_user = [
|
||||
'username' => $data[ 'username' ],
|
||||
'head_img' => $data[ 'head_img' ] ?? '',
|
||||
'status' => $data[ 'status' ] ?? 1,
|
||||
'real_name' => $data[ 'real_name' ] ?? '',
|
||||
'password' => $data[ 'password' ],
|
||||
'role_ids' => '',
|
||||
'is_admin' => 1
|
||||
];
|
||||
$data[ 'uid' ] = ( new UserService() )->add($data_user);
|
||||
( new UserRoleService() )->editAdmin($site_id,$data['uid']);
|
||||
}
|
||||
}
|
||||
|
||||
$site->save($data);
|
||||
|
||||
Cache::tag(self::$cache_tag_name . $site_id)->clear();
|
||||
|
||||
@ -149,5 +149,22 @@ class UserRoleService extends BaseAdminService
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改站点管理员
|
||||
* @param int $site_id
|
||||
* @param int $uid
|
||||
* @return bool
|
||||
*/
|
||||
public function editAdmin(int $site_id, int $uid){
|
||||
$user_role = $this->model->where([['is_admin', '=', 1], ['site_id', '=', $site_id]])->findOrEmpty();
|
||||
if ($user_role->isEmpty())
|
||||
throw new AdminException('USER_NOT_EXIST');
|
||||
$user_role->uid = $uid;
|
||||
$user_role->save();
|
||||
Cache::delete('user_role_'.$uid.'_'.$site_id);
|
||||
Cache::delete('user_role_list_' .$uid);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
namespace app\service\api\member;
|
||||
|
||||
use app\model\member\MemberAddress;
|
||||
use app\service\core\member\CoreMemberAddressService;
|
||||
use core\base\BaseApiService;
|
||||
|
||||
|
||||
@ -35,11 +36,9 @@ class AddressService extends BaseApiService
|
||||
*/
|
||||
public function getList(array $where = [])
|
||||
{
|
||||
$field = 'id, member_id, name, mobile, province_id, city_id, district_id, address, address_name, full_address, lng, lat, is_default';
|
||||
$order = 'is_default desc, id desc';
|
||||
|
||||
$list = $this->model->where([ ['site_id', '=', $this->site_id],['member_id', '=', $this->member_id ] ])->field($field)->order($order)->select()->toArray();
|
||||
return $list;
|
||||
$where['member_id'] = $this->member_id;
|
||||
$where['site_id'] = $this->site_id;
|
||||
return ( new CoreMemberAddressService() )->getList($where);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,10 +48,9 @@ class AddressService extends BaseApiService
|
||||
*/
|
||||
public function getInfo(int $id)
|
||||
{
|
||||
$field = 'id,member_id,name,mobile,province_id,city_id,district_id,address,address_name,full_address,lng,lat,is_default';
|
||||
|
||||
$info = $this->model->field($field)->where([ ['id', '=', $id], ['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id ] ])->findOrEmpty()->toArray();
|
||||
return $info;
|
||||
$data['member_id'] = $this->member_id;
|
||||
$data['site_id'] = $this->site_id;
|
||||
return ( new CoreMemberAddressService() )->getInfo($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,13 +60,9 @@ class AddressService extends BaseApiService
|
||||
*/
|
||||
public function add(array $data)
|
||||
{
|
||||
if ($data['is_default']) {
|
||||
$this->model->where([ ['member_id', '=', $this->member_id ] ])->update(['is_default' => 0]);
|
||||
}
|
||||
$data['member_id'] = $this->member_id;
|
||||
$data['site_id'] = $this->site_id;
|
||||
$res = $this->model->create($data);
|
||||
return $res->id;
|
||||
return ( new CoreMemberAddressService() )->add($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,11 +73,9 @@ class AddressService extends BaseApiService
|
||||
*/
|
||||
public function edit(int $id, array $data)
|
||||
{
|
||||
if ($data['is_default']) {
|
||||
$this->model->where([ ['member_id', '=', $this->member_id ] ])->update(['is_default' => 0]);
|
||||
}
|
||||
$this->model->where([ ['id', '=', $id], ['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id ] ])->update($data);
|
||||
return true;
|
||||
$data['member_id'] = $this->member_id;
|
||||
$data['site_id'] = $this->site_id;
|
||||
return ( new CoreMemberAddressService() )->edit($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -12,9 +12,15 @@
|
||||
namespace app\service\api\pay;
|
||||
|
||||
use app\dict\common\ChannelDict;
|
||||
use app\dict\pay\PayDict;
|
||||
use app\dict\pay\PaySceneDict;
|
||||
use app\model\member\Member;
|
||||
use app\model\pay\Pay;
|
||||
use app\model\sys\Poster;
|
||||
use app\service\core\member\CoreMemberService;
|
||||
use app\service\core\pay\CorePayService;
|
||||
use core\base\BaseApiService;
|
||||
use core\exception\ApiException;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
@ -57,7 +63,7 @@ class PayService extends BaseApiService
|
||||
break;
|
||||
}
|
||||
|
||||
return $this->core_pay_service->pay($this->site_id, $trade_type, $trade_id, $type, $this->channel, $openid, $return_url, $quit_url, $buyer_id, $voucher);
|
||||
return $this->core_pay_service->pay($this->site_id, $trade_type, $trade_id, $type, $this->channel, $openid, $return_url, $quit_url, $buyer_id, $voucher, $this->member_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,8 +96,48 @@ class PayService extends BaseApiService
|
||||
return $this->core_pay_service->getInfoByOutTradeNo($this->site_id, $out_trade_no, $this->channel);
|
||||
}
|
||||
|
||||
public function getInfoByTrade(string $trade_type, int $trade_id){
|
||||
return $this->core_pay_service->getInfoByTrade($this->site_id, $trade_type, $trade_id, $this->channel);
|
||||
public function getInfoByTrade(string $trade_type, int $trade_id, array $data){
|
||||
return $this->core_pay_service->getInfoByTrade($this->site_id, $trade_type, $trade_id, $this->channel, $data['scene']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取找朋友帮忙付支付信息
|
||||
* @param string $trade_type
|
||||
* @param int $trade_id
|
||||
* @return array
|
||||
*/
|
||||
public function getFriendspayInfoByTrade($trade_type, $trade_id){
|
||||
$from_pay_info = ( new Pay() )->field('site_id')->where([ [ 'trade_type', '=', $trade_type ], [ 'trade_id', '=', $trade_id ] ])->findOrEmpty()->toArray();//查询发起交易所属的站点id
|
||||
if (empty($from_pay_info)) throw new ApiException('TRADE_NOT_EXIST');
|
||||
if ($from_pay_info['site_id'] != $this->site_id) throw new ApiException('TRADE_NOT_EXIST');//不是同一站点的用户不能帮付
|
||||
$pay_info = $this->core_pay_service->getInfoByTrade($from_pay_info[ 'site_id' ], $trade_type, $trade_id, $this->channel, PaySceneDict::FRIENDSPAY);
|
||||
if (!empty($pay_info)) {
|
||||
//todo 查询订单交易信息,其它插件可实现该钩子
|
||||
$trade_info = array_values(array_filter(event('PayTradeInfo',[ 'trade_type' => $trade_type, 'trade_id' => $trade_id ])))[0] ?? [];
|
||||
$pay_info['trade_info'] = $trade_info;
|
||||
if ($pay_info['from_main_id'] != $this->member_id) {
|
||||
$pay_info['is_self'] = false;
|
||||
} else {
|
||||
$pay_info['is_self'] = true;
|
||||
}
|
||||
//海报
|
||||
$poster = ( new Poster() )->field('id')->where([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', 'friendspay' ],
|
||||
[ 'status', '=', 1 ],
|
||||
[ 'is_default', '=', 1 ]
|
||||
])->findOrEmpty()->toArray();
|
||||
if (!empty($poster)) {
|
||||
$pay_info['poster_id'] = $poster['id'];
|
||||
}
|
||||
//发起帮付会员信息
|
||||
$member = ( new Member() )->field('member_id,nickname,headimg')->where([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'member_id', '=', $pay_info['from_main_id'] ]
|
||||
])->findOrEmpty()->toArray();
|
||||
$pay_info['member'] = $member;
|
||||
}
|
||||
return $pay_info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -116,4 +116,4 @@ class VerifyService extends BaseApiService
|
||||
])->field($field)->append([ 'type_name' ])->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ namespace app\service\core\member;
|
||||
|
||||
use app\model\member\MemberAddress;
|
||||
use core\base\BaseCoreService;
|
||||
use core\exception\CommonException;
|
||||
|
||||
/**
|
||||
* 会员标签服务层
|
||||
@ -28,6 +29,66 @@ class CoreMemberAddressService extends BaseCoreService
|
||||
$this->model = new MemberAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员收货地址列表
|
||||
* @param array $where
|
||||
* @return array
|
||||
*/
|
||||
public function getList(array $where = [])
|
||||
{
|
||||
if (empty($where['member_id'])) throw new CommonException('MEMBER_NOT_EXIST');
|
||||
$field = 'id, member_id, name, mobile, province_id, city_id, district_id, address, address_name, full_address, lng, lat, is_default';
|
||||
$order = 'is_default desc, id desc';
|
||||
|
||||
$list = $this->model->where([ ['site_id', '=', $where['site_id']],['member_id', '=', $where['member_id'] ] ])->field($field)->order($order)->select()->toArray();
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员收货地址信息
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function getInfo(int $id, array $data)
|
||||
{
|
||||
if (empty($data['member_id'])) throw new CommonException('MEMBER_NOT_EXIST');
|
||||
$field = 'id,member_id,name,mobile,province_id,city_id,district_id,address,address_name,full_address,lng,lat,is_default';
|
||||
|
||||
$info = $this->model->field($field)->where([ ['id', '=', $id], ['site_id', '=', $data['site_id']], ['member_id', '=', $data['member_id'] ] ])->findOrEmpty()->toArray();
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加会员收货地址
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function add(array $data)
|
||||
{
|
||||
if (empty($data['member_id'])) throw new CommonException('MEMBER_NOT_EXIST');
|
||||
if ($data['is_default']) {
|
||||
$this->model->where([ ['member_id', '=', $data['member_id'] ] ])->update(['is_default' => 0]);
|
||||
}
|
||||
$res = $this->model->create($data);
|
||||
return $res->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员收货地址编辑
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function edit(int $id, array $data)
|
||||
{
|
||||
if (empty($data['member_id'])) throw new CommonException('MEMBER_NOT_EXIST');
|
||||
if ($data['is_default']) {
|
||||
$this->model->where([ ['member_id', '=', $data['member_id'] ] ])->update(['is_default' => 0]);
|
||||
}
|
||||
$this->model->where([ ['id', '=', $id], ['site_id', '=', $data['site_id']], ['member_id', '=', $data['member_id'] ] ])->update($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员默认地址
|
||||
|
||||
@ -175,7 +175,7 @@ class CoreMemberService extends BaseCoreService
|
||||
*/
|
||||
public static function sendGrowth(int $site_id, int $member_id, string $key, array $param = []) {
|
||||
$config = (new CoreMemberConfigService())->getGrowthRuleConfig($site_id);
|
||||
if (!isset($config[$key]) || empty($config[$key]) || !$config[$key]['is_use']) return true;
|
||||
if (!isset($config[$key]) || empty($config[$key]) || empty($config[$key]['is_use'])) return true;
|
||||
|
||||
$config = $config[$key];
|
||||
|
||||
@ -209,7 +209,7 @@ class CoreMemberService extends BaseCoreService
|
||||
*/
|
||||
public static function sendPoint(int $site_id, int $member_id, string $key, array $param = []) {
|
||||
$config = (new CoreMemberConfigService())->getPointRuleConfig($site_id)['grant'] ?? [];
|
||||
if (!isset($config[$key]) || empty($config[$key]) || !$config[$key]['is_use']) return true;
|
||||
if (!isset($config[$key]) || empty($config[$key]) || empty($config[$key]['is_use'])) return true;
|
||||
|
||||
$config = $config[$key];
|
||||
|
||||
|
||||
@ -41,8 +41,9 @@ class CorePayChannelService extends BaseCoreService
|
||||
* @param array $where
|
||||
* @return PayChannel|array|mixed|Model
|
||||
*/
|
||||
public function find(int $site_id, array $where){
|
||||
$where['site_id'] = $site_id;
|
||||
public function find(int $site_id, array $where)
|
||||
{
|
||||
$where[ 'site_id' ] = $site_id;
|
||||
return $this->model->where($where)->findOrEmpty();
|
||||
}
|
||||
|
||||
@ -56,21 +57,35 @@ class CorePayChannelService extends BaseCoreService
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getAllowPayTypeByChannel(int $site_id, string $channel, string $trade_type = ''){
|
||||
$channel_pay_list = $this->model->where([['site_id', '=', $site_id], ['channel', '=', $channel], ['status', '=', 1]])->field('type,config')->order('sort asc')->select()->toArray();
|
||||
public function getAllowPayTypeByChannel(int $site_id, string $channel, string $trade_type = '')
|
||||
{
|
||||
$channel_pay_list = $this->model->where([ [ 'site_id', '=', $site_id ], [ 'channel', '=', $channel ], [ 'status', '=', 1 ] ])->field('type,config')->order('sort asc')->select()->toArray();
|
||||
|
||||
if(!empty($channel_pay_list)){
|
||||
if (!empty($channel_pay_list)) {
|
||||
$temp_channel_pay_list = array_column($channel_pay_list, 'type');
|
||||
$pay_type_list = PayDict::getPayType($temp_channel_pay_list);
|
||||
$pay_type_arr = PayDict::getPayType($temp_channel_pay_list);
|
||||
foreach ($temp_channel_pay_list as $key) {
|
||||
if (isset($pay_type_arr[$key])) {
|
||||
$pay_type_list[$key] = $pay_type_arr[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
//充值订单不支持余额支付
|
||||
if(!empty($pay_type_list) && $trade_type == 'recharge'){
|
||||
unset($pay_type_list[PayDict::BALANCEPAY]);
|
||||
//充值订单不支持余额支付和找朋友帮忙付
|
||||
if (!empty($pay_type_list) && $trade_type == 'recharge') {
|
||||
unset($pay_type_list[ PayDict::BALANCEPAY ], $pay_type_list[ PayDict::FRIENDSPAY ]);
|
||||
}
|
||||
// 线下支付做处理
|
||||
if (!empty($pay_type_list) && isset($pay_type_list[PayDict::OFFLINEPAY])) {
|
||||
if (!empty($pay_type_list) && isset($pay_type_list[ PayDict::OFFLINEPAY ])) {
|
||||
$temp_channel_pay_list = array_column($channel_pay_list, null, 'type');
|
||||
$pay_type_list[PayDict::OFFLINEPAY]['config'] = $temp_channel_pay_list[PayDict::OFFLINEPAY]['config'];
|
||||
$pay_type_list[ PayDict::OFFLINEPAY ][ 'config' ] = $temp_channel_pay_list[ PayDict::OFFLINEPAY ][ 'config' ];
|
||||
}
|
||||
// 找朋友帮忙付做处理
|
||||
if (!empty($pay_type_list) && isset($pay_type_list[ PayDict::FRIENDSPAY ])) {
|
||||
$temp_channel_pay_list = array_column($channel_pay_list, null, 'type');
|
||||
$pay_type_list[ PayDict::FRIENDSPAY ][ 'config' ] = $temp_channel_pay_list[ PayDict::FRIENDSPAY ][ 'config' ];
|
||||
if (!empty($temp_channel_pay_list[ PayDict::FRIENDSPAY ][ 'config' ])) {
|
||||
$pay_type_list[ PayDict::FRIENDSPAY ][ 'name' ] = $temp_channel_pay_list[ PayDict::FRIENDSPAY ][ 'config' ][ 'pay_type_name' ];
|
||||
}
|
||||
}
|
||||
return $pay_type_list ?? [];
|
||||
|
||||
@ -83,10 +98,11 @@ class CorePayChannelService extends BaseCoreService
|
||||
* @param string $type
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getConfigByChannelAndType(int $site_id, string $channel, string $type){
|
||||
$pay_channel = $this->model->where([['site_id', '=', $site_id], ['channel', '=', $channel], ['type', '=', $type]])->field('config')->findOrEmpty();
|
||||
if(!$pay_channel->isEmpty()){
|
||||
if($type == PayDict::WECHATPAY){
|
||||
public function getConfigByChannelAndType(int $site_id, string $channel, string $type)
|
||||
{
|
||||
$pay_channel = $this->model->where([ [ 'site_id', '=', $site_id ], [ 'channel', '=', $channel ], [ 'type', '=', $type ] ])->field('config')->findOrEmpty();
|
||||
if (!$pay_channel->isEmpty()) {
|
||||
if ($type == PayDict::WECHATPAY) {
|
||||
$pay_channel->config = array_merge($pay_channel->config, $this->getWechatPayFullConfig($site_id));
|
||||
}
|
||||
return $pay_channel->config;
|
||||
@ -94,20 +110,20 @@ class CorePayChannelService extends BaseCoreService
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取完整的微信支付配置(根据场景)
|
||||
* @param int $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getWechatPayFullConfig(int $site_id){
|
||||
public function getWechatPayFullConfig(int $site_id)
|
||||
{
|
||||
//TODO 先判断是否是开放平台授权,然后再决定使用什么appid
|
||||
//查询公众号配置
|
||||
$core_wechat_config_service = new CoreWechatConfigService();
|
||||
$mp_app_id = $core_wechat_config_service->getWechatConfig($site_id)['app_id'];//公众号appid
|
||||
$mp_app_id = $core_wechat_config_service->getWechatConfig($site_id)[ 'app_id' ];//公众号appid
|
||||
//查询公众号配置
|
||||
$core_weapp_config_service = new CoreWeappConfigService();
|
||||
$mini_app_id = $core_weapp_config_service->getWeappConfig($site_id)['app_id'];//小程序appid
|
||||
$mini_app_id = $core_weapp_config_service->getWeappConfig($site_id)[ 'app_id' ];//小程序appid
|
||||
//todo 查询微信小程序 appid . 应用appid.....
|
||||
return [
|
||||
'mp_app_id' => $mp_app_id,
|
||||
@ -115,4 +131,4 @@ class CorePayChannelService extends BaseCoreService
|
||||
//............
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ use think\Response;
|
||||
use Yansongda\Pay\Exception\ContainerException;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Exception\ServiceNotFoundException;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
/**
|
||||
* 支付服务层
|
||||
@ -43,7 +42,6 @@ class CorePayEventService extends BaseCoreService
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付引擎外置触点初始化
|
||||
* @param int $site_id
|
||||
@ -74,7 +72,6 @@ class CorePayEventService extends BaseCoreService
|
||||
return new PayLoader($this->type, $this->config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 去支付
|
||||
* @param string $out_trade_no
|
||||
|
||||
@ -13,6 +13,7 @@ namespace app\service\core\pay;
|
||||
|
||||
use app\dict\pay\OnlinePayDict;
|
||||
use app\dict\pay\PayDict;
|
||||
use app\dict\pay\PaySceneDict;
|
||||
use app\job\pay\PayReturnTo;
|
||||
use app\model\pay\Pay;
|
||||
use core\base\BaseCoreService;
|
||||
@ -21,7 +22,6 @@ use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
use think\Model;
|
||||
use Throwable;
|
||||
|
||||
@ -63,6 +63,7 @@ class CorePayService extends BaseCoreService
|
||||
'body' => $body,
|
||||
'out_trade_no' => $out_trade_no,
|
||||
'main_id' => $main_id,
|
||||
'from_main_id' => $main_id,
|
||||
'main_type' => $main_type
|
||||
);
|
||||
$this->model->create($data);
|
||||
@ -127,6 +128,32 @@ class CorePayService extends BaseCoreService
|
||||
return $pay;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过业务类型和id查询支付状态
|
||||
* @param int $site_id
|
||||
* @param string $trade_type
|
||||
* @param int $trade_id
|
||||
* @return bool
|
||||
*/
|
||||
public function getPayStatusByTrade(int $site_id, string $trade_type, int $trade_id)
|
||||
{
|
||||
$where = array(
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'trade_type', '=', $trade_type ],
|
||||
[ 'trade_id', '=', $trade_id ],
|
||||
);
|
||||
$pay_info = $this->model->field('status')->where($where)->findOrEmpty();
|
||||
if ($pay_info->isEmpty()) {
|
||||
throw new PayException('TRADE_NOT_EXIST');//支付单据不存在
|
||||
} else {
|
||||
if ($pay_info[ 'status' ] == PayDict::STATUS_FINISH) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过交易信息获取支付单据
|
||||
* @param int $site_id
|
||||
@ -138,7 +165,7 @@ class CorePayService extends BaseCoreService
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getInfoByTrade(int $site_id, string $trade_type, string $trade_id, string $channel)
|
||||
public function getInfoByTrade(int $site_id, string $trade_type, string $trade_id, string $channel, string $scene = '')
|
||||
{
|
||||
$pay = $this->findPayInfoByTrade($site_id, $trade_type, $trade_id);
|
||||
if ($pay->isEmpty()) {
|
||||
@ -150,7 +177,13 @@ class CorePayService extends BaseCoreService
|
||||
}
|
||||
if (!empty($pay)) {
|
||||
//todo 校验场景控制支付方式
|
||||
$pay[ 'pay_type_list' ] = array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $pay[ 'trade_type' ]));
|
||||
$pay_type_list = ( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $pay[ 'trade_type' ]);
|
||||
//找朋友帮忙付时不支持找朋友帮忙付
|
||||
if(!empty($pay_type_list) && !empty($pay_type_list[PayDict::FRIENDSPAY]) && $scene == PaySceneDict::FRIENDSPAY){
|
||||
$pay[ 'config' ] = $pay_type_list[PayDict::FRIENDSPAY]['config'];
|
||||
unset($pay_type_list[PayDict::FRIENDSPAY]);
|
||||
}
|
||||
$pay[ 'pay_type_list' ] = array_values($pay_type_list);
|
||||
}
|
||||
return $pay;
|
||||
}
|
||||
@ -187,7 +220,7 @@ class CorePayService extends BaseCoreService
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function pay($site_id, $trade_type, $trade_id, $type, $channel, string $openid, string $return_url = '', string $quit_url = '', string $buyer_id = '', string $voucher = '')
|
||||
public function pay($site_id, $trade_type, $trade_id, $type, $channel, string $openid, string $return_url = '', string $quit_url = '', string $buyer_id = '', string $voucher = '', $member_id = 0)
|
||||
{
|
||||
//检测并创建支付单据
|
||||
$pay = $this->checkOrCreate($site_id, $trade_type, $trade_id);
|
||||
@ -196,10 +229,19 @@ class CorePayService extends BaseCoreService
|
||||
$body = $pay[ 'body' ];
|
||||
$trade_type = $pay[ 'trade_type' ];
|
||||
if (!in_array($type, array_column(( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $trade_type), 'key'))) throw new PayException('PAYMENT_METHOD_NOT_SCENE');//场景不支持
|
||||
if ($member_id != 0) {
|
||||
//更新付款人id
|
||||
$pay_info = $this->findPayInfoByTrade($site_id, $trade_type, $trade_id);
|
||||
$pay_info->save([
|
||||
'main_id' => $member_id
|
||||
]);
|
||||
}
|
||||
$pay_result = $this->pay_event->init($site_id, $channel, $type)->pay($out_trade_no, $money, $body, $return_url, $quit_url, $buyer_id, $openid ?? '', $voucher);
|
||||
//todo 特殊支付方式会直接返回支付状态,状态如果为已支付会直接支付
|
||||
if (!empty($pay_result[ 'status' ]) && $pay_result[ 'status' ] == PayDict::STATUS_FINISH) {
|
||||
$pay->save([ 'channel' => $channel ]);
|
||||
$pay->save([
|
||||
'channel' => $channel
|
||||
]);
|
||||
$this->paySuccess($site_id, [
|
||||
'status' => PayDict::STATUS_FINISH,
|
||||
'type' => $type,
|
||||
@ -509,6 +551,7 @@ class CorePayService extends BaseCoreService
|
||||
$type = $params[ 'type' ];
|
||||
$trade_type = $pay->trade_type;
|
||||
$trade_id = $pay->trade_id;
|
||||
$main_id = $pay->main_id;
|
||||
$data = array(
|
||||
'pay_time' => time(),
|
||||
'status' => PayDict::STATUS_FINISH,
|
||||
@ -524,7 +567,7 @@ class CorePayService extends BaseCoreService
|
||||
Db::startTrans();
|
||||
try {
|
||||
$pay->allowField($allow_field)->save($data);
|
||||
$result = event('PaySuccess', [ 'out_trade_no' => $out_trade_no, 'trade_type' => $trade_type, 'site_id' => $site_id, 'trade_id' => $trade_id ]);
|
||||
$result = event('PaySuccess', [ 'out_trade_no' => $out_trade_no, 'trade_type' => $trade_type, 'site_id' => $site_id, 'trade_id' => $trade_id, 'main_id' => $main_id ]);
|
||||
// if (!check_event_result($result)) {
|
||||
// Db::rollback();
|
||||
// return false;
|
||||
|
||||
@ -21,7 +21,7 @@ use Throwable;
|
||||
|
||||
/**
|
||||
* 退款服务层
|
||||
* Class CorePayService
|
||||
* Class CoreRefundService
|
||||
* @package app\service\core\pay
|
||||
*/
|
||||
class CoreRefundService extends BaseCoreService
|
||||
|
||||
46
niucloud/app/upgrade/v056/Upgrade.php
Normal file
46
niucloud/app/upgrade/v056/Upgrade.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\upgrade\v056;
|
||||
|
||||
use app\model\diy\Diy;
|
||||
use app\model\site\Site;
|
||||
use app\model\sys\Poster;
|
||||
use app\service\core\poster\CorePosterService;
|
||||
|
||||
class Upgrade
|
||||
{
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->handleDiyData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理自定义数据
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
private function handleDiyData()
|
||||
{
|
||||
$site_model = new Site();
|
||||
$site_ids = $site_model->column('site_id');
|
||||
|
||||
$poster_model = new Poster();
|
||||
$poster = new CorePosterService();
|
||||
$template = $poster->getTemplateList('', 'friendspay')[ 0 ];
|
||||
|
||||
$poster_model->where([ ['type','=','friendspay'] ])->delete();
|
||||
foreach ($site_ids as $site_id) {
|
||||
// 创建默认找朋友帮忙付海报
|
||||
$poster->add($site_id, '', [
|
||||
'name' => $template[ 'name' ],
|
||||
'type' => $template[ 'type' ],
|
||||
'value' => $template[ 'data' ],
|
||||
'status' => 1,
|
||||
'is_default' => 1
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
4
niucloud/app/upgrade/v056/upgrade.sql
Normal file
4
niucloud/app/upgrade/v056/upgrade.sql
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
ALTER TABLE `pay` ADD COLUMN `from_main_id` INT(11) NOT NULL DEFAULT 0 COMMENT '发起支付会员id';
|
||||
|
||||
ALTER TABLE `pay` MODIFY `from_main_id` INT(11) NOT NULL DEFAULT 0 COMMENT '发起支付会员id' AFTER `main_id`;
|
||||
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\validate\article;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* Class Article
|
||||
* @package app\validate\article
|
||||
*/
|
||||
class Article extends Validate
|
||||
{
|
||||
|
||||
//用户名或密码的规范可能是从数据库中获取的
|
||||
protected $rule = [
|
||||
'title' => 'require|max:20',
|
||||
'intro' => 'max:50',
|
||||
'summary' => 'max:50',
|
||||
'image' => 'max:100',
|
||||
'author' => 'max:20',
|
||||
'is_show' => 'number|between:0,1',
|
||||
'sort' => 'number|between:0,10000',
|
||||
'category_id' => 'number|require',
|
||||
'content' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'title.require' => 'validate_article.title_require',
|
||||
'title.max' => 'validate_article.title_max',
|
||||
'intro.max' => 'validate_article.intro_max',
|
||||
'summary.max' => 'validate_article.summary_max',
|
||||
'image.max' => 'validate_article.image_max',
|
||||
'author.max' => 'validate_article.author_max',
|
||||
'is_show.number' => 'validate_article.is_show_number',
|
||||
'is_show.between' => 'validate_article.is_show_between',
|
||||
'sort.number' => 'validate_article.sort_number',
|
||||
'sort.between' => 'validate_article.sort_between',
|
||||
'category_id.require' => 'validate_article.category_id_require',
|
||||
'category_id.number' => 'validate_article.category_id_number',
|
||||
'content.require' => 'validate_article.content_require',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['title', 'intro', 'summary', 'image', 'author', 'is_show', 'sort', 'content', 'category_id'],
|
||||
'edit' => ['title', 'intro', 'summary', 'image', 'author', 'is_show', 'sort', 'content', 'category_id'],
|
||||
];
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\validate\article;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 文章分类(栏目)验证
|
||||
* Class Article
|
||||
* @package app\validate\article
|
||||
*/
|
||||
class ArticleCategory extends Validate
|
||||
{
|
||||
|
||||
//用户名或密码的规范可能是从数据库中获取的
|
||||
protected $rule = [
|
||||
'name' => 'require|max:20',
|
||||
'is_show' => 'number|between:0,1',
|
||||
'sort' => 'number|between:0,10000'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => 'validate_article.cate_name_require',
|
||||
'name.max' => 'validate_article.cate_name_max',
|
||||
'is_show.number' => 'validate_article.is_show_number',
|
||||
'is_show.between' => 'validate_article.is_show_between',
|
||||
'sort.number' => 'validate_article.sort_number',
|
||||
'sort.between' => 'validate_article.sort_between',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['name', 'is_show', 'sort'],
|
||||
'edit' => ['name', 'is_show', 'sort'],
|
||||
];
|
||||
}
|
||||
37
niucloud/app/validate/diy/DiyForm.php
Normal file
37
niucloud/app/validate/diy/DiyForm.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\validate\diy;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 系统表单验证器
|
||||
* Class DiyForm
|
||||
* @package app\validate\diy
|
||||
*/
|
||||
class DiyForm extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'title' => 'require',
|
||||
'type' => 'require',
|
||||
'value' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [];
|
||||
|
||||
protected $scene = [
|
||||
"add" => [ 'title', 'type', 'value' ],
|
||||
"edit" => [ 'title', 'value' ],
|
||||
];
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'version' => '0.5.5',
|
||||
'code' => '202412030001'
|
||||
'version' => '0.5.6',
|
||||
'code' => '202412210001'
|
||||
];
|
||||
|
||||
43
niucloud/core/dict/RechargeGift.php
Normal file
43
niucloud/core/dict/RechargeGift.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Niucloud-admin 企业快速开发的saas管理平台
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网址:https://www.niucloud.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | niucloud团队 版权所有 开源版本可自由商用
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Niucloud Team
|
||||
// +----------------------------------------------------------------------
|
||||
namespace core\dict;
|
||||
|
||||
class RechargeGift extends BaseDict
|
||||
{
|
||||
/**
|
||||
* 加载会员充值赠品组件
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function load(array $data = [])
|
||||
{
|
||||
$addons = $this->getLocalAddons();
|
||||
foreach ($addons as $v) {
|
||||
$addon_change_type_file = $this->getAddonDictPath($v) . "recharge" . DIRECTORY_SEPARATOR . "package_gift.php";
|
||||
if (is_file($addon_change_type_file)) {
|
||||
$account_change_type_files[] = $addon_change_type_file;
|
||||
}
|
||||
}
|
||||
$account_change_type_datas = $this->loadFiles($account_change_type_files);
|
||||
$account_change_type_array = [];
|
||||
foreach ($account_change_type_datas as $account_change_type_data) {
|
||||
$account_change_type_array = empty($account_change_type_array) ? $account_change_type_data : array_merge2($account_change_type_array, $account_change_type_data);
|
||||
}
|
||||
foreach ($account_change_type_array as $key => &$value) {
|
||||
$value[ 'key' ] = $key;
|
||||
}
|
||||
usort($account_change_type_array, function($list_one, $list_two) {
|
||||
return $list_one[ 'sort' ] <=> $list_two[ 'sort' ];
|
||||
});
|
||||
return $account_change_type_array;
|
||||
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,6 @@ namespace core\pay;
|
||||
use app\dict\pay\OnlinePayDict;
|
||||
use app\dict\pay\RefundDict;
|
||||
use app\dict\pay\TransferDict;
|
||||
use core\exception\CommonException;
|
||||
use core\exception\PayException;
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
@ -53,7 +53,11 @@ class Local extends BaseUpload
|
||||
{
|
||||
try {
|
||||
mkdirs_or_notexist(dirname($key), 0777);
|
||||
$content = @file_get_contents($url);
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$content = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
// $content = @file_get_contents($url);//file_get_contents下载网络图片慢,更换为curl下载
|
||||
if (!empty($content)) {
|
||||
file_put_contents($key, $content);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user