feat: 修改了订单核销逻辑和支付通知逻辑
This commit is contained in:
parent
2ce9a75c62
commit
51df5a3a94
@ -432,17 +432,14 @@ class OrderLogic extends BaseLogic
|
|||||||
'staff_id' => $params['staff_id']??0,
|
'staff_id' => $params['staff_id']??0,
|
||||||
'update_time' => time(),
|
'update_time' => time(),
|
||||||
], ['oid' => $order['id']]);
|
], ['oid' => $order['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']);
|
|
||||||
// }
|
|
||||||
PayNotifyLogic::descStock($order['id']);
|
PayNotifyLogic::descStock($order['id']);
|
||||||
$financeFlow=new StoreFinanceFlow();
|
$financeFlow=new StoreFinanceFlow();
|
||||||
$financeFlowLogic=new StoreFinanceFlowLogic();
|
$financeFlowLogic=new StoreFinanceFlowLogic();
|
||||||
$select_1=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>['in'=>14,15],'other_uid'=>['>'=>0]])->select();
|
$select_1=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>['in'=>14,15,16]])->select();
|
||||||
foreach($select_1 as $k=>$v){
|
foreach($select_1 as $k=>$v){
|
||||||
$financeFlowLogic->updateStatusUser($v['id'],$v['other_uid'],$v['number'],$v['order_id']);
|
if($v['other_uid']>0){
|
||||||
|
$financeFlowLogic->updateStatusUser($v['id'],$v['other_uid'],$v['number'],$v['order_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($order['uid'] && $order['pay_price'] >= 500){
|
if($order['uid'] && $order['pay_price'] >= 500){
|
||||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||||
@ -455,67 +452,9 @@ class OrderLogic extends BaseLogic
|
|||||||
$financeFlowLogic->updateStatusUser($spread_find['id'],$order['spread_uid'],$spread_find['number'],$order['order_id']);
|
$financeFlowLogic->updateStatusUser($spread_find['id'],$order['spread_uid'],$spread_find['number'],$order['order_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$deposit=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>11])->value('number');
|
$deposit=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>11])->value('number')??0;
|
||||||
$money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->value('number');
|
$money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->value('number')??0;
|
||||||
$financeFlowLogic->updateStatusStore($order['id'],$order['store_id'],$money,$deposit);
|
$financeFlowLogic->updateStatusStore($order['id'],$order['store_id'],$money,$deposit);
|
||||||
|
|
||||||
/* $check = Db::name('user_sign_log')->where('order_id',$order['order_id'])
|
|
||||||
->where(['status'=>0])
|
|
||||||
->find();//$check['number']扣的
|
|
||||||
if($check){
|
|
||||||
// User::where('id',$order['uid'])->inc('purchase_funds',$check['number'])->update();
|
|
||||||
// $user_number = bcmul($order['pay_price'], '0.10', 2);
|
|
||||||
|
|
||||||
$base = UserSign::where([
|
|
||||||
'uid'=>$order['uid'],
|
|
||||||
'type'=>1,
|
|
||||||
'status'=>1
|
|
||||||
])->find();
|
|
||||||
$user_sing = new UserSign();
|
|
||||||
if($base['number'] > 0 && $base['number'] >= $check['number']){
|
|
||||||
$sing = [
|
|
||||||
'uid' => $order['uid'],
|
|
||||||
'order_id' => $order['order_id'].'-b',
|
|
||||||
'title' => '返还兑换券',
|
|
||||||
'financial_pm' => 1,
|
|
||||||
'store_id' => $order['store_id'],
|
|
||||||
'status' => 1,
|
|
||||||
];
|
|
||||||
$sing['number'] = $check['number'];
|
|
||||||
$user_sing->save($sing);
|
|
||||||
User::where('id',$order['uid'])->inc('integral',$check['number'])->update();
|
|
||||||
//减少
|
|
||||||
UserSign::where('id',$check['sid'])->dec('number',$check['number'])->update();
|
|
||||||
if($base['number'] == $check['number']){
|
|
||||||
UserSign::where([
|
|
||||||
'id'=>$order['sid']
|
|
||||||
])->update(['status'=>1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($base['number'] < $check['number']){
|
|
||||||
$sing = [
|
|
||||||
'uid' => $order['uid'],
|
|
||||||
'order_id' => $order['order_id'].'-b',
|
|
||||||
'title' => '返还兑换券',
|
|
||||||
'financial_pm' => 1,
|
|
||||||
'store_id' => $order['store_id'],
|
|
||||||
'status' => 1,
|
|
||||||
];
|
|
||||||
$sing['number'] = $base['number'];
|
|
||||||
$user_sing->save($sing);
|
|
||||||
|
|
||||||
UserSign::where('id',$check['sid'])->dec('number',$base['number'])->update();
|
|
||||||
User::where('id',$order['uid'])->inc('integral',$base['number'])->update();
|
|
||||||
|
|
||||||
|
|
||||||
UserSign::where([
|
|
||||||
'id'=>$order['sid']
|
|
||||||
])->update(['status'=>1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::name('user_sign_log')->where('order_id',$order['order_id'])->update(['status'=>1]);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -36,7 +36,7 @@ use Webman\RedisQueue\Redis;
|
|||||||
* Class PayNotifyLogic
|
* Class PayNotifyLogic
|
||||||
* @package app\api\logic
|
* @package app\api\logic
|
||||||
*/
|
*/
|
||||||
class PayNotifyLogic extends BaseLogic
|
class PayNotifyLogicaaa extends BaseLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function handle($action, $orderSn, $extra = [], $type = 'wechat')
|
public static function handle($action, $orderSn, $extra = [], $type = 'wechat')
|
||||||
|
@ -27,9 +27,9 @@ class StoreFinanceFlowLogic extends BaseLogic
|
|||||||
* @param $staffId
|
* @param $staffId
|
||||||
* @param $status
|
* @param $status
|
||||||
*/
|
*/
|
||||||
public function out($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1,$pay_type=7)
|
public function out($transaction_id, $number, $financialType, $storeId = 0, $staffId = 0, $status = 1, $pay_type = 7)
|
||||||
{
|
{
|
||||||
$this->setData($number, $financialType, 0, $storeId, $staffId, $status,$transaction_id,$pay_type);
|
$this->setData($number, $financialType, 0, $storeId, $staffId, $status, $transaction_id, $pay_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,22 +41,22 @@ class StoreFinanceFlowLogic extends BaseLogic
|
|||||||
* @param $staffId
|
* @param $staffId
|
||||||
* @param $status
|
* @param $status
|
||||||
*/
|
*/
|
||||||
public function in($transaction_id,$number, $financialType, $storeId = 0, $staffId = 0, $status = 1,$pay_type=7)
|
public function in($transaction_id, $number, $financialType, $storeId = 0, $staffId = 0, $status = 1, $pay_type = 7)
|
||||||
{
|
{
|
||||||
$this->setData($number, $financialType, 1, $storeId, $staffId, $status,$transaction_id,$pay_type);
|
$this->setData($number, $financialType, 1, $storeId, $staffId, $status, $transaction_id, $pay_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setData($number, $financialType, $pm, $storeId, $staffId, $status,$transaction_id,$pay_type=7)
|
public function setData($number, $financialType, $pm, $storeId, $staffId, $status, $transaction_id, $pay_type = 7)
|
||||||
{
|
{
|
||||||
if (empty($this->financeSn)) {
|
if (empty($this->financeSn)) {
|
||||||
$this->financeSn = $this->getSn();
|
$this->financeSn = $this->getSn();
|
||||||
}
|
}
|
||||||
$data=[
|
$data = [
|
||||||
'order_id' => $this->order['id'],
|
'order_id' => $this->order['id'],
|
||||||
'transaction_id' => $transaction_id,
|
'transaction_id' => $transaction_id,
|
||||||
'order_sn' => $this->order['order_id'],
|
'order_sn' => $this->order['order_id'],
|
||||||
'user_id' => $this->user['uid']??0,
|
'user_id' => $this->user['uid'] ?? 0,
|
||||||
'other_uid' => $this->other_arr['vip_uid']??0,
|
'other_uid' => $this->other_arr['vip_uid'] ?? 0,
|
||||||
'financial_type' => $financialType,
|
'financial_type' => $financialType,
|
||||||
'financial_pm' => $pm,
|
'financial_pm' => $pm,
|
||||||
'number' => $number,
|
'number' => $number,
|
||||||
@ -65,22 +65,22 @@ class StoreFinanceFlowLogic extends BaseLogic
|
|||||||
'store_id' => $storeId !== '' ? $storeId : $this->order['store_id'],
|
'store_id' => $storeId !== '' ? $storeId : $this->order['store_id'],
|
||||||
'staff_id' => $staffId !== '' ? $staffId : $this->order['staff_id'],
|
'staff_id' => $staffId !== '' ? $staffId : $this->order['staff_id'],
|
||||||
'financial_record_sn' => $this->financeSn . ($this->index++),
|
'financial_record_sn' => $this->financeSn . ($this->index++),
|
||||||
'create_time'=>time()
|
'create_time' => time()
|
||||||
];
|
];
|
||||||
switch($financialType){
|
switch ($financialType) {
|
||||||
case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户
|
case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户
|
||||||
case OrderEnum::ORDER_MARGIN: // 商户保证金
|
case OrderEnum::ORDER_MARGIN: // 商户保证金
|
||||||
$data['type'] =OrderEnum::MERCHANT;
|
$data['type'] = OrderEnum::MERCHANT;
|
||||||
break;
|
break;
|
||||||
case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台
|
case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台
|
||||||
case OrderEnum::ORDER_HANDLING_FEES: // 手续费
|
case OrderEnum::ORDER_HANDLING_FEES: // 手续费
|
||||||
$data['type'] =OrderEnum::PLATFORM;
|
$data['type'] = OrderEnum::PLATFORM;
|
||||||
break;
|
break;
|
||||||
case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链
|
case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链
|
||||||
$data['type'] =OrderEnum::SUPPLIER;
|
$data['type'] = OrderEnum::SUPPLIER;
|
||||||
break;
|
break;
|
||||||
default: // 用户
|
default: // 用户
|
||||||
$data['type'] =OrderEnum::USER;
|
$data['type'] = OrderEnum::USER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->list[] = $data;
|
$this->list[] = $data;
|
||||||
@ -131,30 +131,35 @@ class StoreFinanceFlowLogic extends BaseLogic
|
|||||||
/**
|
/**
|
||||||
* 核销后更新用户余额
|
* 核销后更新用户余额
|
||||||
*/
|
*/
|
||||||
public function updateStatusUser($id,$uid,$money,$order_id){
|
public function updateStatusUser($id, $uid, $money, $order_id)
|
||||||
|
{
|
||||||
StoreFinanceFlow::where('id', $id)->update(['status' => 1]);
|
StoreFinanceFlow::where('id', $id)->update(['status' => 1]);
|
||||||
$find=User::where('id',$uid)->find();
|
$find = User::where('id', $uid)->find();
|
||||||
$capitalFlowDao = new CapitalFlowLogic($find);
|
$capitalFlowDao = new CapitalFlowLogic($find);
|
||||||
$capitalFlowDao->userIncome('system_balance_add', 'order', $order_id, $money);
|
$capitalFlowDao->userIncome('system_balance_add', 'order', $order_id, $money);
|
||||||
$find->inc('now_money',$money)->update();
|
$find->inc('now_money', $money)->update();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 核销后更新门店余额
|
* 核销后更新门店余额
|
||||||
*/
|
*/
|
||||||
public function updateStatusStore($order_id,$store_id,$money,$deposit){
|
public function updateStatusStore($order_id, $store_id, $money, $deposit)
|
||||||
StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>11])->update(['status' => 1]);
|
{
|
||||||
StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>2])->update(['status' => 1]);
|
StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 11])->update(['status' => 1]);
|
||||||
if($money){
|
StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 2])->update(['status' => 1]);
|
||||||
|
if ($money>0) {
|
||||||
SystemStore::where('id', $store_id)->inc('store_money', $money)->update();
|
SystemStore::where('id', $store_id)->inc('store_money', $money)->update();
|
||||||
}
|
}
|
||||||
if($deposit){
|
if ($deposit>0) {
|
||||||
SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update();
|
SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update();
|
||||||
}
|
}
|
||||||
$find=StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>16])->find();
|
|
||||||
if($find){
|
$find = StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 16])->find();
|
||||||
$find->update(['status' => 1]);
|
if ($find) {
|
||||||
SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update();
|
$find->status=1;
|
||||||
|
$find->save();
|
||||||
|
if ($find['number'] > 0) { // 核销后更新库存
|
||||||
|
SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -310,8 +310,8 @@ class StoreOrderController extends BaseAdminController
|
|||||||
public function writeoff_order()
|
public function writeoff_order()
|
||||||
{
|
{
|
||||||
$params = (new OrderValidate())->post()->goCheck('check');
|
$params = (new OrderValidate())->post()->goCheck('check');
|
||||||
$count = StoreOrder::where('verify_code', $params['verify_code'])->count();
|
$count = StoreOrder::where('verify_code', $params['verify_code'])->find();
|
||||||
if (empty($count)) {
|
if (!$count) {
|
||||||
return $this->fail('无该核销码请检查');
|
return $this->fail('无该核销码请检查');
|
||||||
}
|
}
|
||||||
$params['store_id'] = $this->adminInfo['store_id'];
|
$params['store_id'] = $this->adminInfo['store_id'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user