commit
f042b73e76
@ -8,6 +8,7 @@ use app\common\enum\UserShipEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\CapitalFlowLogic;
|
||||
use app\common\logic\CommissionnLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\logic\StoreFinanceFlowLogic;
|
||||
use app\common\logic\UserSignLogic;
|
||||
@ -566,8 +567,7 @@ class OrderLogic extends BaseLogic
|
||||
'store_id' => $params['store_id'],
|
||||
'staff_id' => $params['staff_id'] ?? 0,
|
||||
], ['id' => $order['id']]);
|
||||
//修改商品统计记录标识
|
||||
(new StoreProductLog())->where('oid', $order['id'])->update(['store_id' => $params['store_id']]);
|
||||
|
||||
(new StoreOrderCartInfo())->update([
|
||||
'verify_code' => $params['verify_code'] . '-1',
|
||||
'writeoff_time' => time(),
|
||||
|
@ -123,9 +123,11 @@ class CommissionProductLogic extends BaseLogic
|
||||
if($order['pay_type']==18 && bcsub($user['total_recharge_amount'],$user['purchase_funds'],2)<$user['first_purchase_funds']){
|
||||
|
||||
}else{
|
||||
$vip_number = bcmul($total_price, 0.06, 2); //会员利润
|
||||
$data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06);
|
||||
$number1 = bcadd($number1, $vip_number, 2);
|
||||
if($rose>=9){
|
||||
$vip_number = bcmul($total_price, 0.06, 2); //会员利润
|
||||
$data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06);
|
||||
$number1 = bcadd($number1, $vip_number, 2);
|
||||
}
|
||||
}
|
||||
if ($rose >= 12 && $village_uid>0) {
|
||||
$village_number = bcmul($total_price, 0.01, 2); //村长利润
|
||||
|
@ -77,26 +77,35 @@ class CommissionnLogic extends BaseLogic
|
||||
$financeLogic->in($transaction_id, bcsub($order['pay_price'],$order['refund_price'],2), OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
|
||||
//缴纳齐全了就加商户没有就加到平台
|
||||
//查询保证金额度 和已交保证金
|
||||
$money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find();
|
||||
$deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度
|
||||
//保证金剩余额度
|
||||
$deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2);
|
||||
//门店利润
|
||||
$store_profit = StoreFinanceFlowProduct::where('oid', $order['id'])->where('type', $type)->sum('number');
|
||||
if ($deposit > 0) {
|
||||
//如果保证金大于利润就全部扣除利润到保证金中
|
||||
if ($deposit > $store_profit) {
|
||||
if ($store_profit > 0) {
|
||||
//添加到门店保证中
|
||||
$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'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
|
||||
}
|
||||
} else {
|
||||
//利润减去保证金
|
||||
$money = bcsub($store_profit, $deposit, 2);
|
||||
if ($deposit > 0) {
|
||||
$financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
}
|
||||
if ($money) {
|
||||
//添加到门店余额中
|
||||
$financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($store_profit > 0) {
|
||||
//添加到门店余额中
|
||||
$financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
|
||||
}
|
||||
}
|
||||
|
@ -146,13 +146,20 @@ class StoreFinanceFlowLogic extends BaseLogic
|
||||
*/
|
||||
public function updateStatusStore($order_id, $store_id, $money, $deposit)
|
||||
{
|
||||
StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1]);
|
||||
StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1]);
|
||||
$store = SystemStore::where('id', $store_id)->find();
|
||||
$capitalFlowDao = new CapitalFlowLogic($store, 'store');
|
||||
if ($money > 0) {
|
||||
$capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money,'','store_money');
|
||||
SystemStore::where('id', $store_id)->inc('store_money', $money)->update();
|
||||
//判断是否是押金
|
||||
if($store['paid_deposit']<$store['security_deposit']){
|
||||
StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1,'number'=>$money]);
|
||||
StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1,'number'=>0]);
|
||||
|
||||
$capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $money,'','paid_deposit');
|
||||
SystemStore::where('id', $store_id)->inc('paid_deposit', $money)->update();
|
||||
}else{
|
||||
$capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money,'','store_money');
|
||||
SystemStore::where('id', $store_id)->inc('store_money', $money)->update();
|
||||
}
|
||||
}
|
||||
if ($deposit > 0) {
|
||||
$capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $deposit,'','paid_deposit');
|
||||
|
@ -36,10 +36,22 @@ class StoreFinanceFlow extends BaseModel
|
||||
{
|
||||
return $this->hasOne(SystemStoreStaff::class, 'id', 'staff_id')->bind(['staff_name']);
|
||||
}
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(),$where),'store_finance_flow','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('store_finance_flow:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'store_finance_flow','更新前');
|
||||
channelLog($data->toArray(),'store_finance_flow','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('store_finance_flow:'.$e->getMessage());
|
||||
|
@ -18,13 +18,4 @@ class StoreFinanceFlowProduct extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'store_finance_flow_product';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'store_finance_flow_product','更新前');
|
||||
channelLog($data->toArray(),'store_finance_flow_product','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('store_finance_flow_product:'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -19,9 +19,23 @@ class SystemStore extends BaseModel
|
||||
protected $name = 'system_store';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public static function onBeforeWrite($data)
|
||||
{
|
||||
try {
|
||||
$where = $data->getWhere();
|
||||
if($data){
|
||||
$find = self::where($where)->field(array_keys($data->toArray()))->find();
|
||||
if($find){
|
||||
channelLog(array_merge($find->toArray(),$where),'system_store','更新前');
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
Log::error('system_store:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAfterWrite($data){
|
||||
try{
|
||||
channelLog($data->getOrigin(),'system_store','更新前');
|
||||
channelLog($data->toArray(),'system_store','更新后');
|
||||
}catch(Throwable $e){
|
||||
Log::error('system_store:'.$e->getMessage());
|
||||
|
Loading…
x
Reference in New Issue
Block a user