711 行
27 KiB
PHP
可执行文件
711 行
27 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace CashierApi\Business;
|
||
|
||
use Addons\Api\Crypto;
|
||
use Common\Business\Manager;
|
||
use Common\Business\Merchant;
|
||
use Common\Business\PayOrder;
|
||
use Common\Business\VipInfo;
|
||
use Common\Business\VipRechargeActivity;
|
||
use Common\Business\VipRechargeRecord;
|
||
use Common\Model\InstallAccountModel;
|
||
use Common\Model\RetailPayOrderModel;
|
||
use Common\Model\RetailPaySetModel;
|
||
use Common\Model\RetailRechargeOrderModel;
|
||
|
||
//[1.7.66]
|
||
|
||
/**
|
||
* 会员充值类
|
||
* Class VipRecharge
|
||
* [
|
||
* 会员充值提交支付 placeRechargeOrder
|
||
* 发起支付 payment
|
||
* 分期到账 stagesPayment
|
||
* 创建充值订单 createRechargerOrder
|
||
* 创建流水数据 createPayOrder
|
||
* 获取自定义充值的赠送金额 customGiveMoney
|
||
* 充值活动验证 ActivityVerify
|
||
* 微信支付宝验证 payVerify
|
||
* 现金对操作员进行验证 operatorVerify
|
||
* 会员充值提交支付的参数验证 placeRechargeOrderVerify
|
||
* ]
|
||
* @package CashierApi\VipRecharge
|
||
*/
|
||
class VipRecharge
|
||
{
|
||
|
||
/**
|
||
* 会员充值提交支付
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* cashier_id
|
||
* merchantInfo
|
||
* storeInfo
|
||
* cashierInfo
|
||
* face_token 支付宝刷脸码
|
||
* give_money 自定义赠送金额
|
||
* manager_number 店长登录账号
|
||
* manager_pass 店长登陆密码
|
||
* pay_code 用户付款码
|
||
* pay_type 类型 1.现金 2.在线 3.刷脸
|
||
* recharge_code 收银员充值码
|
||
* recharge_id 充值活动id
|
||
* recharge_money 自定义充值金额
|
||
* user_type 充值人员类型 1.收银员 2.店长
|
||
* vip_id 会员id
|
||
* vip_type 会员类型 1.普通会员 2.过期plus会员 3.正常plus会员(判断优惠券发放)
|
||
* scene_type 变动场景 1收银机 2商户后台 3门店后台 4小程序 5公众号 6小助手
|
||
* ]
|
||
* [
|
||
* 验证通过后
|
||
* activity 活动信息
|
||
* recharge_money 充值金额
|
||
* give_money赠送金额
|
||
* recharge_id 活动id
|
||
* pay_order_arr 流水信息
|
||
* recharge_order_arr 充值订单信息
|
||
* ]
|
||
* [
|
||
* 流水信息添加成功后
|
||
* setting 分期设置
|
||
* pay_order 流水信息
|
||
* ]
|
||
* [
|
||
* 充值订单添加成功后
|
||
* recharge_order_id 充值订单id
|
||
* ]
|
||
* [
|
||
* config 支付设置
|
||
* ]
|
||
* @return array|mixed
|
||
* [
|
||
* status
|
||
* message
|
||
* data=>[
|
||
* //微信支付宝返回
|
||
* pay_order_id 流水id
|
||
* recharge_id 充值活动id
|
||
* //现金返回
|
||
* order_id 返回订单号(打印小票)
|
||
* install_data 分期到账的信息是各数组
|
||
* ]
|
||
* ]
|
||
* @throws \think\Exception
|
||
*/
|
||
public function placeRechargeOrder($param)
|
||
{
|
||
$verifyResult = $this->placeRechargeOrderVerify($param); //支付前验证
|
||
if ($verifyResult['status'] != 1) {
|
||
return $verifyResult;
|
||
}
|
||
$param['activity'] = $verifyResult['data']['activity']; //活动信息
|
||
$param['recharge_money'] = $verifyResult['data']['recharge_money']; //充值金额
|
||
$param['give_money'] = $verifyResult['data']['give_money']; //增加金额
|
||
$param['recharge_id'] = $verifyResult['data']['recharge_id']; //活动id
|
||
$param['pay_order_arr'] = $verifyResult['data']['pay_order_arr']; //流水信息
|
||
$param['recharge_order_arr'] = $verifyResult['data']['recharge_order_arr']; //充值订单信息
|
||
$config = $verifyResult['data']['config']; //支付设置
|
||
$payOrderResult = $this->createPayOrder($param); //创建流水订单
|
||
if ($payOrderResult['status'] != 1) {
|
||
return $payOrderResult;
|
||
}
|
||
$param['pay_order'] = $payOrderResult['data']; //流水信息
|
||
$MerchantClass = new Merchant();
|
||
$merchantResult = $MerchantClass->getSetting([
|
||
'merchant_id' => $param['merchant_id']
|
||
]);
|
||
if ($merchantResult['status'] != 1) {
|
||
return $merchantResult;
|
||
}
|
||
$param['setting'] = $merchantResult['data']; //商户设置
|
||
$rechargeOrderResult = $this->createRechargerOrder($param);
|
||
if ($rechargeOrderResult['status'] != 1) {
|
||
return $rechargeOrderResult;
|
||
}
|
||
$param['recharge_order_id'] = $rechargeOrderResult['data']; //充值订单id
|
||
if ($param['setting']['aging_repay'] == 1 && $param['activity']['aging_repay'] == 1) {
|
||
//分期到账
|
||
$this->stagesPayment($param);
|
||
}
|
||
$param['config'] = $config;
|
||
$result = $this->payment($param); //发起支付
|
||
return $result;
|
||
}
|
||
|
||
|
||
/**
|
||
*发起支付
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* pay_order 流水信息
|
||
* recharge_id 活动id
|
||
* config 支付设置
|
||
* ]
|
||
* @return array|mixed
|
||
* @throws \think\Exception
|
||
*/
|
||
public function payment($param)
|
||
{
|
||
if ($param['pay_type'] == 1) {
|
||
// 现金
|
||
$Payment = new PaymentCallBack();
|
||
$result = $Payment->rechargeCallBackHandle([
|
||
'merchant_id' => $param['merchant_id'],
|
||
'store_id' => $param['store_id'],
|
||
'pay_order' => $param['pay_order'],
|
||
'recharge_id' => $param['recharge_id'],
|
||
'upData' => [
|
||
'order_state' => 'SUCCESS',
|
||
'trade_date' => time()
|
||
]
|
||
]);
|
||
} else {
|
||
// 在线支付
|
||
$ThirdPayClass = new ThirdPay();
|
||
$result = $ThirdPayClass->launchPay([
|
||
'm_pay_type' => $param['pay_order']['m_pay_type'],
|
||
'pay_type' => $param['pay_order']['pay_type'],
|
||
'pay_order_info' => $param['pay_order'],
|
||
'config' => $param['config']
|
||
]); //发起支付
|
||
if ($result['status'] == 1) {
|
||
//发送支付请求成功
|
||
$result['data'] = [
|
||
'pay_order_id' => $param['pay_order']['id'],
|
||
'recharge_id' => $param['recharge_id'] ? $param['recharge_id'] : 0
|
||
];
|
||
}
|
||
}
|
||
|
||
return $result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 分期到账
|
||
* @param $param
|
||
* merchant_id
|
||
* store_id
|
||
* vip_id 会员id
|
||
* give_money 赠送的金额
|
||
* recharge_order_id 充值订单id
|
||
* setting 分期设置
|
||
* activity 活动信息
|
||
* @return mixed
|
||
*/
|
||
public function stagesPayment($param)
|
||
{
|
||
$accountData = array(
|
||
'vip_id' => $param['vip_id'],
|
||
'merchant_id' => $param['merchant_id'],
|
||
'store_id' => $param['store_id'],
|
||
'aging_money' => $param['give_money'],
|
||
'order_id' => $param['recharge_order_id'],
|
||
'aging_date' => date("Y-m-d", intval(time())),
|
||
'aging_cycle' => $param['setting']['aging_cycle'], //设置->分期到账间隔时间
|
||
'aging_repay' => $param['setting']['aging_repay'], //设置->分期到账是否开启
|
||
'aging_time' => $param['setting']['aging_time'], //设置->分期到账间隔
|
||
'active_aging_repay' => $param['activity']['aging_repay'], //活动->分期到账是否开启
|
||
'active_aging_time' => $param['activity']['aging_time'], //活动->分几期到账
|
||
);
|
||
$InstallAccountModel = new InstallAccountModel();
|
||
$InstallAccountModel->waitUpgradeAccount($accountData);
|
||
return callBack(statusCode()['success'], "分期成功");
|
||
}
|
||
|
||
|
||
/**
|
||
* 创建充值订单
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* setting 商户设置
|
||
* activity 活动信息
|
||
* recharge_order_arr 订单信息
|
||
* vip_id 会员id
|
||
* pay_order 流水信息
|
||
* recharge_id 活动id
|
||
* recharge_money 充值金额
|
||
* give_money 赠送金额
|
||
* user_type 充值人员类型 1.收银员 2.店长
|
||
* scene_type 1收银机 2商户后台 3门店后台 4小程序 5公众号 6小助手
|
||
* ]
|
||
* @return mixed
|
||
*/
|
||
public function createRechargerOrder($param)
|
||
{
|
||
$setting = $param['setting'];
|
||
$activity = $param['activity'];
|
||
$data = $param['recharge_order_arr'];
|
||
$data['merchant_id'] = $param['merchant_id'];
|
||
$data['store_id'] = $param['store_id'];
|
||
$data['vid'] = $param['vip_id'];
|
||
$data['status'] = 0;
|
||
$data['pay_order_id'] = $param['pay_order']['id'];
|
||
$data['money'] = $param['recharge_money'];
|
||
$data['give_money'] = $param['give_money'];
|
||
$data['user_type'] = $param['user_type'] == 1 ? 3 : 2;
|
||
$data['cashier_id'] = $param['user_type'] == 1 ? $param['cashier_id'] : $param['manager']['id'];
|
||
$data['vip_recharge_id'] = $param['recharge_id'] ? $param['recharge_id'] : 0;
|
||
$data['scene_type'] = $param['scene_type'];
|
||
$data['type'] = 1;
|
||
$data['add_time'] = time();
|
||
$data['state'] = 1;
|
||
if ($setting['aging_repay'] == 1 && $activity['aging_repay'] == 1) {
|
||
$data['all_money'] = $param['recharge_money'];
|
||
$data['balance'] = $param['recharge_money'];
|
||
$data['repay_name'] = 1;
|
||
$data['remark'] = '收银机充值' . $param['recharge_money'] . '元获得' . $param['recharge_money'] . '元,剩余' . $param['give_money'] . '分期到账';
|
||
} else {
|
||
$data['all_money'] = $param['recharge_money'] + $param['give_money'];
|
||
$data['balance'] = $param['recharge_money'] + $param['give_money'];
|
||
$data['remark'] = '收银机充值' . $param['recharge_money'] . '元获得' . $data['all_money'] . '元';
|
||
}
|
||
$RechargeOrderModel = new RetailRechargeOrderModel();
|
||
$result = $RechargeOrderModel->addOrder($data);
|
||
// 创建门店充值记录,用于门店消费区分
|
||
// $record = M('recharge_record')
|
||
// ->where(['vid' => $param['vip_id'], 'store_id' => $param['store_id']])
|
||
// ->find();
|
||
// if (!empty($record)) {
|
||
// M('recharge_record')->save([
|
||
// 'id' => $record['id'],
|
||
// 'money' => $param['recharge_money'] + $record['money'],
|
||
// 'balance' => $param['recharge_money'] + $record['balance']
|
||
// ]);
|
||
// } else {
|
||
// M('recharge_record')->add([
|
||
// 'vid' => $param['vip_id'],
|
||
// 'store_id' => $param['store_id'],
|
||
// 'money' => $param['recharge_money'],
|
||
// 'balance' => $param['recharge_money'],
|
||
// 'create_time' => time()
|
||
// ]);
|
||
// }
|
||
if (!empty($result)) {
|
||
return callBack(statusCode()['success'], "充值订单创建成功", $result);
|
||
} else {
|
||
return callBack(statusCode()['error'], "充值订单创建失败");
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 创建流水数据
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* cashier_id
|
||
* pay_order_arr 流水信息
|
||
* vip_id 会员id
|
||
* recharge_money 充值金额
|
||
* ]
|
||
* @return mixed
|
||
* [
|
||
* data 流水订单信息
|
||
* ]
|
||
*/
|
||
public function createPayOrder($param)
|
||
{
|
||
$data = $param['pay_order_arr'];
|
||
$data['order_type'] = 2;
|
||
$data['merchant_id'] = $param['merchant_id'];
|
||
$data['store_id'] = $param['store_id'];
|
||
$data['cashier_id'] = $param['cashier_id'];
|
||
$data['trade_amount'] = $param['recharge_money'];
|
||
$data['add_time'] = time();
|
||
$data['order_state'] = 'WAIT_BUYER_PAY';
|
||
$data['vid'] = $param['vip_id'];
|
||
$PayOrderModel = new RetailPayOrderModel();
|
||
$result = $PayOrderModel->addPayOrder($data);
|
||
if (!$result) {
|
||
return callBack(statusCode()['error'], "流水订单创建失败");
|
||
}
|
||
return callBack(statusCode()['success'], "流水订单创建成功", $result);
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取自定义充值的赠送金额
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* merchantInfo
|
||
* give_money 自定义赠送金额
|
||
* recharge_money 自定义充值金额
|
||
* vip_info_type 会员身份
|
||
* ]
|
||
* @return bool|int|mixed
|
||
* [
|
||
* data 活动信息
|
||
* ]
|
||
*/
|
||
public function customGiveMoney($param)
|
||
{
|
||
if ($param['merchantInfo']['auto_read_recharge_grade'] == 2) {
|
||
$activity = [];
|
||
} else {
|
||
//自动读取活动最大的赠送金额
|
||
$ActivityClass = new VipRechargeActivity();
|
||
$activityResult = $ActivityClass->getMaxGiveMoney([
|
||
'merchant_id' => $param['merchant_id'],
|
||
'store_id' => $param['store_id'],
|
||
'recharge_money' => $param['recharge_money'],
|
||
'user_type' => $param['vip_info_type'],
|
||
'activity_type' => 2
|
||
]);
|
||
if ($activityResult['status'] != 1) {
|
||
return $activityResult;
|
||
}
|
||
$activity = $activityResult['data']; //活动信息
|
||
}
|
||
return callBack(statusCode()['success'], "查询成功", $activity);
|
||
}
|
||
|
||
|
||
/**
|
||
* 自定义充值验证
|
||
* @param $param
|
||
* [
|
||
* cashierInfo
|
||
* merchantInfo
|
||
* give_money 自定义赠送金额
|
||
* recharge_money 自定义充值金额
|
||
* ]
|
||
* @return mixed
|
||
*/
|
||
public function customVerify($param)
|
||
{
|
||
if (!verifyPrice($param['recharge_money'])) {
|
||
return callBack(statusCode()['error'], "请输入正确的充值金额");
|
||
}
|
||
if ($param['merchantInfo']['inputrecharge'] == 2) {
|
||
return callBack(statusCode()['error'], "暂无自定义充值权限");
|
||
}
|
||
if (!empty($param['give_money'])) {
|
||
//赠送金额
|
||
if (empty($param['cashierInfo']['customviprecharge']) || $param['cashierInfo']['customviprecharge'] == 1) {
|
||
return callBack(statusCode()['error'], "暂无赠送权限");
|
||
}
|
||
if (!verifyNumber($param['give_money'], 2, 0.01, $param['recharge_money'])) {
|
||
return callBack(statusCode()['error'], "请输入正确的赠送金额");
|
||
}
|
||
}
|
||
return callBack(statusCode()['success'], "验证成功");
|
||
}
|
||
|
||
|
||
/**
|
||
* 充值活动验证
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* recharge_id 充值活动id
|
||
* vip_id 会员id
|
||
* ]
|
||
* @return mixed
|
||
* [
|
||
* data 活动信息
|
||
* ]
|
||
*/
|
||
public function ActivityVerify($param)
|
||
{
|
||
$ActivityClass = new VipRechargeActivity();
|
||
$activityResult = $ActivityClass->basisIdGetInfo([
|
||
'merchant_id' => $param['merchant_id'],
|
||
'store_id' => $param['store_id'],
|
||
'id' => $param['recharge_id'],
|
||
'activity_type' => 2
|
||
]); //依据活动id查询可使用的活动信息
|
||
if ($activityResult['status'] != 1) {
|
||
return $activityResult;
|
||
}
|
||
$activity = $activityResult['data']; //活动信息
|
||
if ($activity['surplus'] <= 0 && $activity['surplus'] != -1) {
|
||
return callBack(statusCode()['error'], "活动库存不足");
|
||
}
|
||
if (!empty($activity['limit_num']) && $activity['limit_num'] > 0) {
|
||
//充值次数限制
|
||
$rechargeRecord = new VipRechargeRecord();
|
||
$recordResult = $rechargeRecord->vipRechargeNum([
|
||
'merchant_id' => $param['merchant_id'],
|
||
'store_id' => $param['store_id'],
|
||
'vip_id' => $param['vip_id'],
|
||
'activity_id' => $activity['id']
|
||
]);
|
||
if ($recordResult['status'] != 1) {
|
||
return $recordResult;
|
||
}
|
||
$rechargeNum = $recordResult['data']; //充值次数
|
||
if (!empty($rechargeNum) && $rechargeNum >= $activity['limit_num']) {
|
||
return callBack(statusCode()['error'], "该会员已达到该充值活动的最大充值次数");
|
||
}
|
||
}
|
||
return callBack(statusCode()['success'], "验证成功", $activity);
|
||
}
|
||
|
||
|
||
/**
|
||
* 微信支付宝验证
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* merchantInfo
|
||
* storeInfo
|
||
* face_token 支付宝刷脸码
|
||
* pay_code 用户付款码
|
||
* pay_type 类型 1.现金 2.在线 3.刷脸
|
||
* ]
|
||
* @return mixed
|
||
* [
|
||
* pay_order_arr 流水信息
|
||
* recharge_order_arr 充值订单信息
|
||
* config 支付设置
|
||
* ]
|
||
*/
|
||
public function payVerify($param)
|
||
{
|
||
switch ($param['pay_type']) {
|
||
case 2:
|
||
//微信支付宝
|
||
if (empty($param['pay_code']) || strlen($param['pay_code']) != 18) {
|
||
return callBack(statusCode()['error'], "请扫描正确的付款码");
|
||
}
|
||
$num = substr($param['pay_code'], 0, 2); // 截取付款码前两位
|
||
if ($num >= 25 && $num <= 30) { //支付宝付款码支付
|
||
$pay_order_arr['pay_type'] = 2;
|
||
$recharge_order_arr['pay_type'] = 3;
|
||
} else if ($num >= 10 && $num <= 15) { //微信的付款码支付
|
||
$pay_order_arr['pay_type'] = 1;
|
||
$recharge_order_arr['pay_type'] = 2;
|
||
} else {
|
||
return callBack(statusCode()['error'], "请扫描正确的付款码");
|
||
}
|
||
$pay_order_arr['code'] = $param['pay_code'];
|
||
break;
|
||
case 3:
|
||
// 支付宝刷脸
|
||
if (empty($param['face_token'])) {
|
||
return callBack(statusCode()['error'], "刷脸支付失败");
|
||
}
|
||
$PayOrderClass = new PayOrder();
|
||
$payOrderResult = $PayOrderClass->basisFaceGetInfo([
|
||
'store_id' => $param['store_id'],
|
||
'face_token' => $param['face_token']
|
||
]);
|
||
if ($payOrderResult['status'] == 1) {
|
||
return callBack(statusCode()['error'], "请重新扫描");
|
||
}
|
||
$pay_order_arr['pay_type'] = 2;
|
||
$pay_order_arr['face_token'] = $param['face_token'];
|
||
$recharge_order_arr['pay_type'] = 3;
|
||
break;
|
||
default:
|
||
return callBack(statusCode()['error'], "未知的支付方式");
|
||
break;
|
||
}
|
||
$PaySetModel = new RetailPaySetModel();
|
||
$result = $PaySetModel->getFindMerchantConfig($param['merchant_id'], $pay_order_arr['pay_type']);
|
||
if ($result['status'] != 1) {
|
||
return callBack(statusCode()['error'], $result['msg'] ? $result['msg'] : '暂无可用的支付模式');
|
||
}
|
||
$config = $result['config'];
|
||
$config['body'] = $param['merchantInfo']['name'] . '-' . $param['storeInfo']['storetag'];
|
||
$pay_order_arr['m_pay_type'] = $result['m_pay_type'];
|
||
return callBack(statusCode()['success'], "验证成功", [
|
||
'pay_order_arr' => $pay_order_arr,
|
||
'recharge_order_arr' => $recharge_order_arr,
|
||
'config' => $config
|
||
]);
|
||
}
|
||
|
||
|
||
/**
|
||
* 现金对操作员进行验证
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* merchantInfo
|
||
* manager_number 店长登录账号
|
||
* manager_pass 店长登陆密码
|
||
* recharge_code 收银员充值码
|
||
* user_type 充值人员类型 1.收银员 2.店长
|
||
* ]
|
||
* @return mixed
|
||
* [
|
||
* pay_order_arr 流水信息
|
||
* recharge_order_arr 订单信息
|
||
* ]
|
||
*/
|
||
public function operatorVerify($param)
|
||
{
|
||
switch ($param['user_type']) {
|
||
case 1:
|
||
//收银员
|
||
if ($param['cashierInfo']['canrecharge'] != 2) {
|
||
return callBack(statusCode()['error'], "您无充值权限");
|
||
}
|
||
if (empty($param['recharge_code']) || $param['recharge_code'] != $param['cashierInfo']['rechargecode']) {
|
||
return callBack(statusCode()['error'], "请输入正确的权限码");
|
||
}
|
||
break;
|
||
case 2:
|
||
//店长
|
||
if (empty($param['manager_number']) || empty($param['manager_pass'])) {
|
||
return callBack(statusCode()['error'], "请填写店长账号或密码后在提交");
|
||
}
|
||
$ManagerClass = new Manager();
|
||
$managerResult = $ManagerClass->basisPhoneGetInfo([
|
||
'merchant_id' => $param['merchant_id'],
|
||
'store_id' => $param['store_id'],
|
||
'phone' => $param['manager_number']
|
||
]); //查询店长
|
||
if ($managerResult['status'] != 1) {
|
||
return $managerResult;
|
||
}
|
||
$manager = $managerResult['data']; //店长信息
|
||
$cryptClass = new Crypto();
|
||
$encryption_pass = $cryptClass->encrypt($param['manager_pass'], date('YmdHis', $manager['addtime']));
|
||
if ($encryption_pass != $manager['password']) {
|
||
return callBack(statusCode()['error'], "店长密码错误");
|
||
}
|
||
break;
|
||
default:
|
||
return callBack(statusCode()['error'], "未知的操作员");
|
||
break;
|
||
}
|
||
$pay_order_arr['pay_type'] = 3;
|
||
$recharge_order_arr['pay_type'] = 1;
|
||
return callBack(statusCode()['success'], "验证成功", [
|
||
'pay_order_arr' => $pay_order_arr,
|
||
'recharge_order_arr' => $recharge_order_arr
|
||
]);
|
||
}
|
||
|
||
|
||
/**
|
||
* 会员充值提交支付的参数验证
|
||
* @param $param
|
||
* [
|
||
* merchant_id
|
||
* store_id
|
||
* cashier_id
|
||
* merchantInfo
|
||
* storeInfo
|
||
* cashierInfo
|
||
* face_token 支付宝刷脸码
|
||
* give_money 自定义赠送金额
|
||
* manager_number 店长登录账号
|
||
* manager_pass 店长登陆密码
|
||
* pay_code 用户付款码
|
||
* pay_type 类型 1.现金 2.在线 3.刷脸
|
||
* recharge_code 收银员充值码
|
||
* recharge_id 充值活动id
|
||
* recharge_money 自定义充值金额
|
||
* user_type 充值人员类型 1.收银员 2.店长
|
||
* vip_id 会员id
|
||
* vip_type 会员类型 1.普通会员 2.过期plus会员 3.正常plus会员(判断优惠券发放)
|
||
* ]
|
||
* @return mixed
|
||
* [
|
||
* recharge_money 充值金额
|
||
* give_money 赠送金额
|
||
* recharge_id 活动id
|
||
* pay_order_arr 流水信息
|
||
* recharge_order_arr 充值订单信息
|
||
* config 支付设置
|
||
* activity 活动信息
|
||
* ]
|
||
*/
|
||
public function placeRechargeOrderVerify($param)
|
||
{
|
||
if (empty($param['merchant_id']) || empty($param['store_id']) || empty($param['cashier_id'])) {
|
||
return callBack(statusCode()['error'], "缺少收银员的唯一标识");
|
||
}
|
||
if (empty($param['vip_id']) || empty($param['vip_type']) || empty($param['user_type']) || !in_array($param['user_type'], ['1', '2'])) {
|
||
return callBack(statusCode()['error'], "缺少用户身份的唯一标识");
|
||
}
|
||
if (empty($param['pay_type']) || !in_array($param['pay_type'], ['1', '2', '3'])) {
|
||
return callBack(statusCode()['error'], "请选择支付方式");
|
||
}
|
||
$VipInfoClass = new VipInfo();
|
||
$vipResult = $VipInfoClass->basisIdGetVipInfo([
|
||
'merchant_id' => $param['merchant_id'],
|
||
'vip_id' => $param['vip_id'],
|
||
'status' => 1
|
||
]); //查询会员
|
||
if ($vipResult['status'] != 1) {
|
||
return $vipResult;
|
||
}
|
||
$vip_info = $vipResult['data']; //会员信息
|
||
switch ($param['pay_type']) {
|
||
case 1:
|
||
//现金
|
||
$payResult = $this->operatorVerify($param); //操作员验证
|
||
break;
|
||
case 2:
|
||
case 3:
|
||
//微信支付宝
|
||
$payResult = $this->payVerify($param); //操作员与支付方式验证
|
||
break;
|
||
default:
|
||
return callBack(statusCode()['error'], "未知的支付方式");
|
||
break;
|
||
}
|
||
if ($payResult['status'] != 1) {
|
||
return $payResult;
|
||
}
|
||
$pay_order_arr = $payResult['data']['pay_order_arr']; //流水信息
|
||
$recharge_order_arr = $payResult['data']['recharge_order_arr']; //充值订单信息
|
||
$config = $payResult['data']['config'] ? $payResult['data']['config'] : []; //支付设置
|
||
if (!empty($param['recharge_id'])) {
|
||
$rechargeResult = $this->ActivityVerify($param); //充值活动验证
|
||
if ($rechargeResult['status'] != 1) {
|
||
return $rechargeResult;
|
||
}
|
||
$activity = $rechargeResult['data']; //活动信息
|
||
$recharge_money = $activity['recharge_money']; //充值金额
|
||
$give_money = $activity['give_money']; //赠送金额
|
||
$recharge_id = $activity['id']; //活动id
|
||
} else {
|
||
$customResult = $this->customVerify($param); //自定义充值验证
|
||
if ($customResult['status'] != 1) {
|
||
return $customResult;
|
||
}
|
||
$recharge_money = $param['recharge_money']; //充值金额
|
||
$give_money = $param['give_money']; //赠送金额
|
||
if (empty($param['give_money'])) {
|
||
//获取满足活动最大的赠送金额
|
||
$param['vip_info_type'] = $vip_info['plus_type'];
|
||
$activityResult = $this->customGiveMoney($param);
|
||
if ($activityResult['status'] != 1) {
|
||
return $activityResult;
|
||
}
|
||
$activity = $activityResult['data'];
|
||
$give_money = $activity['give_money']; //赠送金额
|
||
$recharge_id = $activity['id']; //赠送金额的活动id
|
||
}
|
||
}
|
||
return callBack(statusCode()['success'], "验证成功", [
|
||
'recharge_money' => $recharge_money,
|
||
'give_money' => $give_money ? $give_money : 0,
|
||
'recharge_id' => $recharge_id ? $recharge_id : 0,
|
||
'activity' => $activity ? $activity : [],
|
||
'pay_order_arr' => $pay_order_arr,
|
||
'recharge_order_arr' => $recharge_order_arr,
|
||
'config' => $config
|
||
]);
|
||
}
|
||
} |