Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
d930bebe6c
@ -131,7 +131,7 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
//加支付方式限制
|
||||
$pay_type = isset($params['pay_type'])?$params['pay_type']:0;
|
||||
if ($user && $user['user_ship'] == 1 && $pay_type ==17) {
|
||||
if ($user && $user['user_ship'] == 1 && $pay_type !=17) {
|
||||
$pay_price = self::$pay_price;
|
||||
}else{
|
||||
$pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
||||
@ -399,7 +399,6 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
|
||||
//核销
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return bool
|
||||
@ -452,6 +451,51 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
//不走二次分钱的核销
|
||||
public static function lessWriteOff($params): bool
|
||||
{
|
||||
$data = StoreOrder::with('store')->where([
|
||||
'verify_code' => $params['verify_code']
|
||||
])->find();
|
||||
if (empty($data)) {
|
||||
return false;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
StoreOrder::update([
|
||||
'verify_code'=>$params['verify_code'].'-1',
|
||||
'status' => OrderEnum::RECEIVED_GOODS,
|
||||
'is_writeoff' => OrderEnum::IS_OK,
|
||||
'update_time' => time(),
|
||||
'store_id' => $params['store_id'],
|
||||
'staff_id' => $params['staff_id']??0,
|
||||
], ['id' => $data['id']]);
|
||||
(new StoreOrderCartInfo())->update([
|
||||
'verify_code'=>$params['verify_code'].'-1',
|
||||
'writeoff_time' => time(),
|
||||
'is_writeoff' => YesNoEnum::YES,
|
||||
'store_id' => $params['store_id'],
|
||||
'staff_id' => $params['staff_id']??0,
|
||||
'update_time' => time(),
|
||||
], ['oid' => $data['id']]);
|
||||
// $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']);
|
||||
// if (!empty($financeFlow)) {
|
||||
// $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store');
|
||||
// $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']);
|
||||
// }
|
||||
$order=StoreOrder::where('id',$data['id'])->find();
|
||||
PayNotifyLogic::descStock($order['id']);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function write_count($info, $params)
|
||||
{
|
||||
|
@ -32,6 +32,7 @@ class PayEnum
|
||||
* @CORPORATE_TRANSFER 对公转账
|
||||
* @CASH_PAY 现金支付
|
||||
* @PURCHASE_FUNDS 采购款收银
|
||||
* @GIFT_FUNDS 礼品券收银
|
||||
*/
|
||||
const BALANCE_PAY = 3;
|
||||
const WECHAT_PAY = 1;
|
||||
@ -51,6 +52,7 @@ class PayEnum
|
||||
const CORPORATE_TRANSFER = 16;
|
||||
const CASH_PAY = 17;
|
||||
const PURCHASE_FUNDS = 18;//采购款收银
|
||||
const GIFT_FUNDS = 19;//礼品券收银
|
||||
//支付状态
|
||||
const UNPAID = 0; //未支付
|
||||
const ISPAID = 1; //已支付
|
||||
|
@ -37,7 +37,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($action != 'cash_pay' && $action != 'balancePay' && $action != 'purchase_funds') {
|
||||
if ($action != 'cash_pay' && $action != 'balancePay' && $action != 'purchase_funds' && $action != 'gift_pay') {
|
||||
$payNotifyLogLogic = new PayNotifyLogLogic();
|
||||
if ($action == 'refund') {
|
||||
$payNotifyLogLogic->insert($action, $extra, PayNotifyLog::TYPE_REFUND);
|
||||
@ -98,6 +98,56 @@ class PayNotifyLogic extends BaseLogic
|
||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼品券支付
|
||||
* @param $orderSn
|
||||
* @param $extra
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
|
||||
public static function gift_pay($orderSn, $extra = [])
|
||||
{
|
||||
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
|
||||
$user = User::where('id', $order['uid'])->find();
|
||||
if ($user['integral'] < $order['pay_price']) {
|
||||
throw new \Exception('礼品券不足');
|
||||
}
|
||||
$order->money = $order['pay_price'];
|
||||
$order->paid = 1;
|
||||
$order->pay_time = time();
|
||||
if (!$order->save()) {
|
||||
throw new \Exception('订单保存出错');
|
||||
}
|
||||
// 减去礼品券
|
||||
$user->integral = bcsub($user['integral'], $order['pay_price'], 2);
|
||||
$user->save();
|
||||
//入礼品券表扣款记录
|
||||
$sing[] = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '订单扣除兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $order['pay_price'],
|
||||
'financial_pm' => 0,
|
||||
'user_ship' => $user['user_ship'],
|
||||
];
|
||||
(new UserSign())->saveAll($sing);
|
||||
|
||||
if($extra && $extra['store_id']){
|
||||
$params = [
|
||||
'verify_code'=>$order['verify_code'],
|
||||
'store_id'=>$extra['store_id'],
|
||||
'staff_id'=>$extra['staff_id']
|
||||
];
|
||||
OrderLogic::lessWriteOff($params);
|
||||
}
|
||||
self::dealProductLog($order);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 采购款支付
|
||||
|
@ -356,14 +356,14 @@ class StoreOrderLogic extends BaseLogic
|
||||
throw new \Exception('用户未设置手机号');
|
||||
}
|
||||
$template = getenv('SMS_TEMPLATE');
|
||||
if($type){
|
||||
$check =(new SmsService())->client($phone,$template,$code,1);
|
||||
}else{
|
||||
$check =(new SmsService())->client($phone,$template,$code);
|
||||
}
|
||||
$check =(new SmsService())->client($phone,$template,$code);
|
||||
|
||||
if($check){
|
||||
$remark = $param['uid'].'_smsPay';
|
||||
if($type == 1){
|
||||
$remark = $param['uid'].'_smsPay';
|
||||
}else{
|
||||
$remark = $param['uid'].'_giftPay';
|
||||
}
|
||||
Cache::set($remark,$code,5*60);
|
||||
return true;
|
||||
}else{
|
||||
|
@ -109,10 +109,17 @@ class StoreOrderController extends BaseAdminController
|
||||
if (!$order) {
|
||||
return $this->fail(StoreOrderLogic::getError());
|
||||
}
|
||||
if ($order['order']['pay_price'] > $user['purchase_funds']) {
|
||||
return $this->fail('当前用户采购款不足支付');
|
||||
if($params['type'] == 1){
|
||||
if ($order['order']['pay_price'] > $user['purchase_funds']) {
|
||||
return $this->fail('当前用户采购款不足支付');
|
||||
}
|
||||
}elseif ($params['type'] == 2){
|
||||
if ($order['order']['pay_price'] > $user['integral']) {
|
||||
return $this->fail('当前用户礼品券不足支付');
|
||||
}
|
||||
}
|
||||
$res = (new StoreOrderLogic())->dealSendSms($params);
|
||||
|
||||
$res = (new StoreOrderLogic())->dealSendSms($params,$params['type']);
|
||||
if ($res) {
|
||||
return $this->success('发送成功', [], 1, 0);
|
||||
} else {
|
||||
@ -132,7 +139,8 @@ class StoreOrderController extends BaseAdminController
|
||||
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||
$uid=$this->request->post('uid');
|
||||
$params = $this->request->post();
|
||||
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS) {
|
||||
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY && $pay_type != PayEnum::PURCHASE_FUNDS
|
||||
&& $pay_type != PayEnum::GIFT_FUNDS) {
|
||||
return $this->fail('支付条码不能为空');
|
||||
}
|
||||
if (count($cartId) > 100) {
|
||||
@ -141,10 +149,19 @@ class StoreOrderController extends BaseAdminController
|
||||
if($pay_type == PayEnum::PURCHASE_FUNDS){
|
||||
$remark = $uid.'_smsPay';
|
||||
$code = Cache::get($remark);
|
||||
if ($code && isset($params['code']) && $code !== $params['code']) {
|
||||
if ($code && isset($params['code']) && $code != $params['code']) {
|
||||
throw new Exception('验证码错误');
|
||||
}
|
||||
}
|
||||
|
||||
if($pay_type == PayEnum::GIFT_FUNDS){
|
||||
$remark = $uid.'_giftPay';
|
||||
$code = Cache::get($remark);
|
||||
if ($code && isset($params['code']) && $code != $params['code']) {
|
||||
throw new Exception('验证码错误');
|
||||
}
|
||||
}
|
||||
|
||||
$user = null;
|
||||
if ($uid) {
|
||||
$user = User::where('id', $uid)->find();
|
||||
@ -160,7 +177,13 @@ class StoreOrderController extends BaseAdminController
|
||||
'staff_id'=>$this->request->adminInfo['admin_id']
|
||||
]);
|
||||
return $this->success('采购款支付成功', ['id' => $order['id']]);
|
||||
|
||||
case PayEnum::GIFT_FUNDS:
|
||||
//礼品券支付
|
||||
PayNotifyLogic::handle('gift_pay', $order['order_id'],[
|
||||
'store_id'=>$this->request->adminInfo['store_id'],
|
||||
'staff_id'=>$this->request->adminInfo['admin_id']
|
||||
]);
|
||||
return $this->success('礼品券支付成功', ['id' => $order['id']]);
|
||||
case PayEnum::CASH_PAY:
|
||||
//现金支付
|
||||
PayNotifyLogic::handle('cash_pay', $order['order_id']);
|
||||
|
@ -23,6 +23,7 @@ class StoreOrderValidate extends BaseValidate
|
||||
'verify_code' => 'requireWithout:id',
|
||||
'uid' => 'require|number',
|
||||
'cart_id' => 'require|array',
|
||||
'type' => 'require|number',
|
||||
];
|
||||
|
||||
|
||||
@ -33,6 +34,7 @@ class StoreOrderValidate extends BaseValidate
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'verify_code' => '核销码',
|
||||
'type' => '发送短信类型',
|
||||
];
|
||||
|
||||
|
||||
@ -85,7 +87,7 @@ class StoreOrderValidate extends BaseValidate
|
||||
|
||||
public function sceneCheck()
|
||||
{
|
||||
return $this->only(['uid','cart_id']);
|
||||
return $this->only(['uid','cart_id','type']);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user