|
@@ -111,6 +111,7 @@ class Plantask extends Controller
|
|
|
}
|
|
|
|
|
|
//订单支付回调之后的任务,每分钟运行
|
|
|
+ //烧伤
|
|
|
public function auto_order_paid(){
|
|
|
|
|
|
$map = [
|
|
@@ -139,11 +140,27 @@ class Plantask extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//直推代理商获益
|
|
|
$intro_uid = Db::name('user')->where('id',$order['user_id'])->value('intro_uid');
|
|
|
if($intro_uid){
|
|
|
+
|
|
|
+ //直推的第一单金额,烧伤
|
|
|
+ $map = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'have_paid' => ['gt',0],
|
|
|
+ 'user_id' => $intro_uid,
|
|
|
+ ];
|
|
|
+ $first_order = Db::name('order')->where($map)->order('have_paid asc')->value('order_price');
|
|
|
+ $jishu = $order['order_price'];
|
|
|
+ if($first_order < $order['order_price']){
|
|
|
+ $jishu = $first_order;
|
|
|
+ }
|
|
|
+
|
|
|
+ //奖励
|
|
|
$bili = config('site.orderpaid_zhitui_bili') ?: 5;
|
|
|
- $score = bcdiv(bcmul($order['order_price'],$bili,2),100,2);
|
|
|
+ $score = bcdiv(bcmul($jishu,$bili,2),100,2);
|
|
|
if($score > 0){
|
|
|
$rs_wallet = $walletmodel->lockChangeAccountRemain($intro_uid,'score',$score,3,'直推代理奖励','unishop_order',$order['id'],$order['user_id']);
|
|
|
if($rs_wallet['status'] === false){
|
|
@@ -157,8 +174,22 @@ class Plantask extends Controller
|
|
|
//上上级
|
|
|
$top_uid = Db::name('user')->where('id',$intro_uid)->value('intro_uid');
|
|
|
if($top_uid){
|
|
|
+
|
|
|
+ //直推的第一单金额,烧伤
|
|
|
+ $map = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'have_paid' => ['gt',0],
|
|
|
+ 'user_id' => $top_uid,
|
|
|
+ ];
|
|
|
+ $first_order = Db::name('order')->where($map)->order('have_paid asc')->value('order_price');
|
|
|
+ $jishu = $order['order_price'];
|
|
|
+ if($first_order < $order['order_price']){
|
|
|
+ $jishu = $first_order;
|
|
|
+ }
|
|
|
+
|
|
|
+ //奖励
|
|
|
$bili = config('site.orderpaid_jiantui_bili') ?: 1;
|
|
|
- $score = bcdiv(bcmul($order['order_price'],$bili,2),100,2);
|
|
|
+ $score = bcdiv(bcmul($jishu,$bili,2),100,2);
|
|
|
if($score > 0){
|
|
|
$rs_wallet = $walletmodel->lockChangeAccountRemain($top_uid,'score',$score,4,'间推代理奖励','unishop_order',$order['id'],$order['user_id']);
|
|
|
if($rs_wallet['status'] === false){
|
|
@@ -255,7 +286,7 @@ class Plantask extends Controller
|
|
|
if($two_intro_uid > 0){
|
|
|
$two_intro_count = Db::name('user')->where('intro_uid',$two_intro_uid)->count();//上上级的直推
|
|
|
// $two_yeji = $this->jiesuan_yeji($two_intro_uid);//上上级的业绩
|
|
|
- if($two_intro_count >= $rule['intronum']){//也要五个,且业绩不高于15万(极差)。这里很矛盾
|
|
|
+ if($two_intro_count >= $rule['intronum']){//>=5个才能拿。上上级的业绩肯定比上级高,如果大于等于五个,就同级了,因为极差,反而拿不到,这里很矛盾。除非重新计算上上级的等级
|
|
|
$score_2 = $score;//目前是一样的,不再次计算了
|
|
|
if($score_2 > 0){
|
|
|
$rs_wallet = model('wallet')->lockChangeAccountRemain($two_intro_uid,'score',$score_2,7,$rule['level'].'级代理(间推)','unishop_order',$order['id'],$order['user_id']);
|