This commit is contained in:
liu 2024-06-27 17:51:55 +08:00
commit 693043303c
5 changed files with 1047 additions and 43 deletions

View File

@ -65,8 +65,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
$item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name');
return $item;
})
->toArray();
})?->toArray();
}

View File

@ -15,6 +15,7 @@ use app\common\model\dict\DictData;
use app\common\model\dict\DictType;
use app\common\model\order\Cart;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
@ -405,10 +406,11 @@ class OrderLogic extends BaseLogic
*/
public static function writeOff($params): bool
{
$data = StoreOrder::with('store')->where([
$order = StoreOrder::with('store')->where([
'verify_code' => $params['verify_code']
])->find();
if (empty($data)) {
if (empty($order)) {
self::setError('订单不存在');
return false;
}
Db::startTrans();
@ -420,7 +422,7 @@ class OrderLogic extends BaseLogic
'update_time' => time(),
'store_id' => $params['store_id'],
'staff_id' => $params['staff_id']??0,
], ['id' => $data['id']]);
], ['id' => $order['id']]);
(new StoreOrderCartInfo())->update([
'verify_code'=>$params['verify_code'].'-1',
'writeoff_time' => time(),
@ -428,20 +430,33 @@ class OrderLogic extends BaseLogic
'store_id' => $params['store_id'],
'staff_id' => $params['staff_id']??0,
'update_time' => time(),
], ['oid' => $data['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']);
// }
$order=StoreOrder::where('id',$data['id'])->find();
// PayNotifyLogic::afterPay($order);
PayNotifyLogic::descStock($order['id']);
if($order['uid'] && $order['total_price'] >= 500){
$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();
foreach($select_1 as $k=>$v){
$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();
UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id']])->update(['status'=>1]);
}
if ($order['spread_uid'] > 0) {
$spread_find=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>12,'other_uid'=>$order['spread_uid']])->find();
if($spread_find){
$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');
$financeFlowLogic->updateStatusStore($order['id'],$order['store_id'],$money,$deposit);
Db::commit();
return true;

File diff suppressed because it is too large Load Diff

View File

@ -750,19 +750,6 @@ class PayNotifyLogic extends BaseLogic
$financeLogic = new StoreFinanceFlowLogic();
$user_sing = new UserSign();
$off_activity = Config::where('name', 'off_activity')->value('value');
try{
$url=getenv('WETCHA_PUSH');
if($url){
$order_id=$order['order_id'];
$pay_price=$order['pay_price'];
$arr=["msgtype"=>"markdown","markdown"=>["content"=> "有新的订单请及时跟踪\n
>单号:<font color=\"comment\">$order_id</font>
>金额:<font color=\"comment\">$pay_price</font>"]];
(new Curl())->post($url,$arr);
}
}catch(\Exception $e){
Log::error('推送订单失败',['order_id'=>$order['id'],'error'=>$e->getMessage()]);
}
if ($off_activity == 1) {
//-----活动价结算更改
$financeLogic->order = $order;
@ -770,6 +757,7 @@ class PayNotifyLogic extends BaseLogic
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->save();
if ($order['uid'] > 0 && $order['total_price'] > 500 && $order['pay_type'] !=18
&& $order['pay_type'] !=3) {
$user_number = bcmul($order['pay_price'], '0.10', 2);
@ -847,46 +835,35 @@ class PayNotifyLogic extends BaseLogic
if ($deposit > 0) {
if ($deposit > $store_profit) {
if ($store_profit > 0) {
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update();
// SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update();
$financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
}
} else {
$money = bcsub($store_profit, $deposit, 2);
if ($deposit > 0) {
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update();
// SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update();
$financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
}
if ($money) {
SystemStore::where('id', $order['store_id'])->inc('store_money', $money)->update();
// SystemStore::where('id', $order['store_id'])->inc('store_money', $money)->update();
$financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
}
}
} else {
if ($store_profit > 0) {
SystemStore::where('id', $order['store_id'])->inc('store_money', $store_profit)->update();
// SystemStore::where('id', $order['store_id'])->inc('store_money', $store_profit)->update();
$financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
}
}
// if ($order['is_vip'] >= 1) {
if ($order['spread_uid'] > 0) {
$financeLogic->other_arr['vip_uid'] = $order['spread_uid'];
if ($vipFen) {
$fees = bcdiv(bcmul($vipFen, '0.08', 2), 1, 2);
} else {
$fees = bcdiv(bcmul($order['pay_price'], '0.08', 2), 1, 2);
}
$count_frees = bcadd($count_frees, $fees, 2);
if ($fees > 0) {
User::where('id', $order['spread_uid'])->inc('now_money', $fees)->update();
//记录用户余额收入
$GiveUser = User::where('id', $order['spread_uid'])->find();
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
$financeLogic->in($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //vip订单获得
$financeLogic->out($transaction_id, $fees, OrderEnum::VIP_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
}
}
$fees = bcdiv(bcmul($order['pay_price'], '0.01', 2), 1, 2);
$count_frees = bcadd($count_frees, bcmul($fees, 3, 2), 2);
@ -900,7 +877,7 @@ class PayNotifyLogic extends BaseLogic
if ($arr1) {
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
if ($uid) {
User::where('id', $uid)->inc('integral', $fees)->update();
// User::where('id', $uid)->inc('integral', $fees)->update();
$village_uid = $uid;
}
}
@ -908,7 +885,7 @@ class PayNotifyLogic extends BaseLogic
if ($arr2) {
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
if ($uid) {
User::where('id', $uid)->inc('integral', $fees)->update();
// User::where('id', $uid)->inc('integral', $fees)->update();
$brigade_uid = $uid;
}
}
@ -955,14 +932,14 @@ class PayNotifyLogic extends BaseLogic
// 'user_ship' => 3,
// ];
if ($village_uid > 0) {
SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update();
// SystemStore::where('id', $village_uid)->inc('store_money', $fees)->update();
$financeLogic->other_arr['vip_uid'] = $village_uid;
}
$financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
//队长获得
if ($brigade_uid > 0) {
SystemStore::where('id', $brigade_uid)->inc('store_money', $fees)->update();
// SystemStore::where('id', $brigade_uid)->inc('store_money', $fees)->update();
$financeLogic->other_arr['vip_uid'] = $brigade_uid;
}
$financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);

View File

@ -5,6 +5,7 @@ namespace app\common\logic;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
class StoreFinanceFlowLogic extends BaseLogic
@ -128,7 +129,7 @@ class StoreFinanceFlowLogic extends BaseLogic
}
/**
* 核销后更新余额
* 核销后更新用户余额
*/
public function updateStatusUser($id,$uid,$money,$order_id){
StoreFinanceFlow::where('id', $id)->update(['status' => 1]);
@ -137,6 +138,18 @@ class StoreFinanceFlowLogic extends BaseLogic
$capitalFlowDao->userIncome('system_balance_add', 'order', $order_id, $money);
$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){
SystemStore::where('id', $store_id)->inc('store_money', $money)->update();
}
if($deposit){
SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update();
}
}
}