diff --git a/app/admin/lists/user/UserLists.php b/app/admin/lists/user/UserLists.php index a419056c..462f0331 100644 --- a/app/admin/lists/user/UserLists.php +++ b/app/admin/lists/user/UserLists.php @@ -150,7 +150,8 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS 'store_name' => '门店', 'total_recharge_amount' => '累计消费', 'purchase_funds' => '采购款', - 'format_address'=>'地址' + 'format_address'=>'地址', + 'vip_time'=>'开通时间' ]; } } \ No newline at end of file diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index 73e831cd..31403537 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -64,14 +64,21 @@ class CommissionLogic extends BaseLogic } /** - * 走线下分润 + * 零售分润 */ - public static function setStore($order, $transaction_id = 0) + public static function setStore($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) { + if($order['spread_uid']<=0){ + $uid=$order['uid']; + }else{ + $uid=$order['spread_uid']; + } + self::user($order, 0, $transaction_id, $uid, 12); //会员、厨师 + self::user($order, 5, $transaction_id, $uid, 12); //会员、厨师 + self::user($order, 3, $transaction_id, $village_uid, 14); //村长 + self::user($order, 4, $transaction_id, $brigade_uid, 15); //队长 self::platform($order, 2, $transaction_id); //平台 self::store($order, 1, $transaction_id, 0); //门店 - // $attrition = self::attrition($order, 0.01, $transaction_id, 16); //损耗 - // $moeny = bcadd($platform, $store, 2); self::suppliter($order, $transaction_id); } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 79c15e22..789d8162 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -95,7 +95,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']); self::dealProductLog($order); - + self::afterPay($order); if ($order['reservation'] == 1 && in_array($order['shipping_type'], [1, 2])) { $checkArr = [ @@ -104,7 +104,7 @@ class PayNotifyLogic extends BaseLogic ]; self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } - if ($order && $order['store_id'] && $order['reservation'] !=1 && $order['source']==1) { + if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $order['store_id'], @@ -112,7 +112,7 @@ class PayNotifyLogic extends BaseLogic ]; OrderLogic::writeOff($params); } - if(in_array($order['shipping_type'],[1,2])){ + if (in_array($order['shipping_type'], [1, 2])) { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } return true; @@ -209,7 +209,7 @@ class PayNotifyLogic extends BaseLogic // } // self::addUserSing($order); self::afterPay($order); - if ($order && $order['store_id'] && $order['reservation'] !=1 && $order['source']==1) { + if ($order && $order['store_id'] && $order['reservation'] != 1 && $order['source'] == 1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $order['store_id'], @@ -227,7 +227,7 @@ class PayNotifyLogic extends BaseLogic } // Redis::send('push-platform-print', ['id' => $order['id']], 60); - if(in_array($order['shipping_type'],[1,2])){ + if (in_array($order['shipping_type'], [1, 2])) { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } } @@ -434,7 +434,7 @@ class PayNotifyLogic extends BaseLogic $uid = $order->uid; $user = User::where('id', $uid)->findOrEmpty(); //check store_id - if($user->store_id==0){ + if ($user->store_id == 0) { $user->store_id = $order['store_id']; } @@ -451,7 +451,7 @@ class PayNotifyLogic extends BaseLogic //更新等级 $user->user_ship = $order['user_ship']; - if($user['vip_time']==null){ + if ($user['vip_time'] == null) { $user->vip_time = time(); } $user->purchase_funds = bcadd($user->purchase_funds, $price, 2); @@ -483,7 +483,7 @@ class PayNotifyLogic extends BaseLogic $order->paid = 1; $order->pay_time = time(); $order->status = 2; - if ($order['reservation'] ==1) { + if ($order['reservation'] == 1) { $order->status = 1; } if (!$order->save()) { @@ -497,7 +497,7 @@ class PayNotifyLogic extends BaseLogic $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); - if ($order && $order['store_id'] && $order['reservation'] !=1) { + if ($order && $order['store_id'] && $order['reservation'] != 1) { $params = [ 'verify_code' => $order['verify_code'], 'store_id' => $order['store_id'], @@ -576,10 +576,9 @@ class PayNotifyLogic extends BaseLogic //用户下单该用户等级为1得时候才处理冻结金额 $user = User::where('id', $order['uid'])->find(); $user_ship = $user['user_ship']; - } //积分写入 - if(isset($user) && $user['user_ship']==0){ + if (isset($user) && $user['user_ship'] == 0) { UserSignLogic::OrderWrite($order); } if ($off_activity == 1) { @@ -597,43 +596,28 @@ class PayNotifyLogic extends BaseLogic // if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY && $off_activity !=1) { // $order['dealVipAmount']= self::dealVipAmount($order, $order['pay_type']); // } - if ($order['spread_uid'] > 0 || $user_ship > 0) { - if ($order['spread_uid'] > 0 && $user_ship == 0) { - $user_ship = User::where('id', $order['spread_uid'])->value('user_ship'); - if ($user_ship == 2) { - $village_uid = $order['spread_uid']; - $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); - if ($address) { - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0; - } + if ($order['spread_uid'] > 0 && $user_ship == 0) { + $user_ship = User::where('id', $order['spread_uid'])->value('user_ship'); + if ($user_ship == 2) { + $village_uid = $order['spread_uid']; + $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); + if ($address) { + $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); + if ($arr2) { + $brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0; } - } elseif ($user_ship == 3) { - $brigade_uid = $order['spread_uid']; - $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); - if ($address) { - $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); - if ($arr1) { - $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0; - } - } - }else{ - $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); - if ($address) { - $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); - if ($arr1) { - $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0; - } - $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); - if ($arr2) { - $brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0; - } + } + } elseif ($user_ship == 3) { + $brigade_uid = $order['spread_uid']; + $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); + if ($address) { + $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); + if ($arr1) { + $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0; } } } else { - //查询用户对应的村长和队长 - $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); + $address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find(); if ($address) { $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); if ($arr1) { @@ -645,32 +629,43 @@ class PayNotifyLogic extends BaseLogic } } } - $info = StoreOrderCartInfo::where('oid',$order['id'])->field('store_id,product_id,cart_num')->select(); - $comm=new CommissionProductLogic(); - foreach ($info as $v) { - $comm->calculate_product_flow($v,$order['id'],$order['store_id'],$v['product_id'],$village_uid,$brigade_uid,$order['uid'],$order['spread_uid']); + } else { + //查询用户对应的村长和队长 + $address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find(); + if ($address) { + $arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid'); + if ($arr1) { + $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0; + } + $arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid'); + if ($arr2) { + $brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0; + } } - switch ($user_ship) { - case 1: // 厨师 + } + $info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select(); + $comm = new CommissionProductLogic(); + foreach ($info as $v) { + $comm->calculate_product_flow($v, $order['id'], $order['store_id'], $v['product_id'], $village_uid, $brigade_uid, $order['uid'], $order['spread_uid']); + } + switch ($user_ship) { + case 1: // 厨师 //case 4: // 商户 //case 5: // 种养殖 // case 6: // 酒店 // case 7: // 食堂 // case 8: // 一条龙 - CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id); - break; - case 2: // 村长 - CommissionLogic::setVillage($order, $village_uid, $brigade_uid, $transaction_id); - break; - case 3: // 队长 - CommissionLogic::setBrigade($order, $village_uid, $brigade_uid, $transaction_id); - break; - default: - CommissionLogic::setStore($order, $transaction_id); - break; - } - } else { - CommissionLogic::setStore($order, $transaction_id); + CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id); + break; + case 2: // 村长 + CommissionLogic::setVillage($order, $village_uid, $brigade_uid, $transaction_id); + break; + case 3: // 队长 + CommissionLogic::setBrigade($order, $village_uid, $brigade_uid, $transaction_id); + break; + default: + CommissionLogic::setStore($order,$village_uid, $brigade_uid, $transaction_id); + break; } }