feat: 修改商品订单相关逻辑
This commit is contained in:
parent
61175aa684
commit
596ce9d66d
@ -65,22 +65,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
|||||||
foreach ($list as $key => &$item) {
|
foreach ($list as $key => &$item) {
|
||||||
|
|
||||||
$find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']])
|
$find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']])
|
||||||
->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price')
|
->field('product_id,image,cost price,cost,store_name,unit,delete_time,vip_price')
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
if ($find) {
|
if ($find) {
|
||||||
if ($user && $user['user_ship'] == 1) {
|
// if ($user && $user['user_ship'] == 1) {
|
||||||
//更新 会员为1的时候原价减去会员价
|
// //更新 会员为1的时候原价减去会员价
|
||||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2);
|
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2);
|
||||||
$this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2);
|
// $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2);
|
||||||
}elseif ($user && $user['user_ship'] == 4) {
|
// }elseif ($user && $user['user_ship'] == 4) {
|
||||||
//更新 为4商户的时候减去商户价格
|
// //更新 为4商户的时候减去商户价格
|
||||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2);
|
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2);
|
||||||
$this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2);
|
// $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2);
|
||||||
}else{
|
// }else{
|
||||||
$this->activity_price =0;
|
// $this->activity_price =0;
|
||||||
}
|
// }
|
||||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||||
$item['imgs'] = $find['image'];
|
$item['imgs'] = $find['image'];
|
||||||
|
@ -83,7 +83,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
$this->searchWhere[] = ['status', '=', 1];
|
$this->searchWhere[] = ['status', '=', 1];
|
||||||
$this->searchWhere[] = ['stock', '>', 0];
|
$this->searchWhere[] = ['stock', '>', 0];
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
return StoreBranchProduct::where($this->searchWhere)
|
||||||
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
|
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'cost price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
|
||||||
->with(['className', 'unitName'])
|
->with(['className', 'unitName'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order($this->sortOrder)
|
->order($this->sortOrder)
|
||||||
|
@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic
|
|||||||
/** 计算价格 */
|
/** 计算价格 */
|
||||||
|
|
||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find();
|
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id')->withTrashed()->find();
|
||||||
if (!$find) {
|
if (!$find) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -85,19 +85,19 @@ class OrderLogic extends BaseLogic
|
|||||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||||
$cart_select[$k]['vip'] = 0;
|
$cart_select[$k]['vip'] = 0;
|
||||||
if ($user && $user['user_ship'] == 1) {
|
// if ($user && $user['user_ship'] == 1) {
|
||||||
//更新 会员为1的时候原价减去会员价
|
// //更新 会员为1的时候原价减去会员价
|
||||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||||
$cart_select[$k]['vip'] =1;
|
// $cart_select[$k]['vip'] =1;
|
||||||
}
|
// }
|
||||||
if ($user && $user['user_ship'] == 4) {
|
// if ($user && $user['user_ship'] == 4) {
|
||||||
//更新 为4商户的时候减去商户价格
|
// //更新 为4商户的时候减去商户价格
|
||||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//利润
|
//利润
|
||||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||||
|
@ -272,8 +272,8 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
||||||
if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){
|
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||||
if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额
|
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额
|
||||||
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
||||||
$user->save();
|
$user->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
@ -281,7 +281,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
//退款
|
//退款
|
||||||
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
|
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
|
||||||
}
|
}
|
||||||
if($order['pay_type'] == PayEnum::PURCHASE_FUNDS){//采购款
|
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款
|
||||||
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
|
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
|
||||||
$user->save();
|
$user->save();
|
||||||
//增加数量
|
//增加数量
|
||||||
@ -289,11 +289,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
//退款
|
//退款
|
||||||
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
|
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//微信日志 user_order_refund
|
//微信日志 user_order_refund
|
||||||
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money,'',1);
|
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
|
||||||
self::addStock($order['id']);//微信
|
self::addStock($order['id']); //微信
|
||||||
|
|
||||||
// self::afterPay($order,$extra['transaction_id']);
|
// self::afterPay($order,$extra['transaction_id']);
|
||||||
}
|
}
|
||||||
@ -320,7 +319,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$order->save();
|
$order->save();
|
||||||
//日志记录
|
//日志记录
|
||||||
$model = new StoreCashFinanceFlow();
|
$model = new StoreCashFinanceFlow();
|
||||||
$model->store_id = $order['store_id']??0;
|
$model->store_id = $order['store_id'] ?? 0;
|
||||||
$model->cash_price = $order->pay_price;
|
$model->cash_price = $order->pay_price;
|
||||||
$model->receivable = $order->pay_price;
|
$model->receivable = $order->pay_price;
|
||||||
$model->remark = '退款';
|
$model->remark = '退款';
|
||||||
@ -454,6 +453,24 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
$financeLogic = new StoreFinanceFlowLogic();
|
$financeLogic = new StoreFinanceFlowLogic();
|
||||||
$user_sing = new UserSign();
|
$user_sing = new UserSign();
|
||||||
|
//-----活动价结算更改
|
||||||
|
$financeLogic->order = $order;
|
||||||
|
$financeLogic->user = ['uid' => $order['uid']];
|
||||||
|
$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']);
|
||||||
|
if ($order['uid'] > 0) {
|
||||||
|
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||||
|
$sing = [
|
||||||
|
'uid' => $order['uid'],
|
||||||
|
'order_id' => $order['order_id'],
|
||||||
|
'title' => '购买商品获得兑换券',
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'number' => $user_number,
|
||||||
|
];
|
||||||
|
$user_sing->save($sing);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
$vipFen = 0;
|
$vipFen = 0;
|
||||||
if ($order['uid'] > 0) {
|
if ($order['uid'] > 0) {
|
||||||
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去
|
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去
|
||||||
@ -834,7 +851,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$updateData[] = [
|
$updateData[] = [
|
||||||
'id' => $StoreBranchProduct['id'],
|
'id' => $StoreBranchProduct['id'],
|
||||||
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
||||||
// 'sales' => ['inc', $v['cart_num']]
|
// 'sales' => ['inc', $v['cart_num']]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user