作者 anyv
1 个管道 的构建 通过 耗费 3 秒

微信支付

... ... @@ -20,7 +20,7 @@ class OrderpageController extends WeChatBaseController{
$indet_id = $this -> request -> param();
$uid = cmf_get_current_user_id();
$address = Db::name('address') -> where("uid=".$uid." and default_address=1") -> find();
$address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
if(empty($address)){
$this -> assign('address',4);
}else{
... ... @@ -29,7 +29,7 @@ class OrderpageController extends WeChatBaseController{
$indet_data = Db::name('indent') -> where("id",$indet_id['indet_id']) -> find();
if($indet_data['state'] == 4){
$indet_data_update['id'] = $indet_id['indet_id'];
$indet_data_update['indent_address'] = $address['detailed'];
$indet_data_update['indent_address'] = $address[''];
$indet_data_update['name'] = $address['name'];
$indet_data_update['phone'] = $address['phone'];
Db::name('indent') -> update($indet_data_update);
... ... @@ -121,11 +121,11 @@ class OrderpageController extends WeChatBaseController{
$money['money'] = $money['money']+$courier['courier'];
$this -> assign('money',$money['money']);
$address = Db::name('address') -> where("uid=".$uid." and default_address=1") -> find();
$address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
if(empty($address)){
$this -> assign('address',4);
}else{
$address_arr = explode(',',$address['detailed']);
$address_arr = explode(',',$address['']);
$address['detailed'] = $address_arr[0].$address_arr[1];
$indet_data = Db::name('indent') -> where("id",$indent_id['indet_id']) -> find();
if($indet_data['state'] == 4){
... ...
... ... @@ -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
... ...
-----BEGIN CERTIFICATE-----
MIIEZDCCA82gAwIBAgIEAhEzATANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMC
Q04xEjAQBgNVBAgTCUd1YW5nZG9uZzERMA8GA1UEBxMIU2hlbnpoZW4xEDAOBgNV
BAoTB1RlbmNlbnQxDDAKBgNVBAsTA1dYRzETMBEGA1UEAxMKTW1wYXltY2hDQTEf
MB0GCSqGSIb3DQEJARYQbW1wYXltY2hAdGVuY2VudDAeFw0xODA3MDMxMjMwNDVa
Fw0yODA2MzAxMjMwNDVaMIGTMQswCQYDVQQGEwJDTjESMBAGA1UECBMJR3Vhbmdk
b25nMREwDwYDVQQHEwhTaGVuemhlbjEQMA4GA1UEChMHVGVuY2VudDEOMAwGA1UE
CxMFTU1QYXkxJzAlBgNVBAMUHuWkqea0peaWueebruenkeaKgOaciemZkOWFrOWP
uDESMBAGA1UEBBMJMTAwODkxMjUxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAsLJARXruD6jC8cchcOFHqsX9FPCypVafg4pVrVMDwlXNzqWqlizaRaGY
HPsDhgJvU3YX+xWo43aocsPkXw+Yl24SnwAwAUz1gL3RA1yrT1S2uFVMZ3uLVXTk
qnxa2iWtrjf46Qx6wEX++Fw99HCQldu/B3zaOjK5XizJNWc/dr8ZSbsEzWN5NNje
Fv68fYnYqWiSTezKbzvRAMh5Ho3hY60wsc0gPXHCUOcucAjM21Z9a1yBqu0XWhL4
UVCXI10sBICEyoSXwx0tnzmy8cO76wA0DlYC5PCmCGSKRBXFCpgbCPg+QRRWu4a8
p4qqENmb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