|
@@ -96,7 +96,7 @@ class Profit
|
|
|
$info = $this->get($uid, $profit['id'], $config['id'], $config['project_id']);
|
|
|
|
|
|
# 开始处理入账
|
|
|
- $this->handle($profit, $uid, $cash, $info['id'], $project['source'], $status, $source, $source_id, $name, $desc);
|
|
|
+ $this->handle($profit, $config, $uid, $cash, $info['id'], $project['source'], $status, $source, $source_id, $name, $desc);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -114,19 +114,19 @@ class Profit
|
|
|
}
|
|
|
|
|
|
# 计算金额
|
|
|
- private function handle($profit, $uid, $cash, $profit_id, $project_source, $status, $source, $source_id, $name, $desc)
|
|
|
+ private function handle($profit, $config, $uid, $cash, $profit_id, $project_source, $status, $source, $source_id, $name, $desc)
|
|
|
{
|
|
|
$rule = Dever::db('account/config_profit_rule')->select(array('profit_id' => $profit['id']));
|
|
|
if ($rule) {
|
|
|
$child = array();
|
|
|
foreach ($rule as $k => $v) {
|
|
|
- $child[$v['level']] = $this->rule($v, $child, $uid, $cash, $profit_id, $project_source, $status, $source, $source_id, $name, $desc);
|
|
|
+ $child[$v['level']] = $this->rule($v, $child, $config, $uid, $cash, $profit_id, $project_source, $status, $source, $source_id, $name, $desc);
|
|
|
}
|
|
|
}
|
|
|
return $cash;
|
|
|
}
|
|
|
|
|
|
- private function rule($rule, $child, $uid, $cash, $profit_id, $project_source, $status, $source, $source_id, $name, $desc)
|
|
|
+ private function rule($rule, $child, $config, $uid, $cash, $profit_id, $project_source, $status, $source, $source_id, $name, $desc)
|
|
|
{
|
|
|
if ($rule['level'] > 0) {
|
|
|
$parent = Dever::load('invite/api')->getParent($uid, $rule['level']);
|
|
@@ -173,7 +173,7 @@ class Profit
|
|
|
$cash = $this->run($exp, $replace);
|
|
|
}
|
|
|
if ($cash > 0) {
|
|
|
- $this->add($uid, $cash, $profit_id, $status, $source, $source_id, $name, $desc);
|
|
|
+ $this->add($config, $uid, $cash, $profit_id, $status, $source, $source_id, $name, $desc);
|
|
|
return $cash;
|
|
|
}
|
|
|
return false;
|
|
@@ -190,7 +190,7 @@ class Profit
|
|
|
}
|
|
|
|
|
|
# 入账
|
|
|
- private function add($uid, $cash, $profit_id, $status, $source, $source_id, $name = '', $desc = '')
|
|
|
+ private function add($config, $uid, $cash, $profit_id, $status, $source, $source_id, $name = '', $desc = '')
|
|
|
{
|
|
|
$data['clear'] = true;
|
|
|
$data['profit_id'] = $profit_id;
|
|
@@ -215,20 +215,17 @@ class Profit
|
|
|
$cash = $log['cash'];
|
|
|
}
|
|
|
}
|
|
|
- echo $status;die;
|
|
|
- if ($status == 2) {
|
|
|
+ if ($status == 1) {
|
|
|
+ $data['cash'] = $cash;
|
|
|
+ } elseif ($status == 2) {
|
|
|
$data['ycash'] = $cash;
|
|
|
} elseif ($status == 3) {
|
|
|
$data['ycash'] = $log['ycash'] + $cash;
|
|
|
} elseif ($status == 4) {
|
|
|
$data['ycash'] = 0;
|
|
|
}
|
|
|
- $data['where_id'] = $log['id'];
|
|
|
+ $id = $data['where_id'] = $log['id'];
|
|
|
Dever::db('account/profit_log')->update($data);
|
|
|
-
|
|
|
- $update['where_id'] = $profit_id;
|
|
|
- $update['set_ycash'] = $data['ycash'];
|
|
|
- Dever::db('account/profit')->incYcash($update);
|
|
|
} else {
|
|
|
# 入账
|
|
|
$data['cash'] = $cash;
|
|
@@ -237,10 +234,22 @@ class Profit
|
|
|
}
|
|
|
$data['order_num'] = $this->createOrderNum();
|
|
|
$id = Dever::db('account/profit_log')->insert($data);
|
|
|
+ }
|
|
|
|
|
|
- $update['where_id'] = $profit_id;
|
|
|
- $update['set_cash'] = $data['cash'];
|
|
|
- Dever::db('account/profit')->incCash($update);
|
|
|
+ if ($id && $id > 0) {
|
|
|
+ if (isset($data['cash']) && $data['cash']) {
|
|
|
+ $update['where_id'] = $profit_id;
|
|
|
+ $update['set_cash'] = $data['cash'];
|
|
|
+ Dever::db('account/profit')->incCash($update);
|
|
|
+ }
|
|
|
+ if (isset($data['ycash']) && $data['ycash']) {
|
|
|
+ $update['where_id'] = $profit_id;
|
|
|
+ $update['set_ycash'] = $data['ycash'];
|
|
|
+ Dever::db('account/profit')->incYcash($update);
|
|
|
+
|
|
|
+ # 同步钱包
|
|
|
+ Dever::load('account/lib/info.up_commit', $uid, $data['ycash'], 'shouyi', $config, $name, $source, $source_id, 1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|