commit
f7c814d2ac
@ -80,7 +80,7 @@ class StoreController extends BaseApiController
|
||||
'uid'=>$find['id'],
|
||||
'staff_id'=>0,
|
||||
'order_id'=>getNewOrderId('CZ'),
|
||||
'price'=>0.01,
|
||||
'price'=>1000,
|
||||
'recharge_type'=>'INDUSTRYMEMBERS',
|
||||
];
|
||||
$order = UserRecharge::create($data);
|
||||
|
@ -65,22 +65,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
foreach ($list as $key => &$item) {
|
||||
|
||||
$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()
|
||||
->find();
|
||||
|
||||
if ($find) {
|
||||
if ($user && $user['user_ship'] == 1) {
|
||||
//更新 会员为1的时候原价减去会员价
|
||||
$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);
|
||||
}elseif ($user && $user['user_ship'] == 4) {
|
||||
//更新 为4商户的时候减去商户价格
|
||||
$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);
|
||||
}else{
|
||||
$this->activity_price =0;
|
||||
}
|
||||
// if ($user && $user['user_ship'] == 1) {
|
||||
// //更新 会员为1的时候原价减去会员价
|
||||
// $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);
|
||||
// }elseif ($user && $user['user_ship'] == 4) {
|
||||
// //更新 为4商户的时候减去商户价格
|
||||
// $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);
|
||||
// }else{
|
||||
// $this->activity_price =0;
|
||||
// }
|
||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||
$item['imgs'] = $find['image'];
|
||||
|
@ -106,7 +106,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
$this->searchWhere[] = ['status', '=', 1];
|
||||
$this->searchWhere[] = ['stock', '>', 0];
|
||||
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'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
|
@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic
|
||||
/** 计算价格 */
|
||||
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
@ -85,19 +85,19 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
$cart_select[$k]['vip'] = 0;
|
||||
if ($user && $user['user_ship'] == 1) {
|
||||
//更新 会员为1的时候原价减去会员价
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
$cart_select[$k]['vip'] =1;
|
||||
}
|
||||
if ($user && $user['user_ship'] == 4) {
|
||||
//更新 为4商户的时候减去商户价格
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
}
|
||||
// if ($user && $user['user_ship'] == 1) {
|
||||
// //更新 会员为1的时候原价减去会员价
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
// $cart_select[$k]['vip'] =1;
|
||||
// }
|
||||
// if ($user && $user['user_ship'] == 4) {
|
||||
// //更新 为4商户的时候减去商户价格
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
// }
|
||||
|
||||
//利润
|
||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
@ -446,6 +446,7 @@ class OrderLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
@ -145,7 +145,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
OrderLogic::lessWriteOff($params);
|
||||
}
|
||||
self::dealProductLog($order);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -391,6 +390,25 @@ class PayNotifyLogic extends BaseLogic
|
||||
{
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$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);
|
||||
User::where('id', $order['uid'])->inc('integral', $user_number)->update();
|
||||
}
|
||||
return false;
|
||||
$vipFen = 0;
|
||||
if ($order['uid'] > 0) {
|
||||
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去
|
||||
@ -404,8 +422,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
$vipFen = $oldUser['purchase_funds'];
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY){
|
||||
} elseif ($user['user_ship'] == 1 && $order['pay_type'] != PayEnum::CASH_PAY) {
|
||||
$vipFrozenAmount = self::dealFrozenPrice($order['id']);
|
||||
//为1的时候要去减活动价
|
||||
// $final_price = bcsub($order['pay_price'],$order['deduction_price'],2);
|
||||
@ -518,56 +535,58 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
if ($fees > 0) {
|
||||
//村长获得
|
||||
$sing = [];
|
||||
// $sing = [];
|
||||
|
||||
$sing[] = [
|
||||
'uid' => $village_uid,
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '村长订单获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $fees,
|
||||
'financial_pm' => 1,
|
||||
'user_ship' => 2,
|
||||
];
|
||||
$sing[] = [
|
||||
'uid' => $brigade_uid,
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '队长订单获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $fees,
|
||||
'financial_pm' => 1,
|
||||
'user_ship' => 3,
|
||||
];
|
||||
$sing[] = [
|
||||
'uid' => $village_uid,
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '订单扣除兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $fees,
|
||||
'financial_pm' => 0,
|
||||
'user_ship' => 2,
|
||||
];
|
||||
$sing[] = [
|
||||
'uid' => $brigade_uid,
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '订单扣除兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $fees,
|
||||
'financial_pm' => 0,
|
||||
'user_ship' => 3,
|
||||
];
|
||||
// if ($village_uid > 0) {
|
||||
// $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']);
|
||||
// $sing[] = [
|
||||
// 'uid' => $village_uid,
|
||||
// 'order_id' => $order['order_id'],
|
||||
// 'title' => '村长订单获得兑换券',
|
||||
// 'store_id' => $order['store_id'],
|
||||
// 'number' => $fees,
|
||||
// 'financial_pm' => 1,
|
||||
// 'user_ship' => 2,
|
||||
// ];
|
||||
// $sing[] = [
|
||||
// 'uid' => $brigade_uid,
|
||||
// 'order_id' => $order['order_id'],
|
||||
// 'title' => '队长订单获得兑换券',
|
||||
// 'store_id' => $order['store_id'],
|
||||
// 'number' => $fees,
|
||||
// 'financial_pm' => 1,
|
||||
// 'user_ship' => 3,
|
||||
// ];
|
||||
// $sing[] = [
|
||||
// 'uid' => $village_uid,
|
||||
// 'order_id' => $order['order_id'],
|
||||
// 'title' => '订单扣除兑换券',
|
||||
// 'store_id' => $order['store_id'],
|
||||
// 'number' => $fees,
|
||||
// 'financial_pm' => 0,
|
||||
// 'user_ship' => 2,
|
||||
// ];
|
||||
// $sing[] = [
|
||||
// 'uid' => $brigade_uid,
|
||||
// 'order_id' => $order['order_id'],
|
||||
// 'title' => '订单扣除兑换券',
|
||||
// 'store_id' => $order['store_id'],
|
||||
// 'number' => $fees,
|
||||
// 'financial_pm' => 0,
|
||||
// 'user_ship' => 3,
|
||||
// ];
|
||||
if ($village_uid > 0) {
|
||||
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) {
|
||||
// $financeLogic->other_arr['vip_uid'] = $brigade_uid;
|
||||
// }
|
||||
// $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||
// $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
$user_sing->saveAll($sing);
|
||||
if ($brigade_uid > 0) {
|
||||
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']);
|
||||
$financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
// $user_sing->saveAll($sing);
|
||||
//其他获得
|
||||
$financeLogic->other_arr['vip_uid'] = 0;
|
||||
$financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||
@ -691,7 +710,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
(new StoreProductLog())->saveAll($productLog);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -711,11 +729,9 @@ class PayNotifyLogic extends BaseLogic
|
||||
'swap' => $StoreBranchProduct['swap'] - $v['cart_num'],
|
||||
'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
(new StoreBranchProduct())->saveAll($updateData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -738,18 +754,15 @@ class PayNotifyLogic extends BaseLogic
|
||||
'product_id' => $v['product_id'],
|
||||
]
|
||||
)->withTrashed()->find();
|
||||
if ($StoreBranchProduct) {
|
||||
$updateData[] = [
|
||||
'id' => $StoreBranchProduct['id'],
|
||||
'stock' => $StoreBranchProduct['stock'] - $v['cart_num'],
|
||||
'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
(new StoreBranchProduct())->saveAll($updateData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user