1110 行
49 KiB
PHP
可执行文件
1110 行
49 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace CashierApi\Business;
|
|
|
|
use Common\Business\CacheHandle;
|
|
use Common\Business\Plug;
|
|
use Common\Business\Sell;
|
|
use Common\Business\ShopCoupon;
|
|
use Common\Business\StoreAuthority;
|
|
use Common\Model\RetailBillOrderModel;
|
|
use Common\Model\RetailCashierModel;
|
|
use Common\Model\RetailMerchantConfigModel;
|
|
use Common\Model\RetailPayOrderModel;
|
|
use Common\Model\RetailPaySetModel;
|
|
use Common\Model\StoreConfigModel;
|
|
use Credit\Controller\CreditOrderController;
|
|
use PayApi\Controller\OrderController;
|
|
|
|
//[1.9.20]
|
|
|
|
/**
|
|
* 支付类
|
|
* Class PayOrder
|
|
* [
|
|
* 收款 placeOrder
|
|
* 提交支付 payOperation
|
|
* 插件处理 plugHandle
|
|
* 流水表操作 payOrderOperation
|
|
* 支付参数验证 placeOrderVerify
|
|
* 订单验证 orderVerify
|
|
* 各种支付方式参数验证 payTypeVerify
|
|
* 前台传的字段验证 fieldsVerify
|
|
* ]
|
|
* @package CashierApi\Business
|
|
*/
|
|
class PayOrder
|
|
{
|
|
/**
|
|
* 收款
|
|
* @param $param
|
|
* [
|
|
* merchantInfo 商户信息
|
|
* storeInfo 门店信息
|
|
* cashierInfo 收银员信息
|
|
* merchant_id
|
|
* store_id
|
|
* cashier_id
|
|
* all_money 前台计算的总金额
|
|
* amount_received 实收
|
|
* pay_money 支付金额
|
|
* business_remark 订单备注
|
|
* balance_pay 赊销订单是否先用余额支付 1 是 2 否(暂时不用)
|
|
* coupon_type 优惠券类型 2商户优惠券 3门店商家券
|
|
* coupon_id 优惠券id
|
|
* changes_money 抹零金额
|
|
* card_code 会员动态码
|
|
* code 支付宝、微信付款码
|
|
* combine_pay 是否组合支付 1是 0否
|
|
* discount 收银员手动打折折扣值
|
|
* face_token 刷脸支付面部信息
|
|
* guide_id 导购员id
|
|
* is_zero_storage 是否存零 1是 0否
|
|
* integral_cashing 是否使用积分抵扣 1是 0否
|
|
* integral_dis_num 扣除的总积分
|
|
* integral_dis_money 抵现积分的金额
|
|
* order_no 订单编号
|
|
* out_trade_no 微信刷脸支付订单内部流水号
|
|
* other_pay_id 其他支付id
|
|
* openid 微信刷脸支付用户openid
|
|
* pay_type 支付类型 1微信 2支付宝 3现金 5其他 6余额 7赊账
|
|
* password 会员支付密码
|
|
* editor_type 操作场景 1收银员 2后台
|
|
* vip_login_type 会员登录方式 1动态码 2手机号或实体卡号
|
|
* vid 会员id
|
|
* third_vip_code 德育币会员id
|
|
* third_vip_name 德育币会员名称
|
|
* ]
|
|
* @return mixed
|
|
* @throws \think\Exception
|
|
*/
|
|
public function placeOrder($param)
|
|
{
|
|
$verifyResult = $this->placeOrderVerify($param); //参数验证
|
|
if ($verifyResult['status'] != 1) {
|
|
return $verifyResult;
|
|
}
|
|
$data = $verifyResult['data']['param']; //前端传来的参数集合
|
|
$Order = $verifyResult['data']['Order'] ? $verifyResult['data']['Order'] : []; //流水存储数据
|
|
$billOrder = $verifyResult['data']['billOrder']; //订单信息
|
|
$config = $verifyResult['data']['config'] ? $verifyResult['data']['config'] : []; //微信支付宝配置
|
|
if ($data['pay_type'] == 1 || $data['pay_type'] == 2) {
|
|
$config['body'] = $data['merchantInfo']['name'] . '-' . $data['storeInfo']['storetag'];
|
|
}
|
|
|
|
//流水表操作
|
|
$payOrderResult = $this->payOrderOperation([
|
|
'Order' => $Order,
|
|
'merchant_id' => $data['merchant_id'],
|
|
'store_id' => $data['store_id'],
|
|
'cashier_id' => $data['cashier_id'],
|
|
'pay_money' => $data['pay_money'],
|
|
'pay_type' => $data['pay_type'],
|
|
'billOrder' => $billOrder,
|
|
'out_trade_no' => $data['out_trade_no'],
|
|
]);
|
|
|
|
if ($payOrderResult['status'] != 1) {
|
|
if (C('IS_SET_REDIS')) {
|
|
//清空订单号缓存
|
|
$order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
$CacheHandleClass = new CacheHandle();
|
|
$CacheHandleClass->eliminateCache($order_key);
|
|
}
|
|
return $payOrderResult;
|
|
}
|
|
|
|
$Order = $payOrderResult['data']; //新的流水存储数据
|
|
//插件处理
|
|
$param['bill_id'] = $billOrder['id'];
|
|
$plugResult = $this->plugHandle($param);
|
|
if ($plugResult['status'] != 1) {
|
|
if (C('IS_SET_REDIS')) {
|
|
//清空订单号缓存
|
|
$order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
$CacheHandleClass = new CacheHandle();
|
|
$CacheHandleClass->eliminateCache($order_key);
|
|
}
|
|
return $plugResult;
|
|
}
|
|
$Order['plug']['wxpaycoupon'] = $plugResult['data']['plug']['wxPayCouponState']; //代金券权限
|
|
$Order['shop_coupon']['goods_tag'] = $plugResult['data']['payCoupon']['goods_tag']; //代金券信息
|
|
$Order['shop_coupon']['goods_detail'] = $plugResult['data']['payCoupon']['goods_detail']; //代金券商品信息
|
|
//提交支付
|
|
$result = $this->payOperation([
|
|
'editor_type' => $param['editor_type'],
|
|
'pay_type' => $param['pay_type'],
|
|
'order' => $Order,
|
|
'config' => $config,
|
|
'pay_money' => $param['pay_money'],
|
|
'amount_received' => $param['amount_received'],
|
|
'billOrder' => $billOrder,
|
|
'is_zero_storage' => $param['is_zero_storage'],
|
|
'password' => $param['password'],
|
|
'vip_login_type' => $param['vip_login_type'],
|
|
'card_code' => $param['card_code'],
|
|
'storeInfo' => $param['storeInfo'],
|
|
'all_money' => $param['all_money'],
|
|
'balance_pay' => $param['balance_pay'] ? $param['balance_pay'] : 2,
|
|
]);
|
|
|
|
if (C('IS_SET_REDIS')) {
|
|
//清空订单号缓存
|
|
$order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
$CacheHandleClass = new CacheHandle();
|
|
$CacheHandleClass->eliminateCache($order_key);
|
|
if ($result['status'] != 1) {
|
|
//清空优惠券redis
|
|
$billOrder['uid'] = $billOrder['uid'] ? $billOrder['uid'] : 0;
|
|
$coupon_redis_key = 'retail_coupon_store_id_' . $billOrder['store_id'] . '_uid_' . $billOrder['uid'] . '_coupon_type_' . $data['coupon_type'] . '_coupon_id_' . $data['coupon_id'];
|
|
$CacheHandleClass->eliminateCache($coupon_redis_key);
|
|
}
|
|
}
|
|
$result['data']['all_money'] = $billOrder['all_money'];
|
|
$result['data']['bill_id'] = $billOrder['id'];
|
|
|
|
// 记录会员消费结余
|
|
if ($result['status'] == 1 && $param['pay_type'] == 6) {
|
|
$vip = M('retail_vip')->where(['id' => $param['vid']])->find();
|
|
if ($vip['storeid'] != $param['store_id']) {
|
|
// 记录
|
|
$record = [
|
|
'order_num' => $param['order_no'],
|
|
'rid' => 0,
|
|
'use_store_id' => $param['store_id'],
|
|
'vid' => 0,
|
|
'recharge_store_id' => $vip['storeid'],
|
|
'create_time' => time()
|
|
];
|
|
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
// public function placeOrder($param)
|
|
// {
|
|
// $verifyResult = $this->placeOrderVerify($param); //参数验证
|
|
// if ($verifyResult['status'] != 1) {
|
|
// return $verifyResult;
|
|
// }
|
|
// $data = $verifyResult['data']['param']; //前端传来的参数集合
|
|
// $Order = $verifyResult['data']['Order'] ? $verifyResult['data']['Order'] : []; //流水存储数据
|
|
// $billOrder = $verifyResult['data']['billOrder']; //订单信息
|
|
// $config = $verifyResult['data']['config'] ? $verifyResult['data']['config'] : []; //微信支付宝配置
|
|
// if ($data['pay_type'] == 1 || $data['pay_type'] == 2) {
|
|
// $config['body'] = $data['merchantInfo']['name'] . '-' . $data['storeInfo']['storetag'];
|
|
// }
|
|
//
|
|
// //流水表操作
|
|
// $payOrderResult = $this->payOrderOperation([
|
|
// 'Order' => $Order,
|
|
// 'merchant_id' => $data['merchant_id'],
|
|
// 'store_id' => $data['store_id'],
|
|
// 'cashier_id' => $data['cashier_id'],
|
|
// 'pay_money' => $data['pay_money'],
|
|
// 'pay_type' => $data['pay_type'],
|
|
// 'billOrder' => $billOrder,
|
|
// 'out_trade_no' => $data['out_trade_no'],
|
|
// ]);
|
|
// if ($payOrderResult['status'] != 1) {
|
|
// if (C('IS_SET_REDIS')) {
|
|
// //清空订单号缓存
|
|
// $order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
// $CacheHandleClass = new CacheHandle();
|
|
// $CacheHandleClass->eliminateCache($order_key);
|
|
// }
|
|
// return $payOrderResult;
|
|
// }
|
|
// $Order = $payOrderResult['data']; //新的流水存储数据
|
|
// //插件处理
|
|
// $param['bill_id'] = $billOrder['id'];
|
|
// $plugResult = $this->plugHandle($param);
|
|
// if ($plugResult['status'] != 1) {
|
|
// if (C('IS_SET_REDIS')) {
|
|
// //清空订单号缓存
|
|
// $order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
// $CacheHandleClass = new CacheHandle();placeOrder
|
|
// $CacheHandleClass->eliminateCache($order_key);
|
|
// }
|
|
// return $plugResult;
|
|
// }
|
|
// $Order['plug']['wxpaycoupon'] = $plugResult['data']['plug']['wxPayCouponState']; //代金券权限
|
|
// $Order['shop_coupon']['goods_tag'] = $plugResult['data']['payCoupon']['goods_tag']; //代金券信息
|
|
// $Order['shop_coupon']['goods_detail'] = $plugResult['data']['payCoupon']['goods_detail']; //代金券商品信息
|
|
// //提交支付
|
|
// $result = $this->payOperation([
|
|
// 'editor_type' => $param['editor_type'],
|
|
// 'pay_type' => $param['pay_type'],
|
|
// 'order' => $Order,
|
|
// 'config' => $config,
|
|
// 'pay_money' => $param['pay_money'],
|
|
// 'amount_received' => $param['amount_received'],
|
|
// 'billOrder' => $billOrder,
|
|
// 'is_zero_storage' => $param['is_zero_storage'],
|
|
// 'password' => $param['password'],
|
|
// 'vip_login_type' => $param['vip_login_type'],
|
|
// 'card_code' => $param['card_code'],
|
|
// 'storeInfo' => $param['storeInfo'],
|
|
// 'all_money' => $param['all_money'],
|
|
// 'balance_pay' => $param['balance_pay'] ? $param['balance_pay'] : 2,
|
|
// ]);
|
|
// if (C('IS_SET_REDIS')) {
|
|
// //清空订单号缓存
|
|
// $order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
// $CacheHandleClass = new CacheHandle();
|
|
// $CacheHandleClass->eliminateCache($order_key);
|
|
// if ($result['status'] != 1) {
|
|
// //清空优惠券redis
|
|
// $billOrder['uid'] = $billOrder['uid'] ? $billOrder['uid'] : 0;
|
|
// $coupon_redis_key = 'retail_coupon_store_id_' . $billOrder['store_id'] . '_uid_' . $billOrder['uid'] . '_coupon_type_' . $data['coupon_type'] . '_coupon_id_' . $data['coupon_id'];
|
|
// $CacheHandleClass->eliminateCache($coupon_redis_key);
|
|
// }
|
|
// }
|
|
// $result['data']['all_money'] = $billOrder['all_money'];
|
|
// $result['data']['bill_id'] = $billOrder['id'];
|
|
//
|
|
// if ($result['status'] == 1 && $param['pay_type'] == 6) {
|
|
// // 代扣操作
|
|
// $rechargeList = M('recharge_order')
|
|
// ->where("vid = {$param['vid']} AND type = 1 AND balance > 0")
|
|
// ->order('id ASC')
|
|
// ->select();
|
|
// if (!empty($rechargeList)) {
|
|
// $odd = $param['amount_received'];
|
|
// foreach ($rechargeList as $item) {
|
|
// // 记录
|
|
// $record = [
|
|
// 'order_num' => $param['order_no'],
|
|
// 'rid' => $item['id'],
|
|
// 'use_store_id' => $param['store_id'],
|
|
// 'vid' => $param['vid'],
|
|
// 'recharge_store_id' => $item['store_id'],
|
|
// 'create_time' => time()
|
|
// ];
|
|
// // 余额不足继续减少下一条充值记录
|
|
// if ($odd > $item['balance']) {
|
|
// $record['money'] = $item['balance'];
|
|
// $odd -= $item['balance'];
|
|
// // 清零
|
|
// M('recharge_order')->save([
|
|
// 'id' => $item['id'],
|
|
// 'balance' => 0
|
|
// ]);
|
|
// M('retail_store_settlement')->add($record);
|
|
// } else {
|
|
// // 记录两条
|
|
// if ($param['store_id'] != $item['store_id']) {
|
|
// $record['money'] = $odd;
|
|
// $record['store_id'] = $param['store_id'];
|
|
// M('retail_store_settlement')->add($record);
|
|
// $record['store_id'] = $item['store_id'];
|
|
// M('retail_store_settlement')->add($record);
|
|
// }
|
|
// // 扣除余额
|
|
// M('recharge_order')->save([
|
|
// 'id' => $item['id'],
|
|
// 'balance' => $item['balance'] - $odd
|
|
// ]);
|
|
// break;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// return $result;
|
|
// }
|
|
|
|
|
|
/**
|
|
* 提交支付
|
|
* @param $param
|
|
* [
|
|
* storeInfo 门店信息
|
|
* all_money 前台计算的价格
|
|
* amount_received 实收金额
|
|
* balance_pay 赊销订单是否先用余额支付 1 是 2 否
|
|
* billOrder 订单信息
|
|
* config 支付配置信息
|
|
* card_code 会员动态码
|
|
* is_zero_storage 是否零存 1是 0否
|
|
* editor_type 操作场景 1收银员 2后台
|
|
* order 支付流水信息
|
|
* pay_type 支付类型 1微信 2支付宝 3现金 5其他 6余额 7赊账
|
|
* pay_money 支付金额
|
|
* password 会员支付密码
|
|
* vip_login_type 会员登录方式 1动态码 2手机号或实体卡号
|
|
* ]
|
|
* @return mixed
|
|
* [
|
|
* pay_type 支付方式
|
|
* ]
|
|
* @throws \think\Exception
|
|
*/
|
|
public function payOperation($param)
|
|
{
|
|
$pay_type = $param['pay_type'];
|
|
$Order = $param['order'];
|
|
$config = $param['config'];
|
|
$pay_money = $param['pay_money'];
|
|
$amount_received = $param['amount_received'];
|
|
$billOrder = $param['billOrder'];
|
|
$PaymentCallBackClass = new PaymentCallBack();
|
|
switch ($pay_type) {
|
|
case 1:
|
|
case 2:
|
|
$ThirdPayClass = new ThirdPay();
|
|
$result = $ThirdPayClass->launchPay([
|
|
'm_pay_type' => $Order['m_pay_type'],
|
|
'pay_type' => $pay_type,
|
|
'pay_order_info' => $Order,
|
|
'config' => $config
|
|
]);//发起支付
|
|
if ($result['status'] == 1) {
|
|
//发送支付请求成功
|
|
$result['data'] = [
|
|
'bill_id' => $billOrder['id'],
|
|
'pay_order_id' => $Order['id'],
|
|
'pay_money' => $pay_money,
|
|
'amount_received' => $amount_received,
|
|
'pay_channel' => $result['pay_channel']
|
|
];
|
|
}
|
|
break;
|
|
case 3:
|
|
case 5:
|
|
//现金 其他支付
|
|
$result = $PaymentCallBackClass->callBackHandle([
|
|
'pay_type' => $pay_type,
|
|
'pay_order' => $Order,
|
|
'pay_money' => $pay_money,
|
|
'amount_received' => $amount_received,
|
|
'billOrder' => $billOrder,
|
|
'is_zero_storage' => $param['is_zero_storage'],
|
|
'upData' => [
|
|
'order_state' => 'SUCCESS',
|
|
'trade_date' => time(),
|
|
]
|
|
]);
|
|
break;
|
|
case 6:
|
|
//会员余额
|
|
$VipPayClass = new VipPay();
|
|
$vipPayResult = $VipPayClass->VipPay([
|
|
'Order' => $Order,
|
|
'password' => $param['password'],
|
|
'vip_login_type' => $param['vip_login_type'],
|
|
'card_code' => $param['card_code'],
|
|
'storeInfo' => $param['storeInfo']
|
|
]);
|
|
|
|
// var_dump($vipPayResult);
|
|
|
|
if ($vipPayResult['status'] != 1) {
|
|
return $vipPayResult;
|
|
}
|
|
$result = $PaymentCallBackClass->callBackHandle([
|
|
'pay_money' => $pay_money,
|
|
'amount_received' => $amount_received,
|
|
'billOrder' => $billOrder,
|
|
'pay_type' => $pay_type,
|
|
]);
|
|
break;
|
|
case 7:
|
|
//赊账
|
|
$StoreConfigModel = new StoreConfigModel();
|
|
if (in_array('Credit', C('MODULE_ALLOW_LIST'))) {
|
|
$RetailCashierModel = new RetailCashierModel();
|
|
if ($param['editor_type'] == 1) {
|
|
$setAuth = $RetailCashierModel->getFindField(['id' => $Order['cashier_id']], 'credit_money_manage'); //收银员是否有还款赊账权限 1否 2是
|
|
if ($setAuth != 2) {
|
|
return callBack(statusCode()['error'], "该收银员没有进行赊账的权限!");
|
|
}
|
|
}
|
|
$is_open = $StoreConfigModel->getFindField(['store_id' => $Order['store_id']], 'is_credit');
|
|
}
|
|
if ($is_open != 1) {
|
|
return callBack(statusCode()['error'], "门店尚未开启赊账功能");
|
|
}
|
|
//赊销下单
|
|
$orderParam = [
|
|
'merchant_id' => $Order['merchant_id'],
|
|
'vid' => $Order['vid'],
|
|
'store_id' => $Order['store_id'],
|
|
'all_money' => $param['all_money'],
|
|
'cashier_id' => $Order['cashier_id'],
|
|
];
|
|
$CreditOrder = new CreditOrderController();
|
|
$result = $CreditOrder->creditOrderAdd($billOrder, $orderParam, 2);
|
|
$result['message'] = $result['msg'];
|
|
break;
|
|
case 8:
|
|
//德育币支付
|
|
$MoralEducationCoinPay = new \MoralEducationCoin\Business\Pay();
|
|
$result = $MoralEducationCoinPay->pay([
|
|
'store_third_code' => $param['storeInfo']['third_code'],
|
|
'amount' => $Order['trade_amount'],
|
|
'third_vip_code' => $param['billOrder']['third_vip_code'],
|
|
]);
|
|
if ($result['status'] == 1) {
|
|
$result = $PaymentCallBackClass->callBackHandle([
|
|
'pay_money' => $pay_money,
|
|
'amount_received' => $amount_received,
|
|
'billOrder' => $billOrder,
|
|
'pay_type' => $pay_type,
|
|
'pay_order' => $Order,
|
|
'upData' => [
|
|
'order_state' => 'SUCCESS',
|
|
'trade_date' => time(),
|
|
],
|
|
]);
|
|
}
|
|
break;
|
|
default:
|
|
$result['status'] = 0;
|
|
$result['message'] = '未知的支付类型';
|
|
break;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
/**
|
|
* 插件处理
|
|
* @param $param
|
|
* [
|
|
* merchant_id
|
|
* store_id
|
|
* bill_id 订单id
|
|
* coupon_id 券id
|
|
* coupon_type 券类型
|
|
* ]
|
|
* @return mixed
|
|
* [
|
|
* plug 插件权限
|
|
* payCoupon 代金券所需信息
|
|
* ]
|
|
*/
|
|
public function plugHandle($param)
|
|
{
|
|
$Plug = new Plug();
|
|
$plugResult = $Plug->PlugPermissions([
|
|
'merchant_id' => $param['merchant_id'],
|
|
'identification_arr' => [
|
|
'wxpaycoupon'
|
|
]
|
|
]); //查询是否有代金券插件
|
|
//代金券插件
|
|
if (!empty($plugResult['data']['plug']['wxpaycoupon'])) {
|
|
$wxPayCouponState = $plugResult['data']['plug']['wxpaycoupon'];
|
|
$ConfigModel = new RetailMerchantConfigModel();
|
|
$pay_coupon_goods_tag = $ConfigModel->getFindField(['merchant_id' => $param['merchant_id']], 'pay_coupon_goods_tag'); //代金券指定商品id或指定条码
|
|
$pay_coupon_goods_tag = $pay_coupon_goods_tag ? $pay_coupon_goods_tag : 1;
|
|
$SellClass = new Sell();
|
|
$goodsResult = $SellClass->getGoodsTag([
|
|
'bill_id' => $param['bill_id'],
|
|
'store_id' => $param['store_id'],
|
|
'pay_coupon_goods_tag' => $pay_coupon_goods_tag
|
|
]); //查询商品信息
|
|
if ($goodsResult['status'] == 1 && !empty($goodsResult['data']['goods_detail'])) {
|
|
$payCouponGoodsTag = strval($param['merchant_id']);
|
|
$payCouponGoodsDetail = $goodsResult['data']['goods_detail'];
|
|
}
|
|
}
|
|
if (C('IS_SET_REDIS') && !empty($param['coupon_id']) && !empty($param['coupon_type'])) {
|
|
$coupon_redis_key = 'retail_coupon_store_id_*_uid_*_coupon_type_' . $param['coupon_type'] . '_coupon_id_' . $param['coupon_id'];
|
|
$CacheHandleClass = new CacheHandle();
|
|
$user_shop_coupon = $CacheHandleClass->getManyCache($coupon_redis_key);
|
|
if (!empty($user_shop_coupon)) {
|
|
return callBack(statusCode()['error'], "该优惠券正在使用中,请勿重复使用");
|
|
}
|
|
if ($param['coupon_type'] == 3) {
|
|
$ShopCouponClass = new ShopCoupon();
|
|
$shopResult = $ShopCouponClass->getUserShopCouponState([
|
|
'coupon_id' => $param['coupon_id']
|
|
]);
|
|
if ($shopResult['status'] == 1 && $shopResult['data']['used_type'] == 2) {
|
|
return callBack(statusCode()['error'], "该优惠券已使用,请刷新重试");
|
|
}
|
|
}
|
|
//商家券插件
|
|
$coupon_time = 602;
|
|
$parameter = [
|
|
'coupon_id' => $param['coupon_id'],
|
|
'coupon_type' => $param['coupon_type'],
|
|
'uid' => 0,
|
|
'coupon_redis_key' => $coupon_redis_key,
|
|
'coupon_time' => $coupon_time
|
|
];
|
|
$coupon_redis_key = 'retail_coupon_store_id_' . $param['store_id'] . '_uid_' . 0 . '_coupon_type_' . $param['coupon_type'] . '_coupon_id_' . $param['coupon_id'];
|
|
$CacheHandleClass->addTimeCache($coupon_redis_key, $coupon_time, $parameter);
|
|
}
|
|
//插件权限
|
|
$plug = [
|
|
'wxPayCouponState' => $wxPayCouponState
|
|
];
|
|
//代金券指定商品信息
|
|
$payCoupon = [
|
|
'goods_tag' => $payCouponGoodsTag ? $payCouponGoodsTag : '',
|
|
'goods_detail' => $payCouponGoodsDetail ? $payCouponGoodsDetail : '',
|
|
];
|
|
return callBack(statusCode()['success'], "成功", [
|
|
'plug' => $plug,
|
|
'payCoupon' => $payCoupon
|
|
]);
|
|
}
|
|
|
|
|
|
/**
|
|
* 流水表操作
|
|
* @param $param
|
|
* [
|
|
* Order 流水存储的数据
|
|
* merchant_id
|
|
* store_id
|
|
* cashier_id
|
|
* pay_money 支付金额
|
|
* pay_type 支付类型 1微信 2支付宝 3现金 5其他 6余额 7赊账
|
|
* billOrder 订单信息
|
|
* out_trade_no 微信刷脸支付订单内部流水号
|
|
* ]
|
|
* @return mixed
|
|
* [
|
|
* Order 最新流水数据
|
|
* pay_order 流水id 订单号信息
|
|
* ]
|
|
*/
|
|
public function payOrderOperation($param)
|
|
{
|
|
$Order = $param['Order'];
|
|
$Order['trade_amount'] = $param['pay_money'];
|
|
$Order['order_type'] = 1;
|
|
$Order['pay_type'] = $param['pay_type'];
|
|
$Order['store_id'] = $param['store_id'];
|
|
$Order['merchant_id'] = $param['merchant_id'];
|
|
$Order['cashier_id'] = $param['cashier_id'];
|
|
$Order['vid'] = $param['billOrder']['vid'];
|
|
$Order['order_state'] = 'WAIT_BUYER_PAY';
|
|
$Order['add_time'] = time();
|
|
$Order['bill_id'] = $param['billOrder']['id'];
|
|
$PayOrderModel = new RetailPayOrderModel();
|
|
if (!empty($param['out_trade_no'])) {
|
|
$pay_order_id = $PayOrderModel->getFindField(['out_trade_no' => $param['out_trade_no']], "id");
|
|
if (empty($pay_order_id)) {
|
|
return callBack(statusCode()['error'], "未找到内部订单");
|
|
}
|
|
unset($Order['add_time']);
|
|
$pay_order_save = $PayOrderModel->updateOrder(['id' => $pay_order_id], $Order);
|
|
if (!$pay_order_save) {
|
|
return callBack(statusCode()['error'], "内部订单修改失败");
|
|
}
|
|
$pay_order['id'] = $pay_order_id;
|
|
$pay_order['out_trade_no'] = $param['out_trade_no'];
|
|
} else {
|
|
$pay_order = $PayOrderModel->addPayOrder($Order);
|
|
}
|
|
if (empty($pay_order)) {
|
|
return callBack(statusCode()['error'], "创建订单失败,请重试");
|
|
}
|
|
$Order['id'] = $pay_order['id'];
|
|
$Order['out_trade_no'] = $pay_order['out_trade_no'];
|
|
return callBack(statusCode()['success'], "操作成功", $Order);
|
|
}
|
|
|
|
|
|
/**
|
|
* 支付参数验证
|
|
* @param $param
|
|
* [
|
|
* merchantInfo 商户信息
|
|
* storeInfo 门店信息
|
|
* cashierInfo 收银员信息
|
|
* merchant_id
|
|
* store_id
|
|
* order_no 订单编号
|
|
* out_trade_no 微信刷脸支付订单内部流水号
|
|
* vid 会员id
|
|
* pay_type 支付类型 1微信 2支付宝 3现金 5其他 6余额 7赊账
|
|
* all_money 前台计算的总金额
|
|
* amount_received 实收
|
|
* coupon_id 优惠券id
|
|
* coupon_type 优惠券类型 2商户优惠券 3门店商家券
|
|
* discount 收银员手动打折折扣值
|
|
* changes_money 抹零金额
|
|
* guide_id 导购员id
|
|
* pay_money 支付金额
|
|
* vip_login_type 会员登录方式
|
|
* card_code 会员动态码
|
|
* code 支付宝、微信付款码
|
|
* face_token 刷脸支付面部信息
|
|
* password 会员支付密码
|
|
* is_zero_storage 是否存零 1是 0否
|
|
* other_pay_id 其他支付id
|
|
* combine_pay 是否组合支付 1是 0否
|
|
* integral_cashing 是否使用积分抵扣 1是 0否
|
|
* openid 微信刷脸支付用户openid
|
|
* integral_dis_num 扣除的总积分
|
|
* integral_dis_money 抵现积分的金额
|
|
* business_remark 订单备注
|
|
* balance_pay 赊销订单是否先用余额支付 1 是 2 否
|
|
* editor_type 操作场景 1收银员 2后台
|
|
* ]
|
|
* @return mixed
|
|
* [
|
|
* param 前端参数
|
|
* Order 流水表存储数据
|
|
* config 微信支付宝支付设置
|
|
* tempPayType 订单表支付方式
|
|
* billOrder 订单信息
|
|
* ]
|
|
*/
|
|
public function placeOrderVerify($param)
|
|
{
|
|
$param['integral_dis_num'] = $param['integral_dis_num'] ? $param['integral_dis_num'] : 0;
|
|
$param['integral_dis_money'] = $param['integral_dis_money'] ? $param['integral_dis_money'] : 0;
|
|
$param['business_remark'] = $param['business_remark'] ? $param['business_remark'] : '';
|
|
$param['balance_pay'] = $param['balance_pay'] ? $param['balance_pay'] : 2;
|
|
$param['editor_type'] = $param['editor_type'] ? $param['editor_type'] : 1;
|
|
//参数验证
|
|
$fieldsVerifyResult = $this->fieldsVerify($param);
|
|
if ($fieldsVerifyResult['status'] != 1) {
|
|
return $fieldsVerifyResult;
|
|
}
|
|
//其他支付$otherPay
|
|
if ($param['pay_type'] == 5) {
|
|
$OtherClass = new OtherPay();
|
|
$otherPayResult = $OtherClass->otherVerify([
|
|
'merchant_id' => $param['merchant_id'],
|
|
'id' => $param['other_pay_id']
|
|
]);
|
|
if ($otherPayResult['status'] != 1) {
|
|
return $otherPayResult;
|
|
}
|
|
}
|
|
//导购员$guide
|
|
if (!empty($guide_id)) {
|
|
$GuideClass = new Guide();
|
|
$guideResult = $GuideClass->basisIdGetInfo([
|
|
'store_id' => $param['store_id'],
|
|
'id' => $guide_id
|
|
]);
|
|
if ($guideResult['status'] != 1) {
|
|
return $guideResult;
|
|
}
|
|
}
|
|
//各支付方式的参数验证
|
|
|
|
$payTypeResult = $this->payTypeVerify($param);
|
|
|
|
if ($payTypeResult['status'] != 1) {
|
|
return $payTypeResult;
|
|
}
|
|
$payData = $payTypeResult['data'];
|
|
if (!empty($payData['pay_type'])) {
|
|
$param['pay_type'] = $payData['pay_type'];
|
|
}
|
|
$Order = $payData['Order']; //流水表存储数据
|
|
$config = $payData['config']; //微信支付宝支付设置
|
|
$tempPayType = $payData['tempPayType']; //订单表支付方式
|
|
//订单验证
|
|
$orderVerifyResult = $this->orderVerify([
|
|
'cashierInfo' => $param['cashierInfo'],
|
|
'storeInfo' => $param['storeInfo'],
|
|
'store_id' => $param['store_id'],
|
|
'order_no' => $param['order_no'],
|
|
'vid' => $param['vid'],
|
|
'coupon_id' => $param['coupon_id'],
|
|
'coupon_type' => $param['coupon_type'],
|
|
'discount' => $param['discount'],
|
|
'changes_money' => $param['changes_money'],
|
|
'all_money' => $param['all_money'],
|
|
'integral_cashing' => $param['integral_cashing'],
|
|
'integral_dis_money' => $param['integral_dis_money'],
|
|
'integral_dis_num' => $param['integral_dis_num'],
|
|
'guide_id' => $param['guide_id'],
|
|
'pay_money' => $param['pay_money'],
|
|
'business_remark' => $param['business_remark'],
|
|
'tempPayType' => $tempPayType,
|
|
'third_vip_code' => $param['third_vip_code'],
|
|
'third_vip_name' => $param['third_vip_name'],
|
|
]);
|
|
|
|
|
|
if ($orderVerifyResult['status'] != 1) {
|
|
if (C('IS_SET_REDIS')) {
|
|
//清空订单号缓存
|
|
$order_key = 'retail_cashier_bill_order_no_' . $orderVerifyResult['data']['order_no'];
|
|
$CacheHandleClass = new CacheHandle();
|
|
$CacheHandleClass->eliminateCache($order_key);
|
|
}
|
|
return $orderVerifyResult;
|
|
}
|
|
|
|
$billOrder = $orderVerifyResult['data']; //订单信息
|
|
return callBack(statusCode()['success'], "参数验证成功", [
|
|
'param' => $param,
|
|
'Order' => $Order,
|
|
'config' => $config,
|
|
'billOrder' => $billOrder,
|
|
]);
|
|
}
|
|
|
|
|
|
/**
|
|
* 订单验证
|
|
* @param $param
|
|
* [
|
|
* storeInfo 门店信息
|
|
* cashierInfo 收银员信息
|
|
* store_id
|
|
* order_no 订单号
|
|
* vid 会员id
|
|
* coupon_id 优惠券id
|
|
* coupon_type 优惠券类型
|
|
* discount 收银员手动打折折扣值
|
|
* changes_money 抹零金额
|
|
* all_money 前台计算的总金额
|
|
* integral_cashing 是否使用积分抵扣 1是 0否
|
|
* integral_dis_money 抵现积分的金额
|
|
* integral_dis_num 扣除的总积分
|
|
* guide_id 导购员id
|
|
* pay_money 支付金额
|
|
* business_remark 订单备注
|
|
* tempPayType 订单表的支付方式
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function orderVerify($param)
|
|
{
|
|
try {
|
|
$BillModel = new RetailBillOrderModel();
|
|
$where = [
|
|
'order_no' => strval($param['order_no']),
|
|
'store_id' => $param['store_id'],
|
|
'pay_state' => ['in', '0,2'], //未支付或待支付状态
|
|
'refund_money' => 0,
|
|
];
|
|
$billOrder = $BillModel->getFind($where);
|
|
|
|
if (empty($billOrder)) {
|
|
return callBack(statusCode()['error'], "订单不存在");
|
|
}
|
|
|
|
|
|
//判断是否已存入缓存
|
|
if (C('IS_SET_REDIS')) {
|
|
$order_key = 'retail_cashier_bill_order_no_' . $billOrder['order_no'];
|
|
$CacheHandleClass = new CacheHandle();
|
|
$cacheResult = $CacheHandleClass->getSingleCache($order_key);
|
|
if (!empty($cacheResult)) {
|
|
return callBack(statusCode()['error'], "请勿频繁操作!");
|
|
}
|
|
$CacheHandleClass->addCache($order_key, $billOrder['order_no']);
|
|
}
|
|
//条码秤打印的条码价权限
|
|
$StoreAuthClass = new StoreAuthority();
|
|
$configResult = $StoreAuthClass->getStoreConfig([
|
|
'store_id' => $param['store_id'],
|
|
'fields' => 'code_price_state'
|
|
]);
|
|
$code_price_state = $configResult['data']['code_price_state'] ? $configResult['data']['code_price_state'] : 0;
|
|
if ($billOrder['pay_state'] == 0) {
|
|
//未计算钱并且金额发生改变
|
|
$cashierInfo = $param['cashierInfo'];
|
|
$storeInfo = $param['storeInfo'];
|
|
$item = [
|
|
'bill_order' => $billOrder,
|
|
'code_price_state' => $code_price_state, //条码秤打印的条码价权限 0关闭 1开启
|
|
'vid' => $param['vid'], //会员id
|
|
'coupon_id' => $param['coupon_id'], //优惠券id
|
|
'coupon_type' => $param['coupon_type'], //优惠券类型
|
|
'discount' => $param['discount'], //收银员手动打折折扣值
|
|
'small_changes_money' => $param['changes_money'], //抹零金额
|
|
'allMoney' => $param['all_money'], //前台计算的总价
|
|
'integral_cashing' => $param['integral_cashing'], //积分抵现开启状态
|
|
'integral_dis_money' => $param['integral_dis_money'], //积分抵现开启抵现的金额
|
|
'integral_dis_num' => $param['integral_dis_num'], //积分抵现开启状态抵现的积分
|
|
'guide_id' => $param['guide_id'], //导购员id
|
|
'cashier_preferential_state' => $cashierInfo['preferential'], //收银员打折权限
|
|
'cashier_manual_discount_state' => $cashierInfo['manual_discount'], // 收银员-单品折扣权限
|
|
'manual_min_discount_state' => $cashierInfo['manual_min_discount'], // 收银员-手动折扣最低折扣
|
|
'manual_max_amount_state' => $cashierInfo['manual_max_amount'], // 收银员-手动折扣最多优惠金额
|
|
'store_preferential_state' => $storeInfo['preferential'], //门店打折权限
|
|
'store_manual_discount_state' => $storeInfo['manual_discount'], // 门店折上折--收银员
|
|
'guide_open_state' => $storeInfo['openstate'], //导购员分佣开启状态
|
|
];
|
|
$OrderApi = new OrderController();
|
|
$calculation = $OrderApi->calculationOrder_v2($item); //重新计算该付的金额
|
|
|
|
// var_dump($calculation);
|
|
if ($calculation['status'] == 1) {
|
|
$billOrder = $calculation['order'];
|
|
if (round($billOrder['all_money'] - $param['pay_money']) < 0) {
|
|
return callBack(statusCode()['error'], "支付金额超出订单总额1", ['all_money' => $billOrder['all_money']]);
|
|
}
|
|
$billOrder['guide_id'] = $param['guide_id'];
|
|
$billOrder['pay_state'] = 2;
|
|
$billOrder['business_remark'] = $param['business_remark'];
|
|
$billOrder['pay_type'] = $param['tempPayType']; //1现金 3微信支付 4支付宝支付 5会员卡余额支付 6小程序商城微信支付 7其他支付方式 8组合支付 9德育币
|
|
if ($param['tempPayType'] == 9) {
|
|
$billOrder['third_vip_code'] = $param['third_vip_code'];
|
|
$billOrder['third_vip_name'] = $param['third_vip_name'];
|
|
}
|
|
$update = $BillModel->updateOrder(['id' => $billOrder['id']], $billOrder);
|
|
|
|
if (!$update) {
|
|
return callBack(statusCode()['error'], "订单更新失败,请重试", $billOrder);
|
|
}
|
|
} else {
|
|
return callBack(statusCode()['error'], $calculation['msg'], $billOrder);
|
|
}
|
|
} else {
|
|
//组合
|
|
if (round($billOrder['all_money'] - $param['all_money'], 2) != 0) {
|
|
return callBack(statusCode()['error'], "bill2-前后台计算价格不一致,请检查" . $billOrder['all_money'] . ' ' . $param['all_money'], $billOrder);
|
|
}
|
|
$toUp = false;
|
|
if ($billOrder['pay_state'] == 0) {
|
|
$toUp = true;
|
|
$billOrder['pay_state'] = 2;
|
|
}
|
|
if (round($billOrder['all_money'] - $param['pay_money'], 2) > 0) {
|
|
$toUp = true;
|
|
$billOrder['pay_type'] = 8;
|
|
} else if (round($billOrder['all_money'] - $param['pay_money'] - $billOrder['pay_money'], 2) == 0) {
|
|
$toUp = true;
|
|
$billOrder['pay_type'] = $param['tempPayType']; //1现金 3微信支付 4支付宝支付 5会员卡余额支付 6小程序商城微信支付 7其他支付方式 8组合支付
|
|
} else {
|
|
return callBack(statusCode()['error'], "支付金额超出订单总额2", $billOrder);
|
|
}
|
|
if ($param['tempPayType'] == 9) {
|
|
$toUp = true;
|
|
$billOrder['third_vip_code'] = $param['third_vip_code'];
|
|
$billOrder['third_vip_name'] = $param['third_vip_name'];
|
|
}
|
|
if ($toUp) {
|
|
$BillModel->updateOrder(['id' => $billOrder['id']], $billOrder);
|
|
}
|
|
}
|
|
if (round($billOrder['all_money'] - $billOrder['pay_money'] - $param['pay_money'], 2) < 0) {
|
|
return callBack(statusCode()['error'], "支付金额超出订单总额3", $billOrder);
|
|
}
|
|
return callBack(statusCode()['success'], "验证成功", $billOrder);
|
|
} catch (\Exception $e) {
|
|
return callBack(statusCode()['success'], "订单验证失败", $billOrder);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 各种支付方式参数验证
|
|
* @param $param
|
|
* [
|
|
* merchant_id
|
|
* store_id
|
|
* pay_type 支付方式
|
|
* code 付款码
|
|
* face_token 刷脸支付面部信息
|
|
* openid 微信刷脸支付用户openid
|
|
* amount_received 实收金额
|
|
* is_zero_storage 是否存零 1是 0否
|
|
* vid 会员id
|
|
* other_pay_id 其他支付id
|
|
* vip_login_type 会员登录方式
|
|
* third_vip_code 德育币会员ID
|
|
* ]
|
|
* @return mixed
|
|
* [
|
|
* $pay_type 支付方式针对付款码
|
|
* $Order 流水表数据
|
|
* config 支付设置针对微信支付宝
|
|
* tempPayType 支付方式针对订单表
|
|
* ]
|
|
*/
|
|
public function payTypeVerify($param)
|
|
{
|
|
try {
|
|
$PayOrderModel = new RetailPayOrderModel(); //支付流水模型
|
|
$PaySetModel = new RetailPaySetModel(); //支付设置
|
|
$tempPayType = 0; //默认bill_order 0
|
|
$Plug = new Plug();
|
|
$plugData = $Plug->merPlugState([
|
|
'merchant_id' => $param['merchant_id'],
|
|
'identification_arr' => [
|
|
'wxpaycoupon'
|
|
]
|
|
]);
|
|
|
|
switch ($param['pay_type']) {
|
|
case '1':
|
|
case '2':
|
|
//微信 支付宝
|
|
if (!empty($param['code'])) {
|
|
//刷卡支付、付款码支付
|
|
$where = [
|
|
'store_id' => $param['store_id'],
|
|
'code' => $param['code']
|
|
];
|
|
$oldPayOrderId = $PayOrderModel->getFindField($where, "id");
|
|
if (!empty($oldPayOrderId)) {
|
|
return callBack(statusCode()['error'], "请用户刷新付款码");
|
|
}
|
|
$text = substr($param['code'], 0, 2);
|
|
if ($text >= 25 && $text <= 30) { //支付宝付款码支付
|
|
$pay_type = 2;
|
|
} else if ($text >= 10 && $text <= 15) { //微信的付款码支付
|
|
$pay_type = 1;
|
|
} else {
|
|
return callBack(statusCode()['error'], "请扫描正确的二维码");
|
|
}
|
|
$Order['code'] = $param['code'];
|
|
} else if (!empty($param['face_token'])) {
|
|
//微信刷脸支付
|
|
if ($param['pay_type'] == 1) {
|
|
if (empty($param['openid'])) {
|
|
return callBack(statusCode()['error'], "缺少用户openid");
|
|
}
|
|
$Order['openid'] = $param['openid'];
|
|
} else { //支付宝刷脸支付
|
|
|
|
}
|
|
$where = array(
|
|
'store_id' => $param['store_id'],
|
|
'face_token' => $param['face_token']
|
|
);
|
|
$oldPayOrderId = $PayOrderModel->getFindField($where, "id");
|
|
if (!empty($oldPayOrderId)) {
|
|
return callBack(statusCode()['error'], "请用户重新刷脸支付");
|
|
}
|
|
$Order['face_token'] = $param['face_token'];
|
|
} else {
|
|
return callBack(statusCode()['error'], "缺少支付参数code或face_token");
|
|
}
|
|
if ($param['pay_type'] == 1) {
|
|
$tempPayType = 3;
|
|
} else {
|
|
$tempPayType = 4;
|
|
}
|
|
$paySet = $PaySetModel->getFindMerchantConfig($param['merchant_id'], $param['pay_type']);
|
|
if ($paySet['status'] != 1) {
|
|
return callBack(statusCode()['error'], $paySet['msg']);
|
|
}
|
|
$config = $paySet['config'];
|
|
$Order['m_pay_type'] = $paySet['m_pay_type'];
|
|
break;
|
|
case '3':
|
|
//现金
|
|
$tempPayType = 1;
|
|
if ($param['is_zero_storage'] && ($param['is_zero_storage'] != 1 || !$param['vid'])) {
|
|
return callBack(statusCode()['error'], "零存参数有误");
|
|
}
|
|
break;
|
|
case '5':
|
|
//其他支付
|
|
$tempPayType = 7;
|
|
if (!empty($param['other_pay_id'])) {
|
|
$Order['other_pay_id'] = $param['other_pay_id'];
|
|
}
|
|
break;
|
|
case '6':
|
|
//会员卡余额
|
|
$tempPayType = 5;
|
|
if (empty($param['vid']) || empty($param['vip_login_type'])) {
|
|
return callBack(statusCode()['error'], "会员参数有误");
|
|
}
|
|
break;
|
|
case '7':
|
|
//赊账订单
|
|
if (empty($param['vid'])) {
|
|
return callBack(statusCode()['error'], "缺少会员参数!");
|
|
}
|
|
break;
|
|
case '8':
|
|
//德育币支付
|
|
$tempPayType = 9;
|
|
if ($plugData['moraleducationcoin']) {
|
|
return callBack(statusCode()['error'], "该商户未拥有德育币支付插件");
|
|
}
|
|
if (empty($param['third_vip_code'])) {
|
|
return callBack(statusCode()['error'], "请先登录德育币会员");
|
|
}
|
|
break;
|
|
}
|
|
return callBack(statusCode()['success'], "验证成功", [
|
|
'pay_type' => $pay_type ? $pay_type : '',
|
|
'Order' => $Order ? $Order : [],
|
|
'config' => $config ? $config : [],
|
|
'tempPayType' => $tempPayType,
|
|
]);
|
|
} catch (\Exception $e) {
|
|
return callBack(statusCode()['error'], "支付验证失败,请重试");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 前台传的字段验证
|
|
* @param $param
|
|
* [
|
|
* merchantInfo
|
|
* storeInfo
|
|
* merchant_id
|
|
* store_id
|
|
* cashier_id
|
|
* order_no 订单编号
|
|
* out_trade_no 微信刷脸支付订单内部流水号
|
|
* vid 会员id
|
|
* pay_type 支付类型 1微信 2支付宝 3现金 5其他 6余额 7赊账
|
|
* all_money 前台计算的总金额
|
|
* amount_received 实收
|
|
* coupon_id 优惠券id
|
|
* coupon_type 优惠券类型 2商户优惠券 3门店商家券
|
|
* discount 收银员手动打折折扣值
|
|
* changes_money 抹零金额
|
|
* guide_id 导购员id
|
|
* pay_money 支付金额
|
|
* vip_login_type 会员登录方式
|
|
* card_code 会员动态码
|
|
* code 支付宝、微信付款码
|
|
* face_token 刷脸支付面部信息
|
|
* password 会员支付密码
|
|
* is_zero_storage 是否存零 1是 0否
|
|
* other_pay_id 其他支付id
|
|
* combine_pay 是否组合支付 1是 0否
|
|
* integral_cashing 是否使用积分抵扣 1是 0否
|
|
* openid 微信刷脸支付用户openid
|
|
* integral_dis_num 扣除的总积分
|
|
* integral_dis_money 抵现积分的金额
|
|
* business_remark 订单备注
|
|
* balance_pay 赊销订单是否先用余额支付 1 是 2 否
|
|
* editor_type 操作场景 1收银员 2后台
|
|
* ]
|
|
* @return mixed
|
|
*/
|
|
public function fieldsVerify($param)
|
|
{
|
|
if (empty($param['merchant_id']) || empty($param['store_id']) || empty($param['cashier_id'])) {
|
|
return callBack(statusCode()['error'], "未知的收银员");
|
|
}
|
|
if (empty($param['order_no'])) {
|
|
return callBack(statusCode()['error'], "缺少必要参数order_no");
|
|
}
|
|
if (!in_array($param['pay_type'], ['1', '2', '3', '5', '6', '7', '8'])) {
|
|
return callBack(statusCode()['error'], "支付类型有误");
|
|
}
|
|
if (!in_array($param['combine_pay'], ['0', '1'])) {
|
|
return callBack(statusCode()['error'], "支付方式有误");
|
|
}
|
|
if (!in_array($param['integral_cashing'], ['0', '1'])) {
|
|
return callBack(statusCode()['error'], "积分使用方式有误");
|
|
}
|
|
if (!verifyPrice($param['pay_money']) || !verifyPrice($param['amount_received']) || floatval($param['amount_received']) < floatval($param['pay_money']) || !verifyPrice($param['all_money'])) {
|
|
return callBack(statusCode()['error'], "支付金额有误");
|
|
}
|
|
if ($param['combine_pay'] == 0 && floatval($param['all_money']) > floatval($param['pay_money']) && $param['pay_type'] != 7) {
|
|
return callBack(statusCode()['error'], "您需要一次付清");
|
|
}
|
|
return callBack(statusCode()['success'], "验证成功");
|
|
}
|
|
|
|
} |