This commit is contained in:
liu 2024-06-28 18:42:41 +08:00
commit 1acc001559
4 changed files with 42 additions and 98 deletions

View File

@ -432,18 +432,15 @@ 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){
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);
User::where('id', $order['uid'])->inc('integral', $user_number)->update();
@ -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) {

View File

@ -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')

View File

@ -131,7 +131,8 @@ 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();
$capitalFlowDao = new CapitalFlowLogic($find);
@ -141,20 +142,24 @@ class StoreFinanceFlowLogic extends BaseLogic
/**
* 核销后更新门店余额
*/
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]);
if($money){
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]);
$find->status=1;
$find->save();
if ($find['number'] > 0) { // 核销后更新库存
SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update();
}
}
}
}

View File

@ -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'];