...
|
...
|
@@ -138,14 +138,120 @@ class PayController extends HomeBaseController |
|
|
$money_teacher = 0;
|
|
|
foreach ($data_indent_goods as $key => $val){
|
|
|
$money_teacher += $val['price']*$val['number']*$money_ratio['teacher_ratio'];
|
|
|
$data_money_income_teacher
|
|
|
$data_money_income_teacher['create_time'] = time();
|
|
|
$data_money_income_teacher['money'] = $money_teacher;
|
|
|
$data_money_income_teacher['type'] = 1;
|
|
|
$data_money_income_teacher['book_name'] = $val['book_name'];
|
|
|
$data_money_income_teacher['book_thumbnail'] = $val['thumbnail'];
|
|
|
$data_money_income_teacher['book_num'] = $val['number'];
|
|
|
$data_money_income_teacher['uid'] = $teacher['uid'];
|
|
|
Db::name('money_income') -> insert($data_money_income_teacher);
|
|
|
}
|
|
|
Db::name('my_user') -> where('uid',$teacher['uid']) -> setInc('balance',$money_salesman);
|
|
|
}
|
|
|
//如果是平台商品 老师购买
|
|
|
if($data_user['status'] == 3){
|
|
|
|
|
|
//查询平台商品老师和业务员所占的佣金比例
|
|
|
$money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
|
|
|
//查询这条订单下的所有商品
|
|
|
$data_indent_goods = Db::name('indent_goods') -> where('indent_id',$order['id']) -> select();
|
|
|
$money_salesman = 0;
|
|
|
//查询老师的uid
|
|
|
/* $teacher = Db::name('my_user') -> where('id',$data_user['pid']) -> find();*/
|
|
|
//查询业务员的uid
|
|
|
$salesman = Db::name('my_user') -> where('id',$data_user['pid']) -> find();
|
|
|
foreach ($data_indent_goods as $key => $val){
|
|
|
$money_salesman += $val['price']*$val['number']*$money_ratio['salesman_ratio'];
|
|
|
$data_money_income_salesman['create_time'] = time();
|
|
|
$data_money_income_salesman['money'] = $money_salesman;
|
|
|
$data_money_income_salesman['type'] = 1;
|
|
|
$data_money_income_salesman['book_name'] = $val['book_name'];
|
|
|
$data_money_income_salesman['book_thumbnail'] = $val['thumbnail'];
|
|
|
$data_money_income_salesman['book_num'] = $val['number'];
|
|
|
$data_money_income_salesman['uid'] = $salesman['uid'];
|
|
|
Db::name('money_income') -> insert($data_money_income_salesman);
|
|
|
}
|
|
|
Db::name('my_user') -> where('uid',$salesman['uid']) -> setInc('balance',$money_salesman);
|
|
|
$money_teacher = 0;
|
|
|
foreach ($data_indent_goods as $key => $val){
|
|
|
$money_teacher += $val['price']*$val['number']*$money_ratio['teacher_ratio'];
|
|
|
$data_money_income_teacher['create_time'] = time();
|
|
|
$data_money_income_teacher['money'] = $money_teacher;
|
|
|
$data_money_income_teacher['type'] = 1;
|
|
|
$data_money_income_teacher['book_name'] = $val['book_name'];
|
|
|
$data_money_income_teacher['book_thumbnail'] = $val['thumbnail'];
|
|
|
$data_money_income_teacher['book_num'] = $val['number'];
|
|
|
$data_money_income_teacher['uid'] = $data_user['uid'];
|
|
|
Db::name('money_income') -> insert($data_money_income_teacher);
|
|
|
}
|
|
|
Db::name('my_user') -> where('uid',$data_user['uid']) -> setInc('balance',$money_salesman);
|
|
|
}
|
|
|
}else if($order['indent_type'] == 2){
|
|
|
//如果是业务员订单
|
|
|
//查询平台商品老师和业务员所占的佣金比例
|
|
|
$money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
|
|
|
//查询这条订单下的所有商品
|
|
|
$data_indent_goods = Db::name('indent_goods') -> where('indent_id',$order['id']) -> select();
|
|
|
//业务员商品学生购买
|
|
|
if($data_user['status'] == 4){
|
|
|
$teacher = Db::name('my_user') -> where('id',$data_user['pid']) -> find();
|
|
|
$money = 0;
|
|
|
foreach ($data_indent_goods as $key => $val){
|
|
|
$money += $val['commission']*$val['number'];
|
|
|
$money_income_teacher['create_time'] = time();
|
|
|
$money_income_teacher['money'] = $money;
|
|
|
$money_income_teacher['type'] = 2;
|
|
|
$money_income_teacher['book_name'] = $val['book_name'];
|
|
|
$money_income_teacher['book_thumbnail'] = $val['thumbnail'];
|
|
|
$money_income_teacher['book_num'] = $val['number'];
|
|
|
$money_income_teacher['uid'] = $teacher['uid'];
|
|
|
Db::name('money_income') -> insert($money_income_teacher);
|
|
|
}
|
|
|
//增加老师余额
|
|
|
Db::name('my_user') -> where('uid',$teacher['uid']) -> setInc('balance',$money);
|
|
|
//计算业务员这条订单的收入
|
|
|
$balance_salesman = $order['money'] - $order['money']*$money_ratio['platform_ratio'] - $money;
|
|
|
//增加业务员的余额
|
|
|
Db::name('my_user') -> where('uid',$order['salesman_uid']) -> setInc('balance',$balance_salesman);
|
|
|
//添加业务员的收入记录
|
|
|
$money_income_salesman_indent['create_time'] = time();
|
|
|
$money_income_salesman_indent['uid'] = $order['salesman_uid'];
|
|
|
$money_income_salesman_indent['money'] = $balance_salesman;
|
|
|
$money_income_salesman_indent['type'] = 2;
|
|
|
$money_income_salesman_indent['indent_id'] = $order['id'];
|
|
|
Db::name('money_income') -> insert($money_income_salesman_indent);
|
|
|
|
|
|
}
|
|
|
//业务员商品老师购买
|
|
|
if ($data_user['status'] == 3){
|
|
|
$teacher = $data_user['uid'];
|
|
|
$money = 0;
|
|
|
foreach ($data_indent_goods as $key => $val){
|
|
|
$money += $val['commission']*$val['number'];
|
|
|
$money_income_teacher['create_time'] = time();
|
|
|
$money_income_teacher['money'] = $money;
|
|
|
$money_income_teacher['type'] = 2;
|
|
|
$money_income_teacher['book_name'] = $val['book_name'];
|
|
|
$money_income_teacher['book_thumbnail'] = $val['thumbnail'];
|
|
|
$money_income_teacher['book_num'] = $val['number'];
|
|
|
$money_income_teacher['uid'] = $teacher;
|
|
|
Db::name('money_income') -> insert($money_income_teacher);
|
|
|
}
|
|
|
//增加老师余额
|
|
|
Db::name('my_user') -> where('uid',$teacher) -> setInc('balance',$money);
|
|
|
//计算业务员这条订单的收入
|
|
|
$balance_salesman = $order['money'] - $order['money']*$money_ratio['platform_ratio'] - $money;
|
|
|
//增加业务员的余额
|
|
|
Db::name('my_user') -> where('uid',$order['salesman_uid']) -> setInc('balance',$balance_salesman);
|
|
|
//添加业务员的收入记录
|
|
|
$money_income_salesman_indent['create_time'] = time();
|
|
|
$money_income_salesman_indent['uid'] = $order['salesman_uid'];
|
|
|
$money_income_salesman_indent['money'] = $balance_salesman;
|
|
|
$money_income_salesman_indent['type'] = 2;
|
|
|
$money_income_salesman_indent['indent_id'] = $order['id'];
|
|
|
Db::name('money_income') -> insert($money_income_salesman_indent);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -282,4 +388,12 @@ class PayController extends HomeBaseController |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|