feat: 添加门店会员充值功能
This commit is contained in:
parent
04776f7b80
commit
0286d428e6
@ -102,7 +102,6 @@ class UserLogic extends BaseLogic
|
|||||||
return $res;
|
return $res;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
d($e);
|
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
namespace app\api\controller\store;
|
namespace app\api\controller\store;
|
||||||
|
|
||||||
|
use app\admin\logic\user\UserLogic as UserUserLogic;
|
||||||
use app\api\lists\store\SystemStoreLists;
|
use app\api\lists\store\SystemStoreLists;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\api\logic\store\StoreLogic;
|
use app\api\logic\store\StoreLogic;
|
||||||
use app\common\service\pay\PayService;
|
use app\api\logic\user\UserLogic;
|
||||||
use Webman\Config;
|
use app\api\validate\UserValidate;
|
||||||
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\logic\PaymentLogic;
|
||||||
|
use app\common\logic\PayNotifyLogic;
|
||||||
|
use app\common\model\user\User;
|
||||||
|
use app\common\model\user_recharge\UserRecharge;
|
||||||
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
class StoreController extends BaseApiController
|
class StoreController extends BaseApiController
|
||||||
{
|
{
|
||||||
@ -32,5 +38,39 @@ class StoreController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店会员充值
|
||||||
|
*/
|
||||||
|
public function recharge()
|
||||||
|
{
|
||||||
|
$params = (new UserValidate())->post()->goCheck('rechargeStoreMoney');
|
||||||
|
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||||
|
$params['uid'] = $this->userId;
|
||||||
|
$params['channel_type'] = $this->userInfo['terminal'];
|
||||||
|
$find=User::where('mobile',$params['mobile'])->find();
|
||||||
|
if(!$find){
|
||||||
|
$find=UserUserLogic::StoreAdd($params);
|
||||||
|
}
|
||||||
|
$data=[
|
||||||
|
'store_id'=>$params['store_id'],
|
||||||
|
'uid'=>$find['uid'],
|
||||||
|
'staff_id'=>0,
|
||||||
|
'order_id'=>getNewOrderId('CZ'),
|
||||||
|
'price'=>$params['price'],
|
||||||
|
];
|
||||||
|
$order = UserRecharge::create($data);
|
||||||
|
|
||||||
|
$order['pay_price']=$order['price'];
|
||||||
|
$result = PaymentLogic::codepay($auth_code, $order);
|
||||||
|
if (PaymentLogic::hasError()) {
|
||||||
|
return $this->fail(PaymentLogic::getError(), $params);
|
||||||
|
}
|
||||||
|
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||||
|
PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result);
|
||||||
|
} else {
|
||||||
|
Redis::send('send-code-pay', ['order_id' => $order['order_id'],'pay_type'=>'recharge']);
|
||||||
|
return $this->success('用户支付中');
|
||||||
|
}
|
||||||
|
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,6 @@ class UserController extends BaseApiController
|
|||||||
return $this->fail(PaymentLogic::getError(), $params);
|
return $this->fail(PaymentLogic::getError(), $params);
|
||||||
}
|
}
|
||||||
return $this->success('', $result);
|
return $this->success('', $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[
|
// #[
|
||||||
|
@ -16,10 +16,14 @@ class UserValidate extends BaseValidate
|
|||||||
|
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'code' => 'require',
|
'code' => 'require',
|
||||||
|
'store_id' => 'require',
|
||||||
|
'mobile' => 'require',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $message = [
|
protected $message = [
|
||||||
'code.require' => '参数缺失',
|
'code.require' => '参数缺失',
|
||||||
|
'store_id.require' => '门店id',
|
||||||
|
'mobile.require' => '手机',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -57,5 +61,14 @@ class UserValidate extends BaseValidate
|
|||||||
{
|
{
|
||||||
return $this->only(['price']);
|
return $this->only(['price']);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @notes 充值
|
||||||
|
* @return UserValidate
|
||||||
|
* @Time: 2024/6/4 22:50
|
||||||
|
*/
|
||||||
|
public function sceneRechargeStoreMoney()
|
||||||
|
{
|
||||||
|
return $this->only(['price']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\store\controller\store_order;
|
namespace app\store\controller\store_order;
|
||||||
|
|
||||||
|
use app\admin\logic\user\UserLogic;
|
||||||
use app\api\logic\order\OrderLogic;
|
use app\api\logic\order\OrderLogic;
|
||||||
use app\api\validate\OrderValidate;
|
use app\api\validate\OrderValidate;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user