feat(StoreOrderLogic): 新增针对特定商店ID的价格更新逻辑

This commit is contained in:
mkm 2024-09-02 16:52:49 +08:00
parent efc7286162
commit a5d93516b2
3 changed files with 33 additions and 28 deletions

View File

@ -46,6 +46,9 @@ class StoreOrderLogic extends BaseLogic
$v['uid'] = $params['user_id'];
$v['store_id'] = $params['store_id'];
$v['cart_num'] = $v['stock'];
if(in_array($params['store_id'],[17,18])){
StoreBranchProduct::where('id', $v['id'])->update(['price' => $v['price'], 'vip_price' => $v['price'], 'cost' => $v['price'], 'purchase' => $v['price']]);
}
unset($v['id']);
$res = CartLogic::add($v);
$cartId[] = $res['id'];
@ -53,6 +56,7 @@ class StoreOrderLogic extends BaseLogic
$user = User::where('id', $params['user_id'])->find();
$params['shipping_type'] = 2;
$params['pay_type'] = 7;
$params['source'] =2;
$order = OrderLogic::createOrder($cartId, null, $user, $params);
return true;
}

View File

@ -183,39 +183,40 @@ class StoreFinanceFlowLogic extends BaseLogic
->select();
foreach ($list as $k => $value) {
//用户
switch ($value['type']) {
case 0:
if ($value['financial_type'] == 12 && $value['other_uid'] > 0) {
$user = User::where('id', $value['other_uid'])->findOrEmpty();
$capitalFlowDao = new CapitalFlowLogic($user);
$user->now_money = bcsub($user['now_money'], $value['number'], 2);
$user->save();
// Log::error('aa'.$a);
// Log::error('aa'.$user['now_money']);
// Log::error('aa'.$value['number']);
$capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'], '', $value['pay_type']);
}
break;
//商户
case 1:
$store = SystemStore::where('id', $store_id)->find();
$capitalFlowDao = new CapitalFlowLogic($store, 'store');
if ($value['number'] > 0 && $value['financial_type'] == 2) {
SystemStore::where('id', $value['store_id'])->dec('store_money', $value['number'])->update();
$capitalFlowDao->storeExpense('store_paid_deposit_dec', 'order', $value['order_id'],$value['number']);
if($value['type']==0){
if ($value['financial_type'] == 12 && $value['other_uid'] > 0) {
$user = User::where('id', $value['other_uid'])->findOrEmpty();
$capitalFlowDao = new CapitalFlowLogic($user);
$user->now_money = bcsub($user['now_money'], $value['number'], 2);
$user->save();
$capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'], '', $value['pay_type']);
}
}elseif($value['type']==1){
$store = SystemStore::where('id', $store_id)->find();
$capitalFlowDao = new CapitalFlowLogic($store, 'store');
if ($value['number'] > 0 && $value['financial_type'] == 2) {
$find=SystemStore::where('id', $value['store_id'])->find();
$find->store_money=bcsub($find['store_money'], $value['number'],2);
$find->save();
$capitalFlowDao->storeExpense('store_money_refund', 'order', $value['order_id'],$value['number'],'','store_money');
}
if ($value['number'] > 0 && $value['financial_type'] == 16) {
SystemStore::where('id', $value['store_id'])->dec('attrition', $value['number'])->update();
$capitalFlowDao->storeExpense('store_attrition_dec', 'order', $value['order_id'], $value['number']);
}
if ($value['number'] > 0 && $value['financial_type'] == 16) {
$find=SystemStore::where('id', $value['store_id'])->find();
$find->attrition=bcsub($find['attrition'], $value['number'],2);
$find->save();
$capitalFlowDao->storeExpense('store_attrition_refund', 'order', $value['order_id'], $value['number'],'','attrition');
}
break;
}
}
}
$find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status', 1)->find();
if ($find && $find['number'] > 0) {
SystemStore::where('id', $find['store_id'])->dec('paid_deposit', $find['number'])->update();
$find=SystemStore::where('id', $value['store_id'])->find();
$capitalFlowDao = new CapitalFlowLogic($find, 'store');
$find->paid_deposit=bcsub($find['paid_deposit'], $value['number'],2);
$find->save();
$capitalFlowDao->storeExpense('store_paid_deposit_refund', 'order', $value['order_id'],$value['number'],'','paid_deposit');
}
// $data = StoreFinanceFlow::where('order_sn', $orderSn)->select();
// foreach ($data as $k => &$value) {

View File

@ -23,7 +23,7 @@ class Task
new Crontab('0 */10 * * * *', function () {
$where = ['paid' => 0];
$where[] = ['create_time', '<', time() - 600]; // 10分钟前创建的订单
$where[] = ['shipping_type', '<>',4];
$where[] = ['source', '<',2];
// 删除10分钟未支付的订单
$oid = StoreOrder::where($where)->column('id'); // 删除时间设置为当前时间,即删除
if ($oid) {