diff --git a/app/api/controller/Gh.php b/app/api/controller/Gh.php index ea5c8ec6..d292958e 100644 --- a/app/api/controller/Gh.php +++ b/app/api/controller/Gh.php @@ -3,6 +3,8 @@ namespace app\api\controller; use app\common\basics\Api; +use app\common\logic\Earnings; +use app\common\logic\Billions; use app\common\server\JsonServer; use app\common\model\user\User; use app\common\model\user\UserAuth; @@ -132,6 +134,7 @@ class Gh extends Api $data['shop_appid'] = $this->shop_appid; $data['icbc_appid'] = $this->APP_ID; $data['user_id'] = $user_id; + $data['classify_amt'] = $money*100; $data['open_id'] = $user_msg['openid']; $data['dtime'] = date("Y-m-d H:i:s"); $rest = Db::name("abutment_log")->insertGetId($data); @@ -140,14 +143,17 @@ class Gh extends Api // print_r("
");
// var_dump($result);
$r = json_decode($result['wx_data_package'],true);
+
$out_trade_no = createSn('user', 'id');
- $data['order_sn'] = $out_trade_no;
- $data['user_id'] = $user_id;
- $data['order_amount'] = $money;
- $data['partner_id'] = $partner_id;
- $data['store_type_id'] = $store_type_id;
- $data['pay_time'] = date("Y-m-d H:i:s");
- Db::name("distribution_pay")->save($data);
+ $da['order_sn'] = $out_trade_no;
+ $da['user_id'] = $user_id;
+ $da['order_amount'] = $money;
+ $da['partner_id'] = $partner_id;
+ $da['store_type_id'] = $store_type_id;
+ $da['pay_time'] = date("Y-m-d H:i:s");
+ Db::name("distribution_pay")->save($da);
+
+
$r['nonceStr'] = $r['noncestr'];
$r['timeStamp'] = $r['timestamp'];
$r['paySign'] = $r['sign'];
@@ -160,8 +166,89 @@ class Gh extends Api
return substr(md5("donglonghui".time().mt_rand(1,1000000)),8,13);
}
// 查询回调记录
- public function checkReturn($alog_id){
- $abutment =
+ public function checkReturn($alog_id,$type=""){
+ $abutment = Db::name("abutment_log")
+ ->where("alog_id",$alog_id)
+ ->where("state",0)
+ ->find();
+ if($abutment == null){
+ return JsonServer::error('支付失败');
+ }
+ $distributionPay = Db::name("distribution_pay")
+ ->where("alog_id",$alog_id)
+ ->find();
+ if($distributionPay == null){
+ return JsonServer::error('支付失败');
+ }
+ $checkPay = $this->payReturnCheck($abutment['out_trade_no']);
+ if($checkPay['return_msg'] === "SUCCESS"){
+ Db::name("abutment_log")
+ ->where("seq_no",$abutment['seq_no'])
+ ->update(['state'=>1]);
+ Db::name("distribution_pay")
+ ->where("alog_id",$alog_id)
+ ->update(['pay_status'=>1]);
+ // 解冻查询
+ $r = json_decode($checkPay['order_submit_act_output'],true);
+ $jd = $this->jiedong($r);
+ if(!$jd){
+ return JsonServer::error('解冻失败');
+ }
+ }else{
+ return JsonServer::error('支付失败');
+ }
+ $user = Db::name("user")
+ ->where('id',$abutment['user_id'])
+ ->where('disable',0)
+ ->where('del',0)
+ ->find();
+ if($user == null){
+ return JsonServer::error('用户不存在或被禁用');
+ }
+ if($user['first_leader'] > 0){
+ //获取配置比例
+ $config = Db::name("config")->where("type","subsidy")->select()->toArray();
+ $arr = array();
+ $earnings_pecent = $earnings_electrodeless_pecent = 0;
+ foreach($config as $key=>$value){
+ if($value['name'] == "distribution_user"){
+ $earnings_pecent = $value['value'];
+ }
+ if($value['name'] == "distribution_electrodeless"){
+ $earnings_electrodeless_pecent = $value['value'];
+ }
+ }
+ $earns = new Earnings();
+ // 推广会员用户佣金
+ $earnings = round($earnings_pecent*$distributionPay['order_amount']/100,2);
+ $distribution_user_earnings = AccountLog::distribution_user_earnings;
+ $earnings_result = $earns->userEarnings($earnings,$user['first_leader'],$distribution_user_earnings);
+ if(!$earnings_result){
+ return JsonServer::error('支付失败');
+ }
+ // 推广会员无极佣金
+ if($user['divide_state']==1){
+ if($user['divide_role_user_id'] > 0){
+ $electrodeless = round($earnings_electrodeless_pecent*$distributionPay['order_amount']/100,2);
+ $distribution_user_electrodeless_earnings = AccountLog::distribution_user_electrodeless_earnings;
+ $earnings_result = $earns->userElectrodelessEarnings($electrodeless,$user['divide_role_user_id'],$distribution_user_electrodeless_earnings);
+ if(!$earnings_result){
+ return JsonServer::error('支付失败');
+ }
+ }
+ }
+ }
+ // 参与消费返补
+ $billions = new Billions();
+ $order['order_amount'] = round($distributionPay['order_amount'],2);
+ $order['id'] = $alog_id;
+ $order['type'] = 5;
+ $type = "distribution";
+ $billions_result = $billions->billions($order,$abutment['user_id'],$type);
+ if(!$billions_result){
+ return JsonServer::error('支付失败');
+ }
+
}
// 用户账户
public function userAccount($user_id,$out,$money,$merchant,$user_msg){
@@ -290,4 +377,70 @@ class Gh extends Api
"classify_amt"=>strval($money*$user_billions)
);
}
+ // 查询是否支付成功
+ public function payReturnCheck($out_trade_no){
+ $user_id = 1;
+ $msg_id = $this->getMsgId();
+ // $out = "dlh".time().$user_id;
+ $request = [
+ 'serviceUrl' => 'https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/orderqry/V2',
+ 'method' => 'POST',
+ 'isNeedEncrypt'=>false,
+ 'biz_content' => array(
+ "mer_id"=>"120448160200",
+ "deal_flag"=>'0',
+ "out_trade_no"=>$out_trade_no,
+ // "order_id"=>"120448160200000562407290003182",
+ "mer_prtcl_no"=>"1204481602000201",
+ "icbc_appid"=>$this->APP_ID
+ ),
+ 'extraParams'=>[]
+ ];
+// print_r("");
+// var_dump($request);
+ $res = $this->apiClient->execute($request,$msg_id,"");
+// var_dump($res);
+ $result = json_decode($res,true);
+ // print_r("");
+// var_dump($result);
+ if(isset($result['order_submit_act_output'])){
+ return $result;
+ }else{
+ $arr['return_msg'] = "ERROR";
+ return $arr;
+ }
+
+ }
+
+ //解冻
+ public function jiedong($r){
+ foreach($r as $key=>$value){
+ $msg_id = $this->getMsgId();
+ $request = [
+ 'serviceUrl' => 'https://gw.open.icbc.com.cn/api/mybank/mer/merin/thaw/V1',
+ 'method' => 'POST',
+ 'isNeedEncrypt'=>false,
+ 'biz_content' => array(
+ "icbcOrderSubNo"=>$value['sub_order_seq'],
+ "icbcOrderNo"=>$value['order_id'],
+ "outAgreeNo"=>$value['sub_mer_id']."0201"
+ // "outAgreeNo"=>"dlh17304530429791"
+ // "outAgreeNo"=>"1204481602020201"
+ ),
+ 'extraParams'=>[]
+ ];
+// print_r("");
+// var_dump($request);
+ $res = $this->apiClient->execute($request,$msg_id,"");
+// var_dump($res);
+ // $result = json_decode($res,true);
+ $result = json_decode($res,true);
+ // print_r("");
+// var_dump($result);
+ if($result['returnCode']!="success"){
+ return false;
+ }
+ }
+ return true;
+ }
}
\ No newline at end of file
diff --git a/app/common/logic/Billions.php b/app/common/logic/Billions.php
new file mode 100644
index 00000000..662f45a9
--- /dev/null
+++ b/app/common/logic/Billions.php
@@ -0,0 +1,348 @@
+where(['id' => $user_id])->find();
+ $first_leader_user = Db::name("user")->where("id", $user['first_leader'])->find();
+ $is_d = Distribution::where('user_id', $user['first_leader'] )->where('is_distribution', 1 )->find();
+ $data['order_price'] = $order['order_amount']; // 改为充值金额
+ $data['user_id'] = $user_id;
+ $data['goods_id'] = 0; // 充值接口不需要该参数
+ $data['shop_id'] = 0; // 充值接口不需要该参数
+ $data['goods_num'] = 1; // 充值接口设置为1
+ $data['order_id'] = $order['id'];
+ $data['dtime'] = date("Y-m-d H:i:s");
+ $data['type'] = $order['type']; // 类型是充值
+ $data['subsidy_price'] = round($order['order_amount'] * $user_subsidy / 100,8);
+ $res = Db::name("user_billions")->insertGetId($data);
+ $subsidy = $order['order_amount'] * $all_user_subsidy / 100;
+ if($is_d != null){
+ $ufl = round($subsidy*$user_first_leader/100,8);
+ $subsidy_ufl = round($subsidy - $ufl,8);
+ $first_billions_msg = Db::name("user_billions")->where("user_id",$user['first_leader'])->where("state",0)->select()->toArray();
+ if(count($first_billions_msg) > 0){
+ foreach($first_billions_msg as $k=>$v){
+ if($ufl > 0){
+ if($v['order_price'] <= $ufl+$v['subsidy_price']){
+ // 查询用户总余额账户
+ $first_user_all_account = Db::name("subsidy_withdrawal")->where("user_id",$v['user_id'])->find();
+ if($first_user_all_account != null){
+ // 判断账户是否可用
+ if($first_user_all_account['state'] == 0 || $first_user_all_account['state'] == 2){
+ return -2;
+ }
+ // 更新主表
+ $first_update_subsidy_withdrawal = Db::name("subsidy_withdrawal")->where("user_id",$v['user_id'])->inc("total_amount",$v['order_price'])->update();
+ if(!$first_update_subsidy_withdrawal){
+ return -4;
+ }
+ $dat['subsidy_withdrawal_id'] = $first_user_all_account['id'];
+ $dat['user_id'] = $v['user_id'];
+ $dat['billions_id'] = $v['billions_id'];
+ $dat['type'] = 1;
+ $dat['money'] = $v['order_price'];
+ $dat['create_time'] = date("Y-m-d H:i:s");
+ // 插入提现记录
+ $first_save_record = Db::name("subsidy_withdrawal_record")->save($dat);
+ if ($first_save_record) {
+ $send = array(
+ 'user_id' => $v['user_id'],
+ 'money' => $v['order_price']
+ );
+ sendBillionsSubsidySMS($send);
+ }
+
+ if(!$first_save_record){
+ return -5;
+ }
+ }else{
+ $d['user_id'] = $v['user_id'];
+ $d['total_amount'] = $v['order_price'];
+ $first_update_subsidy_withdrawal = Db::name("subsidy_withdrawal")->insertGetId($d);
+ if(!$first_update_subsidy_withdrawal){
+ return -4;
+ }
+ $dat['subsidy_withdrawal_id'] = $first_update_subsidy_withdrawal;
+ $dat['user_id'] = $v['user_id'];
+ $dat['billions_id'] = $v['billions_id'];
+ $dat['type'] = 1;
+ $dat['money'] = $v['order_price'];
+ $dat['create_time'] = date("Y-m-d H:i:s");
+ // 插入提现记录
+ $first_save_record = Db::name("subsidy_withdrawal_record")->save($dat);
+ if ($first_save_record) {
+ $send = array(
+ 'user_id' => $v['user_id'],
+ 'money' => $v['order_price']
+ );
+ sendBillionsSubsidySMS($send);
+ }
+
+ if(!$first_save_record){
+ return -5;
+ }
+ }
+ // 更新排队状态
+ $first_update_user_billions = Db::name("user_billions")->where("billions_id",$v['billions_id'])->update(['subsidy_price'=>$v['order_price'],"state"=>2]);
+ if(!$first_update_user_billions){
+ return -3;
+ }
+ // 剩余金额
+ $ufl = round($ufl+$v['subsidy_price']-$v['order_price'],8);
+ }else{
+ $subsidy_price_sum = round($v['subsidy_price']+$ufl,8);
+ Db::name("user_billions")->where("billions_id",$v['billions_id'])->update(['subsidy_price'=>$subsidy_price_sum]);
+ // Db::name("user_billions")->where("billions_id",$v['billions_id'])->inc("subsidy_price",$ufl)->update();
+ $ufl = 0;
+ }
+ }
+
+ }
+ $subsidy = round($subsidy_ufl + $ufl,8);
+ }
+ self::atcl($order,$store_subsidy,$type,$user,$first_leader,$other_leader);
+ }
+ $billions_count = Db::name("user_billions")->where("state",0)->count();
+ $data_surplus['billions_id'] = $res;
+ $data_surplus['subsidy_all_price'] = $subsidy;
+ $data_surplus['user_start_num'] = $user_start_num;
+ $data_surplus['user_start_subsidy'] = $user_start_subsidy;
+ $data_surplus['user_start_price'] = round($subsidy*$user_start_subsidy/100,8);
+ $data_surplus['user_start_avg_price'] = round($data_surplus['user_start_price']/$user_start_num,8);
+ $data_surplus['residue_price'] = $subsidy-$data_surplus['user_start_price'];
+ if($billions_count>$user_start_num){
+ $data_surplus['user_price'] = round(($subsidy-$data_surplus['user_start_price'])/($billions_count-$user_start_num),8);
+ }
+ $data_surplus['dtime'] = date("Y-m-d H:i:s");
+ $rest = Db::name("user_billions_surplus")->save($data_surplus);
+ return $rest;
+ }
+ public static function atcl($order,$store_subsidy,$type,$user,$first_leader,$other_leader){
+ if(isset($order['lstore_id'])){
+ $local_msg = Db::name("local_store")
+ ->where("lstore_id",$order['lstore_id'])
+ ->where("is_delete",0)
+ ->where("store_state",1)
+ ->find();
+ if($local_msg != null){
+ $local_first_leader = Db::name("user")
+ ->where("id",$local_msg['user_id'])
+ ->where("del",0)
+ ->where("disable",0)
+ ->find();
+ if($local_first_leader != null){
+ if($local_first_leader['first_leader']!=0){
+ $is_local_d = Distribution::where('user_id', $local_first_leader['first_leader'] )->where('is_distribution', 1 )->find();
+ if($is_local_d!=null){
+ $local_earnings = round($order['order_amount']*$store_subsidy/100,2);
+ User::where('id', $local_first_leader['first_leader'])
+ ->inc('earnings', $local_earnings)->update();
+ $local_earnings_buy = AccountLog::where('user_id', $local_first_leader['first_leader'])->order("create_time desc")->limit(1)->value('left_amount');
+ $sn = createSn('account_log', 'log_sn', '', 4);
+ AccountLog::create([
+ 'log_sn' => $sn,
+ 'user_id' => $local_first_leader['first_leader'],
+ 'source_type' => AccountLog::local_inc_earnings, //todo 改为充值类型
+ 'source_id' => 0, //todo 改为充值订单主键
+ 'source_sn' => 0, // todo 改为充值订单编号
+ 'change_amount' => $local_earnings,
+ 'left_amount' => $local_earnings_buy + $local_earnings,
+ 'change_type' => 1,
+ 'remark' => '推广本地商家收款佣金增加'
+ ]);
+ }
+ }
+ }
+ }
+ }
+ $remark = $remark1 =$remark2= "";
+ $source_type = $source_type1 =$source_type2= 0;
+ if($type == "balance_rechange"){
+ $remark = "用户充值佣金";
+ $source_type = AccountLog::recharge_inc_earnings;
+ $remark1 = "无极充值佣金";
+ $source_type1 = AccountLog::electrodeless_rechange_inc_earnings;
+ $remark2 = "无极公司充值佣金";
+ $source_type2 = AccountLog::company_electrodeless_rechange_inc_earnings;
+ }
+ if($type == "local_pay"){
+ $remark = "本地生活用户佣金";
+ $source_type = AccountLog::local_user_inc_earnings;
+ $remark1 = "无极本地生活用户佣金";
+ $source_type1 = AccountLog::electrodeless_local_inc_earnings;
+ $remark2 = "无极公司本地生活用户佣金";
+ $source_type2 = AccountLog::company_electrodeless_local_inc_earnings;
+ }
+ if($type == "billions_rechange"){
+ $remark = "返补充值佣金";
+ $source_type = AccountLog::billions_rechange_inc_earnings;
+ $remark1 = "无极返补充值佣金";
+ $source_type1 = AccountLog::electrodeless_billions_rechange_inc_earnings;
+ $remark2 = "无极公司返补充值佣金";
+ $source_type2 = AccountLog::company_electrodeless_billions_rechange_inc_earnings;
+ }
+ if($type == "pay_goods"){
+ $remark = "消费佣金";
+ $source_type = AccountLog::pay_money;
+ $remark1 = "无极消费佣金";
+ $source_type1 = AccountLog::electrodeless_pay_money;
+ $remark2 = "无极公司消费佣金";
+ $source_type2 = AccountLog::company_electrodeless_pay_money;
+ }
+ if($type == "distribution"){
+ $remark = "分销推广会员佣金";
+ $source_type = AccountLog::distribution_user_earnings;
+ $remark1 = "无极分销推广会员佣金";
+ $source_type1 = AccountLog::distribution_user_electrodeless_earnings;
+ $remark2 = "无极公司分销推广会员佣金";
+ $source_type2 = AccountLog::distribution_user_company_electrodeless_earnings;
+ }
+ if($user['first_leader']>0){
+ $first_leader_percent = round($order['order_amount'] * $first_leader / 100, 8);
+// Order::where('id', $order['id'])
+// ->inc('distribution_money',$first_leader_percent)->update();
+ UserDistribution::where('user_id', $user['first_leader'])
+ ->inc('order_amount', $first_leader_percent)->update();
+ UserDistribution::where('user_id', $user['first_leader'])
+ ->inc('order_num')->update();
+ User::where('id', $user['first_leader'])
+ ->inc('earnings', $first_leader_percent)->update();
+ $earnings_buy = AccountLog::where('user_id', $user['first_leader'])->order("create_time desc")->limit(1)->value('left_amount');
+ $sn = createSn('account_log', 'log_sn', '', 4);
+ AccountLog::create([
+ 'log_sn' => $sn,
+ 'user_id' => $user['first_leader'],
+ 'source_type' => $source_type, //todo 改为充值类型
+ 'source_id' => 0, //todo 改为充值订单主键
+ 'source_sn' => 0, // todo 改为充值订单编号
+ 'change_amount' => $first_leader_percent,
+ 'left_amount' => $earnings_buy + $first_leader_percent,
+ 'change_type' => 1,
+ 'remark' => $remark
+ ]);
+ DistributionOrderGoods::create([
+ 'sn' => $sn,
+ 'user_id' => $user['first_leader'],
+ 'ratio' => $first_leader,
+ 'order_id' => 0, //todo 改为充值订单主键
+ 'order_goods_id' => 0, //todo 因为是充值所以改为0
+ 'goods_num' => 1, // todo 因为是充值所以改为1
+ 'money' => $first_leader_percent,
+ 'status' => 2,
+ 'create_time' => time(),
+ 'shop_id' => 0, // todo 因为是充值所以改为默认0
+ 'is_recharge' => 1, // todo 因为是充值所以改为1
+ 'settlement_time' => time()
+ ]);
+ }
+ // 1%给运营人员
+ $divide_second_user_msg = Db::name("user")->where("id",$user['divide_second_user_id'])->find();
+ $regional_state = 0;
+ if($divide_second_user_msg != null){
+ $regional_state = $user['regional_state'];
+ }
+ $performance_person = 0;
+ $performance = 0;
+ if($regional_state == 1){
+ $performance = $user['regional_percent'];
+ $performance_person = round($order['order_amount'] * $performance / 100, 8);
+ // Order::where('id', $order['id'])
+ // ->inc('distribution_money',$performance_person)->update();
+ // $shopDistribution_msg = UserShopDistribution::where('shop_id', $value['shop_id'])
+ // ->find();
+ User::where('id', $user['divide_second_user_id'])
+ ->inc('earnings', $performance_person)->update();
+ $earnings_buy = AccountLog::where('user_id', $user['divide_second_user_id'])->order("create_time desc")->limit(1)->value('left_amount');
+ $sn = createSn('account_log', 'log_sn', '', 4);
+ AccountLog::create([
+ 'log_sn' => $sn,
+ 'user_id' => $user['divide_second_user_id'],
+ 'source_type' => $source_type1,
+ 'source_id' => 0,
+ 'source_sn' => 0,
+ 'change_amount' => $performance_person,
+ 'left_amount' => $earnings_buy + $performance_person,
+ 'change_type' => 1,
+ 'remark' => $remark1
+ ]);
+ DistributionOrderGoods::create([
+ 'sn' => $sn,
+ 'user_id' => $user['divide_second_user_id'],
+ 'ratio' => $performance,
+ 'order_id' => 0,
+ 'order_goods_id' => 0,
+ 'goods_num' => 1,
+ 'money' => $performance_person,
+ 'status' => 2,
+ 'create_time' => time(),
+ 'shop_id' => 0,
+ 'settlement_time' => time()
+ ]);
+ }
+ // 3%对公司
+ $role_user_msg = Db::name("user")->where("id",$user['divide_role_user_id'])->find();
+ $state = 0;
+ if($role_user_msg != null){
+ $state = $user['divide_state'];
+ }
+ if($user['divide_role_user_id'] > 0&&$state>0 ){
+ $divide_percent = round($order['order_amount'] * ($other_leader-$performance) / 100, 8);
+// Order::where('id', $order['id'])
+// ->inc('distribution_money',$divide_percent)->update();
+// $shopDistribution_msg = UserShopDistribution::where('shop_id', $value['shop_id'])
+// ->find();
+ User::where('id', $user['divide_role_user_id'])
+ ->inc('earnings', $divide_percent)->update();
+ $earnings_buy = AccountLog::where('user_id', $user['divide_role_user_id'])->order("create_time desc")->limit(1)->value('left_amount');
+ $sn = createSn('account_log', 'log_sn', '', 4);
+ AccountLog::create([
+ 'log_sn' => $sn,
+ 'user_id' => $user['divide_role_user_id'],
+ 'source_type' => $source_type2, //todo 改为充值类型
+ 'source_id' => 0, //todo 改为充值订单主键
+ 'source_sn' => $order['order_sn'], // todo 改为充值订单编号
+ 'change_amount' => $divide_percent,
+ 'left_amount' => $earnings_buy + $divide_percent,
+ 'change_type' => 1,
+ 'remark' => $remark2
+ ]);
+ DistributionOrderGoods::create([
+ 'sn' => $sn,
+ 'user_id' => $user['divide_role_user_id'],
+ 'ratio' => $other_leader-$performance,
+ 'order_id' => $order['id'], //todo 改为充值订单主键
+ 'order_goods_id' => 0, //todo 因为是充值所以改为0
+ 'goods_num' => 1, // todo 因为是充值所以改为1
+ 'money' => $divide_percent,
+ 'status' => 2,
+ 'create_time' => time(),
+ 'shop_id' => 0, // todo 因为是充值所以改为默认0
+ 'is_recharge' => 1, // todo 因为是充值所以改为1
+ 'settlement_time' => time()
+ ]);
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/app/common/logic/Earnings.php b/app/common/logic/Earnings.php
new file mode 100644
index 00000000..c5f95d1b
--- /dev/null
+++ b/app/common/logic/Earnings.php
@@ -0,0 +1,54 @@
+inc('earnings', $money)->update();
+ $earnings_buy = AccountLog::where('user_id', $first_leader)
+ ->order("create_time desc")
+ ->limit(1)
+ ->value('left_amount');
+ $sn = createSn('account_log', 'log_sn', '', 4);
+ $result = AccountLog::create([
+ 'log_sn' => $sn,
+ 'user_id' => $first_leader,
+ 'source_type' => $type_msg, //todo 改为充值类型
+ 'source_id' => 0, //todo 改为充值订单主键
+ 'source_sn' => 0, // todo 改为充值订单编号
+ 'change_amount' => $money,
+ 'left_amount' => $earnings_buy + $money,
+ 'change_type' => 1,
+ 'remark' => '分销推广佣金增加'
+ ]);
+ return $result;
+ }
+
+ //推广会员无极公司佣金
+ public function userElectrodelessEarnings($money,$divide_role_user_id,$type_msg){
+ User::where('id', $divide_role_user_id)
+ ->inc('earnings', $money)->update();
+ $earnings_buy = AccountLog::where('user_id', $divide_role_user_id)
+ ->order("create_time desc")
+ ->limit(1)
+ ->value('left_amount');
+ $sn = createSn('account_log', 'log_sn', '', 4);
+ $result = AccountLog::create([
+ 'log_sn' => $sn,
+ 'user_id' => $divide_role_user_id,
+ 'source_type' => $type_msg, //todo 改为充值类型
+ 'source_id' => 0, //todo 改为充值订单主键
+ 'source_sn' => 0, // todo 改为充值订单编号
+ 'change_amount' => $money,
+ 'left_amount' => $earnings_buy + $money,
+ 'change_type' => 1,
+ 'remark' => '分销推广佣金增加'
+ ]);
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/app/common/model/AccountLog.php b/app/common/model/AccountLog.php
index fb883ef3..de69ab2b 100755
--- a/app/common/model/AccountLog.php
+++ b/app/common/model/AccountLog.php
@@ -71,6 +71,9 @@ class AccountLog extends Models
const electrodeless_pay_money = 420;//无极消费佣金
const company_electrodeless_pay_money = 421;//无极公司消费佣金
const shop_pay_money = 422;//店铺消费佣金
+ const distribution_user_earnings = 423;//分销推广会员佣金
+ const distribution_user_electrodeless_earnings = 424;//无极分销推广会员佣金
+ const distribution_user_company_electrodeless_earnings = 425;//无极公司分销推广会员佣金
const money_change = [ //余额变动类型
self::admin_add_money,self::admin_reduce_money,self::recharge_money,self::balance_pay_order,self::cancel_order_refund,self::after_sale_refund
, self::withdraw_to_balance,self::user_transfer_inc_balance, self::user_transfer_dec_balance, self::integral_order_dec_balance, self::integral_order_inc_balance
@@ -110,7 +113,10 @@ class AccountLog extends Models
self::pay_money, //消费佣金
self::electrodeless_pay_money, //无极消费佣金
self::company_electrodeless_pay_money, //无极公司消费佣金
- self::shop_pay_money //店铺消费佣金
+ self::shop_pay_money, //店铺消费佣金
+ self::distribution_user_earnings, //分销推广会员佣金
+ self::distribution_user_electrodeless_earnings, //无极分销推广会员佣金
+ self::distribution_user_company_electrodeless_earnings //无极公司分销推广会员佣金
];
public static function getAcccountDesc($from = true){
@@ -151,6 +157,9 @@ class AccountLog extends Models
self::electrodeless_pay_money => '无极消费佣金',
self::company_electrodeless_pay_money => '无极公司消费佣金',
self::shop_pay_money =>'店铺消费佣金',
+ self::distribution_user_earnings =>'分销推广会员佣金',
+ self::distribution_user_electrodeless_earnings =>'无极分销推广会员佣金',
+ self::distribution_user_company_electrodeless_earnings => '无极公司分销推广会员佣金',
self::withdraw_dec_earnings => '提现扣减佣金',
self::withdraw_back_earnings => '拒绝提现返还佣金',
self::distribution_inc_earnings => '订单结算获得佣金',