...
|
...
|
@@ -101,6 +101,55 @@ class PayController extends HomeBaseController |
|
|
// $update['status']=9;
|
|
|
// }
|
|
|
// Db::name('order')->where('order_sn',$out_trade_no)->update($update);
|
|
|
$out_trade_no=$notify->out_trade_no;
|
|
|
//查询订单信息
|
|
|
$order = Db::name('indent')->where('order_number',$out_trade_no)->find();
|
|
|
if($successful){
|
|
|
$update['state'] = 2;
|
|
|
//更新订单状态为待发货
|
|
|
Db::name('indent')->where('order_number',$out_trade_no)->update($update);
|
|
|
$uid = cmf_get_current_user_id();
|
|
|
//查询当前用户身份
|
|
|
$data_user = Db::name('my_user')->where('uid',$uid)->find();
|
|
|
if($order['indent_type'] == 1){
|
|
|
//如果是平台商品 学生购买
|
|
|
if($data_user['status'] == 4){
|
|
|
//查询平台商品老师和业务员所占的佣金比例
|
|
|
$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',$teacher['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
|
|
|
}
|
|
|
}
|
|
|
//如果是平台商品 老师购买
|
|
|
if($data_user['status'] == 3){
|
|
|
|
|
|
}
|
|
|
}else if($order['indent_type'] == 2){
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true; // 返回处理完成
|
|
|
});
|
...
|
...
|
|