充值和订单相关查询模块
This commit is contained in:
parent
b61a99b060
commit
98da00e975
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace app\api\controller\order;
|
namespace app\api\controller\order;
|
||||||
|
|
||||||
//use app\admin\logic\order\CartLogic;
|
|
||||||
//use app\admin\logic\retail\StoreOrderLogic;
|
|
||||||
use app\api\logic\order\OrderLogic;
|
use app\api\logic\order\OrderLogic;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\api\lists\order\OrderList;
|
use app\api\lists\order\OrderList;
|
||||||
@ -12,12 +10,8 @@ use app\api\validate\OrderValidate;
|
|||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
use app\common\logic\PaymentLogic;
|
use app\common\logic\PaymentLogic;
|
||||||
use app\common\logic\PayNotifyLogic;
|
use app\common\logic\PayNotifyLogic;
|
||||||
use app\common\model\order\Cart;
|
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\model\user\User;
|
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
use app\common\service\wechat\WeChatConfigService;
|
|
||||||
use support\Log;
|
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
use hg\apidoc\annotation as ApiDoc;
|
use hg\apidoc\annotation as ApiDoc;
|
||||||
|
|
||||||
@ -350,7 +344,15 @@ class OrderController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//核销
|
#[
|
||||||
|
ApiDoc\Title('核销'),
|
||||||
|
ApiDoc\url('/api/order/order/writeoff_order'),
|
||||||
|
ApiDoc\Method('POST'),
|
||||||
|
ApiDoc\Param(name: "verify_code", type: "string", require: true, desc: "验证码"),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
public function writeoff_order()
|
public function writeoff_order()
|
||||||
{
|
{
|
||||||
$params = (new OrderValidate())->post()->goCheck('check');
|
$params = (new OrderValidate())->post()->goCheck('check');
|
||||||
|
@ -4,11 +4,13 @@ namespace app\api\controller\user;
|
|||||||
|
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\api\logic\user\UserLogic;
|
use app\api\logic\user\UserLogic;
|
||||||
use app\api\validate\PasswordValidate;
|
|
||||||
use app\api\validate\SetUserInfoValidate;
|
|
||||||
use app\api\validate\UserValidate;
|
use app\api\validate\UserValidate;
|
||||||
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\logic\PaymentLogic;
|
||||||
use hg\apidoc\annotation as ApiDoc;
|
use hg\apidoc\annotation as ApiDoc;
|
||||||
#[ApiDoc\NotParse()]
|
use taoser\Validate;
|
||||||
|
|
||||||
|
#[ApiDoc\title('用户')]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户控制器
|
* 用户控制器
|
||||||
@ -17,14 +19,15 @@ use hg\apidoc\annotation as ApiDoc;
|
|||||||
*/
|
*/
|
||||||
class UserController extends BaseApiController
|
class UserController extends BaseApiController
|
||||||
{
|
{
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('获取小程序手机号'),
|
||||||
/**
|
ApiDoc\url('/api/user/user/getMobileByMnp'),
|
||||||
* @notes 获取小程序手机号
|
ApiDoc\Method('POST'),
|
||||||
* @return
|
ApiDoc\Param(name: "code", type: "string", require: true, desc: "换取手机的code"),
|
||||||
* @author 段誉
|
ApiDoc\NotHeaders(),
|
||||||
* @date 2022/9/21 16:46
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
*/
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
public function getMobileByMnp()
|
public function getMobileByMnp()
|
||||||
{
|
{
|
||||||
$params = (new UserValidate())->post()->goCheck('getMobileByMnp');
|
$params = (new UserValidate())->post()->goCheck('getMobileByMnp');
|
||||||
@ -38,11 +41,44 @@ class UserController extends BaseApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('用户个人信息'),
|
||||||
|
ApiDoc\url('/api/user/user/info'),
|
||||||
|
ApiDoc\Method('POST'),
|
||||||
|
ApiDoc\Param(),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
public function info()
|
public function info()
|
||||||
{
|
{
|
||||||
return $this->success('success', UserLogic::info($this->userId));
|
return $this->success('success', UserLogic::info($this->userId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('小程序充值'),
|
||||||
|
ApiDoc\url('/api/user/user/recharge'),
|
||||||
|
ApiDoc\Method('POST'),
|
||||||
|
ApiDoc\Param(name: "price", type: "string", require: true, desc: "金额"),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
|
public function recharge()
|
||||||
|
{
|
||||||
|
$params = (new UserValidate())->post()->goCheck('rechargeMoney');
|
||||||
|
$params['uid'] = $this->userId;
|
||||||
|
$params['channel_type'] = $this->userInfo['terminal'];
|
||||||
|
$order = UserLogic::recharge($params);
|
||||||
|
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
|
||||||
|
$result = PaymentLogic::pay(PayEnum::WECHAT_PAY, 'StoreOrder', $order, $this->userInfo['terminal'], $redirectUrl);
|
||||||
|
if (PaymentLogic::hasError()) {
|
||||||
|
return $this->fail(PaymentLogic::getError(), $params);
|
||||||
|
}
|
||||||
|
return $this->success('', $result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['paid','status'],
|
'=' => ['paid','status','is_writeoff'],
|
||||||
'between_time' => 'create_time',
|
'between_time' => 'create_time',
|
||||||
'%like%' => ['order_id'],
|
'%like%' => ['order_id'],
|
||||||
];
|
];
|
||||||
@ -44,7 +44,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
{
|
{
|
||||||
$userId=$this->request->userId;
|
$userId=$this->request->userId;
|
||||||
if(!$userId) return [];
|
if(!$userId) return [];
|
||||||
return StoreOrder::where($this->searchWhere)->where('uid',$userId)
|
return StoreOrder::with(['store'])->where($this->searchWhere)->where('uid',$userId)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
@ -416,6 +416,7 @@ class OrderLogic extends BaseLogic
|
|||||||
try {
|
try {
|
||||||
StoreOrder::update([
|
StoreOrder::update([
|
||||||
'status' => OrderEnum::RECEIVED_GOODS,
|
'status' => OrderEnum::RECEIVED_GOODS,
|
||||||
|
'is_writeoff' => OrderEnum::IS_OK,
|
||||||
'update_time' => time(),
|
'update_time' => time(),
|
||||||
], ['id' => $data['id']]);
|
], ['id' => $data['id']]);
|
||||||
(new StoreOrderCartInfo())->update([
|
(new StoreOrderCartInfo())->update([
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
namespace app\api\logic\user;
|
namespace app\api\logic\user;
|
||||||
|
|
||||||
|
|
||||||
use app\common\{logic\BaseLogic, model\system_store\SystemStore, model\user\User, service\wechat\WeChatMnpService};
|
use app\common\{logic\BaseLogic,
|
||||||
|
model\system_store\SystemStore,
|
||||||
|
model\user\User,
|
||||||
|
model\user\UserRecharge,
|
||||||
|
service\wechat\WeChatMnpService};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员逻辑层
|
* 会员逻辑层
|
||||||
@ -78,4 +82,13 @@ class UserLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function recharge($param)
|
||||||
|
{
|
||||||
|
$param['order_id'] = getNewOrderId('rc');
|
||||||
|
$param['recharge_type'] = 'wechat';
|
||||||
|
return UserRecharge::create($param);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -47,4 +47,15 @@ class UserValidate extends BaseValidate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 充值
|
||||||
|
* @return UserValidate
|
||||||
|
* @author: codeliu
|
||||||
|
* @Time: 2024/6/4 22:50
|
||||||
|
*/
|
||||||
|
public function sceneRechargeMoney()
|
||||||
|
{
|
||||||
|
return $this->only(['price']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -47,6 +47,12 @@ class OrderEnum
|
|||||||
const RECEIVED_GOODS = 2;
|
const RECEIVED_GOODS = 2;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核销
|
||||||
|
* @IS_OK 已核销
|
||||||
|
*/
|
||||||
|
const IS_OK = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户类型
|
* 账户类型
|
||||||
* @USER 用户
|
* @USER 用户
|
||||||
|
21
app/common/model/user/UserRecharge.php
Normal file
21
app/common/model/user/UserRecharge.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\user;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户充值表
|
||||||
|
* Class UserAddress
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class UserRecharge extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $pk = 'id';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user