feat: 修改了订单核销逻辑和支付通知逻辑
This commit is contained in:
parent
2ce9a75c62
commit
51df5a3a94
@ -432,17 +432,14 @@ class OrderLogic extends BaseLogic
|
||||
'staff_id' => $params['staff_id']??0,
|
||||
'update_time' => time(),
|
||||
], ['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']);
|
||||
$financeFlow=new StoreFinanceFlow();
|
||||
$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){
|
||||
$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){
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
$deposit=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>11])->value('number');
|
||||
$money=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>2])->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')??0;
|
||||
$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();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
|
@ -36,7 +36,7 @@ use Webman\RedisQueue\Redis;
|
||||
* Class PayNotifyLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class PayNotifyLogic extends BaseLogic
|
||||
class PayNotifyLogicaaa extends BaseLogic
|
||||
{
|
||||
|
||||
public static function handle($action, $orderSn, $extra = [], $type = 'wechat')
|
||||
|
@ -27,9 +27,9 @@ class StoreFinanceFlowLogic extends BaseLogic
|
||||
* @param $staffId
|
||||
* @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 $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)) {
|
||||
$this->financeSn = $this->getSn();
|
||||
}
|
||||
$data=[
|
||||
$data = [
|
||||
'order_id' => $this->order['id'],
|
||||
'transaction_id' => $transaction_id,
|
||||
'order_sn' => $this->order['order_id'],
|
||||
'user_id' => $this->user['uid']??0,
|
||||
'other_uid' => $this->other_arr['vip_uid']??0,
|
||||
'user_id' => $this->user['uid'] ?? 0,
|
||||
'other_uid' => $this->other_arr['vip_uid'] ?? 0,
|
||||
'financial_type' => $financialType,
|
||||
'financial_pm' => $pm,
|
||||
'number' => $number,
|
||||
@ -65,22 +65,22 @@ class StoreFinanceFlowLogic extends BaseLogic
|
||||
'store_id' => $storeId !== '' ? $storeId : $this->order['store_id'],
|
||||
'staff_id' => $staffId !== '' ? $staffId : $this->order['staff_id'],
|
||||
'financial_record_sn' => $this->financeSn . ($this->index++),
|
||||
'create_time'=>time()
|
||||
'create_time' => time()
|
||||
];
|
||||
switch($financialType){
|
||||
switch ($financialType) {
|
||||
case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户
|
||||
case OrderEnum::ORDER_MARGIN: // 商户保证金
|
||||
$data['type'] =OrderEnum::MERCHANT;
|
||||
$data['type'] = OrderEnum::MERCHANT;
|
||||
break;
|
||||
case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台
|
||||
case OrderEnum::ORDER_HANDLING_FEES: // 手续费
|
||||
$data['type'] =OrderEnum::PLATFORM;
|
||||
$data['type'] = OrderEnum::PLATFORM;
|
||||
break;
|
||||
case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链
|
||||
$data['type'] =OrderEnum::SUPPLIER;
|
||||
case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链
|
||||
$data['type'] = OrderEnum::SUPPLIER;
|
||||
break;
|
||||
default: // 用户
|
||||
$data['type'] =OrderEnum::USER;
|
||||
$data['type'] = OrderEnum::USER;
|
||||
break;
|
||||
}
|
||||
$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]);
|
||||
$find=User::where('id',$uid)->find();
|
||||
$find = User::where('id', $uid)->find();
|
||||
$capitalFlowDao = new CapitalFlowLogic($find);
|
||||
$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){
|
||||
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]);
|
||||
if($money){
|
||||
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]);
|
||||
if ($money>0) {
|
||||
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();
|
||||
}
|
||||
$find=StoreFinanceFlow::where(['order_id'=>$order_id,'financial_pm'=>1,'financial_type'=>16])->find();
|
||||
if($find){
|
||||
$find->update(['status' => 1]);
|
||||
SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update();
|
||||
|
||||
$find = StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 16])->find();
|
||||
if ($find) {
|
||||
$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()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('check');
|
||||
$count = StoreOrder::where('verify_code', $params['verify_code'])->count();
|
||||
if (empty($count)) {
|
||||
$count = StoreOrder::where('verify_code', $params['verify_code'])->find();
|
||||
if (!$count) {
|
||||
return $this->fail('无该核销码请检查');
|
||||
}
|
||||
$params['store_id'] = $this->adminInfo['store_id'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user