|
@@ -35,13 +35,29 @@ class Package extends BaseModel
|
|
|
$data['first_price'] = $first_price;
|
|
|
$data['last_id'] = $last_id;
|
|
|
$data['price'] = $price;
|
|
|
+ if(cache('reserve_'.$uid,1) && false) return self::setErrorInfo('你已报名,无需重复报名');
|
|
|
if($last_id>0 && self::where('last_id',$last_id)->where('uid',$uid)->find())
|
|
|
{
|
|
|
return self::setErrorInfo('你已报名,无需重复报名');
|
|
|
+ }elseif($last_id>0 && self::where('last_id',$last_id)->find())
|
|
|
+ {
|
|
|
+ return self::setErrorInfo('该订单已有预约');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cache('reserve_'.$uid,1,60);
|
|
|
}
|
|
|
+
|
|
|
$integral = bcmul($price,bcdiv(sys_config('reserve_integral'),100,2),2);
|
|
|
- if($integral>$user['integral']) return self::setErrorInfo('金豆不足,请先买金豆专区');
|
|
|
- if($last_id>0 && self::where('id',$last_id)->value('status')!=3) return self::setErrorInfo('已有用户预约,换个商品预约');
|
|
|
+ if($integral>$user['gold'])
|
|
|
+ {
|
|
|
+ cache('reserve_'.$uid,null);
|
|
|
+ return self::setErrorInfo('金豆不足,请先买金豆专区');
|
|
|
+ }
|
|
|
+ if($last_id>0 && self::where('id',$last_id)->value('status')!=3) {
|
|
|
+ cache('reserve_'.$uid,null);
|
|
|
+ return self::setErrorInfo('已有用户预约,换个商品预约');
|
|
|
+ }
|
|
|
$data['add_time'] = time();
|
|
|
$data['order_id'] = self::getNewOrderId();
|
|
|
if($to_uid==0)
|
|
@@ -53,14 +69,16 @@ class Package extends BaseModel
|
|
|
try{
|
|
|
$data['use_integral'] = $integral;
|
|
|
$res = self::create($data);
|
|
|
- User::where('uid',$uid)->dec('integral',$integral)->update();
|
|
|
- UserBill::expend("预约扣金豆",$uid,'integral','pay_money',$integral,$res['id'],bcsub($user['integral'],$integral,2),'预约扣除'.$integral."金豆");
|
|
|
- User::edit(['is_whole'=>1],$uid);
|
|
|
+ User::where('uid',$uid)->dec('gold',$integral)->update();
|
|
|
+ UserBill::expend("预约扣金豆",$uid,'gold','pay_money',$integral,$res['id'],bcsub($user['gold'],$integral,2),'预约扣除'.$integral."金豆");
|
|
|
+ if($last_id==0) User::edit(['is_whole'=>1],$uid);
|
|
|
+ if($last_id>0) self::where('id',$last_id)->update(['status'=>3]);
|
|
|
self::commitTrans();
|
|
|
return $res->toArray();
|
|
|
|
|
|
}catch (Exception $e)
|
|
|
{
|
|
|
+ cache('reserve_'.$uid,null);
|
|
|
Log::error('预约出错:' . $e->getLine().'--'.$e->getMessage());
|
|
|
return self::setErrorInfo($e->getMessage(),true);
|
|
|
}
|
|
@@ -104,16 +122,23 @@ class Package extends BaseModel
|
|
|
public static function take($id)
|
|
|
{
|
|
|
$info = self::find($id);
|
|
|
- $data['status'] = 3;
|
|
|
+ $data['status'] = 2;
|
|
|
$data['paid'] = 1;
|
|
|
self::beginTrans();
|
|
|
try {
|
|
|
- User::where('uid',$info['uid'])->inc('now_money',$info['pass'])->update();
|
|
|
+ $package_income = bcmul($info['price'],bcdiv(sys_config('package_income'),100,2),2);
|
|
|
+ $confirm_receipt = bcmul($info['price'],bcdiv(sys_config('confirm_receipt'),100,2),2);
|
|
|
+ $gold_bond = bcmul($info['price'],bcdiv(sys_config('gold_bond'),100,2),2);
|
|
|
+ User::where('uid',$info['uid'])->inc('brokerage_price',$package_income)->inc('gold',$gold_bond)->update();
|
|
|
$user = User::where('uid',$info['uid'])->find();
|
|
|
- UserBill::income('通证收益',$info['uid'],'now_money','sign',$info['pass'],$info['id'],$user['now_money'],'包收益通证'.$info['pass']);
|
|
|
+ UserBill::income('订单收益',$info['uid'],'now_money','brokerage',$package_income,$info['id'],$user['brokerage_price'],'订单收益'.$package_income);
|
|
|
+ UserBill::income('订单金券收益',$info['uid'],'integral','package',$gold_bond,$info['id'],$user['gold'],'订单收益'.$gold_bond);
|
|
|
+
|
|
|
$res = self::edit($data,$id);
|
|
|
- $res1 = self::backBrokerage($info);
|
|
|
- if($info['last_id']>0) self::edit(['status'=>6],$info['last_id']);
|
|
|
+ User::where('uid',$info['to_uid'])->inc('brokerage_price',$confirm_receipt)->update();
|
|
|
+ $to_user = User::where('uid',$info['to_uid'])->find();
|
|
|
+ UserBill::income('订单确认收益',$info['to_uid'],'now_money','brokerage',$confirm_receipt,$info['id'],$to_user['brokerage_price'],'订单确认收益'.$confirm_receipt);
|
|
|
+ if($info['last_id']>0) self::edit(['status'=>4],$info['last_id']);
|
|
|
self::commitTrans();
|
|
|
}
|
|
|
catch (Exception $e)
|
|
@@ -126,236 +151,99 @@ class Package extends BaseModel
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 定时执行
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * 订单无效
|
|
|
+ * @param $id
|
|
|
*/
|
|
|
- public static function make_package()
|
|
|
+ public static function invalid($id,$re='')
|
|
|
{
|
|
|
- self::startTrans();
|
|
|
- try {
|
|
|
- $package_manager = sys_data('package_manager');
|
|
|
- $package = [];
|
|
|
- foreach ($package_manager as $v) {
|
|
|
- if(date("H:i") == $v['open'])
|
|
|
- $package[] = $v;
|
|
|
- }
|
|
|
- $uids = User::where('is_sys', 1)->column('uid');
|
|
|
- foreach ($package as $v)
|
|
|
- {
|
|
|
- $arr = self::where('status', 0)->where('package_manager',$v['id'])->where('add_time','<',strtotime(date("Y-m-d ").$v['end'].":00"))->select();
|
|
|
- if ($arr) {
|
|
|
- $ids = [];
|
|
|
- $sum = $v['one'];
|
|
|
- if (sizeof($arr->toArray()) > $sum) {
|
|
|
- $ids = self::getrand($arr->toArray(), $sum);
|
|
|
- } else {
|
|
|
- foreach ($arr as $v1) {
|
|
|
- $ids[] = $v1['id'];
|
|
|
- }
|
|
|
- }
|
|
|
- foreach ($ids as $v2) {
|
|
|
-
|
|
|
- $info = self::where('status', 4)->where('uid','not in',$uids)->where('add_time','<',strtotime("-30 minute"))->where('package_manager', $v['id'])->find();
|
|
|
- $last_id = 0;
|
|
|
- if ($info) {
|
|
|
- $to_uid = $info['uid'];
|
|
|
- $last_id = $info['id'];
|
|
|
- self::edit(['status' => 5], $info['id']);
|
|
|
- } else {
|
|
|
- $to_uid = User::where('is_sys', 1)->order('sys_pay asc,uid asc')->value('uid');
|
|
|
- User::where('uid', $to_uid)->inc('sys_pay', 1)->update();
|
|
|
-
|
|
|
- }
|
|
|
- self::edit(['to_uid' => $to_uid, 'status' => 1,'last_id'=>$last_id,'lottery_time'=>time()], $v2);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- self::checkTrans(true);
|
|
|
- }catch (Exception $e)
|
|
|
- {
|
|
|
- self::setErrorInfo('生成出错'.$e->getMessage(),true);
|
|
|
- }
|
|
|
+ $data['status'] = -1;
|
|
|
+ $data['re'] = $re;
|
|
|
+ $last_id = self::where('id',$id)->value('last_id');
|
|
|
+ if($last_id>0) self::edit(['status'=>2],$last_id);
|
|
|
+ return self::edit($data,$id);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 定时执行老
|
|
|
+ * 支付超时
|
|
|
*/
|
|
|
- public static function make_package2()
|
|
|
+ public static function time_out()
|
|
|
{
|
|
|
- self::startTrans();
|
|
|
- try {
|
|
|
- $H = date("H");
|
|
|
- $package_manager = sys_data('package_manager');
|
|
|
- $package = [];
|
|
|
- foreach ($package_manager as $v) {
|
|
|
- $package[$v['id']] = $v;
|
|
|
- }
|
|
|
- $model = new self;
|
|
|
- $model = $model->where('add_time','<',strtotime("-30 minute"));
|
|
|
- $where = null;
|
|
|
- if ($H < 13) {
|
|
|
- $model = $model->where('am', 1);
|
|
|
- $where['am'] = 1;
|
|
|
- } else {
|
|
|
- $model = $model->where('am', 0);
|
|
|
- $where['am'] = 0;
|
|
|
- }
|
|
|
- $rs = $model->where('status', 0)->group('package_manager')->field('package_manager,count(package_manager) as ct')->select();
|
|
|
-
|
|
|
- foreach ($rs as $v) {
|
|
|
- $arr = self::where('status', 0)->where($where)->where('add_time','<',strtotime("-30 minute"))->where('package_manager', $v['package_manager'])->select();
|
|
|
- if ($arr) {
|
|
|
- $ids = [];
|
|
|
- $sum = $package[$v['package_manager']]['one'];
|
|
|
- if (sizeof($arr->toArray()) > $sum) {
|
|
|
- $ids = self::getrand($arr->toArray(), $sum);
|
|
|
- } else {
|
|
|
- foreach ($arr as $v1) {
|
|
|
- $ids[] = $v1['id'];
|
|
|
- }
|
|
|
- }
|
|
|
- foreach ($ids as $v2) {
|
|
|
- $info = self::where('status', 4)->where($where)->where('add_time','<',strtotime("-30 minute"))->where('package_manager', $v['package_manager'])->find();
|
|
|
- $last_id = 0;
|
|
|
- if ($info) {
|
|
|
- $to_uid = $info['uid'];
|
|
|
- $last_id = $info['id'];
|
|
|
- self::edit(['status' => 5], $info['id']);
|
|
|
- } else {
|
|
|
- $to_uid = User::where('is_sys', 1)->order('sys_pay asc,uid asc')->value('uid');
|
|
|
- User::where('uid', $to_uid)->inc('sys_pay', 1)->update();
|
|
|
- }
|
|
|
- self::edit(['to_uid' => $to_uid, 'status' => 1,'last_id'=>$last_id,'lottery_time'=>time()], $v2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- self::checkTrans(true);
|
|
|
- }catch (Exception $e)
|
|
|
+ $list = self::where('status',1)->where('add_time','<',strtotime("-".sys_config('order_whole_time')." hour"))->select();
|
|
|
+ foreach ($list as $v)
|
|
|
{
|
|
|
- self::setErrorInfo('生成出错'.$e->getMessage(),true);
|
|
|
+ if($v['last_id']>0) self::edit(['status'=>2],$v['last_id']);
|
|
|
+ self::edit(['status'=>-2],$v['id']);
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 返现
|
|
|
- * @param $info
|
|
|
+ * 收货确认超时
|
|
|
+ * @return bool
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public static function backBrokerage($info)
|
|
|
+ public static function take_outs()
|
|
|
{
|
|
|
- $userinfo = User::find($info['uid']);
|
|
|
- $spreaduser = User::where('uid',$userinfo['spread_uid'])->find();
|
|
|
- $twouser = User::where('uid',$spreaduser['spread_uid'])->find();
|
|
|
- $bksum = bcdiv(bcmul($info['price'],bcmul($info['proportion'],$info['day'],2),2),100,2);
|
|
|
- if($spreaduser['level']>0) {
|
|
|
- $recommend = bcmul(bcdiv(sys_config('recommend'),100,2), $bksum, 2);
|
|
|
- $mark = "订单号" . $info['order_id'] . '产生推荐奖,奖励推广佣金' . $recommend;
|
|
|
- $res1 = UserBill::income('推荐奖', $spreaduser['uid'], 'now_money', 'brokerage', $recommend, $info['id'], bcadd($recommend, $spreaduser['brokerage_price'], 2), $mark);
|
|
|
- $res2 = User::where('uid', $spreaduser['uid'])->inc('brokerage_price', $recommend)->update();
|
|
|
- }
|
|
|
- //二代推荐
|
|
|
- if($twouser && $twouser['level']>1)
|
|
|
- {
|
|
|
- $recommend = bcmul(bcdiv(sys_config('two_recommend'),100,2), $bksum, 2);
|
|
|
- $mark = "订单号" . $info['order_id'] . '产生推荐奖,奖励推广佣金' . $recommend;
|
|
|
- $res1 = UserBill::income('二代推荐奖', $twouser['uid'], 'now_money', 'brokerage', $recommend, $info['id'], bcadd($recommend, $twouser['brokerage_price'], 2), $mark);
|
|
|
- $res2 = User::where('uid', $twouser['uid'])->inc('brokerage_price', $recommend)->update();
|
|
|
- }
|
|
|
-
|
|
|
- $userlist = User::select()->toArray();
|
|
|
- $pids = UtilService::getparentid($userlist, $info['uid']);
|
|
|
- $levels = SystemUserLevel::where('is_del',0)->where('is_show',1)->field('id,name,peer_award,team_award')->select();
|
|
|
- $levela = [];$current_level = $spreaduser['level'];
|
|
|
- foreach ($levels as $v)
|
|
|
- {
|
|
|
- $levela[$v['id']]['peer_award'] = $v['peer_award'];
|
|
|
- $levela[$v['id']]['team_award'] = $v['team_award'];
|
|
|
- $levela[$v['id']]['sbl'] = false;
|
|
|
- $levela[$v['id']]['use'] = false;
|
|
|
- }
|
|
|
- if($pids) {
|
|
|
- foreach ($pids as $v) {
|
|
|
- if ($v['level'] >= $current_level && $levela[$v['level']]['team_award'] > 0) {
|
|
|
- //处理第一次
|
|
|
- if ($levela[$v['level']]['use']==false) {
|
|
|
- $level_award = $levela[$v['level']]['team_award'];
|
|
|
- $levela[$v['level']]['use'] = true;
|
|
|
- } else {
|
|
|
- if ($levela[$v['level']]['sbl']==false) {
|
|
|
- $level_award = $levela[$v['level']]['peer_award'];
|
|
|
- $levela[$v['level']]['sbl'] = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($v['level'] > $current_level) {
|
|
|
- $current_level = $v['level'];
|
|
|
- } else {
|
|
|
- if ($v['level'] == $current_level && $levela[$v['level']]['sbl'] == true) {
|
|
|
- $current_level++;
|
|
|
- }
|
|
|
- }
|
|
|
- $proportion = bcmul($bksum, bcdiv($level_award, 100, 2), 2);
|
|
|
- if($proportion==0) continue;
|
|
|
- if ($levela[$v['level']]['sbl'] == true) {
|
|
|
- $mark = "订单号" . $info['order_id'] . '产生平级奖,奖励推广佣金' . $proportion;
|
|
|
- $res1 = UserBill::income('平级奖', $v['uid'], 'now_money', 'brokerage', $proportion, $info['id'], bcadd($proportion, $v['brokerage_price'], 2), $mark);
|
|
|
- $res2 = User::where('uid', $v['uid'])->inc('brokerage_price', $proportion)->update();
|
|
|
- } else {
|
|
|
- $mark = "订单号" . $info['order_id'] . '产生团队奖,奖励推广佣金' . $proportion;
|
|
|
- $res1 = UserBill::income('团队奖', $v['uid'], 'now_money', 'brokerage', $proportion, $info['id'], bcadd($proportion, $v['brokerage_price'], 2), $mark);
|
|
|
- $res2 = User::where('uid', $v['uid'])->inc('brokerage_price', $proportion)->update();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ $data['status'] = 2;
|
|
|
+ $data['paid'] = 1;
|
|
|
+ $list = self::where('pay_time', '<', strtotime("-" . sys_config('order_whole_time') . " hour"))->select()->toArray();
|
|
|
+ self::beginTrans();
|
|
|
+ try {
|
|
|
+ foreach ($list as $info) {
|
|
|
+ $confirm_receipt = bcmul($info['price'], bcdiv(sys_config('confirm_receipt'), 100, 2), 2);
|
|
|
+ $package_income = bcmul($info['price'], bcdiv(sys_config('package_income'), 100, 2), 2);
|
|
|
+ $confirm_receipt1 = bcmul($info['price'], bcdiv(bcsub(sys_config('confirm_receipt'), sys_config('not_confirm_receipt', 2.2), 2), 100, 2), 2);
|
|
|
+ User::where('uid', $info['uid'])->inc('brokerage_price', $package_income)->update();
|
|
|
+ $user = User::where('uid', $info['uid'])->find();
|
|
|
+ UserBill::income('订单收益', $info['uid'], 'now_money', 'brokerage', $package_income, $info['id'], $user['brokerage_price'], '订单收益' . $package_income);
|
|
|
+ $res = self::edit($data, $info['id']);
|
|
|
+ User::where('uid', $info['to_uid'])->inc('brokerage_price', $confirm_receipt1)->update();
|
|
|
+ $to_user = User::where('uid', $info['to_uid'])->find();
|
|
|
+ UserBill::income('订单确认收益', $info['to_uid'], 'now_money', 'brokerage', $confirm_receipt1, $info['id'], $to_user['brokerage_price'], '订单确认收益' . $confirm_receipt1 . ',未确认收货系统确认,扣除收益' . bcsub($confirm_receipt, $confirm_receipt1, 2));
|
|
|
+ if ($info['last_id'] > 0) self::edit(['status' => 4], $info['last_id']);
|
|
|
}
|
|
|
+ } catch (Exception $e) {
|
|
|
+ Log::error('收货错误:' . $e->getFile() . '行' . $e->getLine() . "原因:" . $e->getMessage());
|
|
|
+ self::setErrorInfo('收货确认错误', true);
|
|
|
}
|
|
|
+ self::commitTrans();
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 订单无效
|
|
|
- * @param $id
|
|
|
- */
|
|
|
- public static function invalid($id,$re='')
|
|
|
+ public static function take_out($id)
|
|
|
{
|
|
|
- $data['status'] = -2;
|
|
|
- $data['re'] = $re;
|
|
|
- $last_id = self::where('id',$id)->value('last_id');
|
|
|
- if($last_id>0) self::edit(['status'=>4],$last_id);
|
|
|
- return self::edit($data,$id);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 支付超时
|
|
|
- */
|
|
|
- public static function time_out()
|
|
|
- {
|
|
|
- $list = self::where('status',1)->where('lottery_time','<',strtotime("-".sys_config('time_out')." minute"))->select();
|
|
|
- foreach ($list as $v)
|
|
|
+ $info = self::where('pay_time','<',strtotime("-".sys_config('order_whole_time')." hour"))->where('id',$id)->find();
|
|
|
+ if($info)
|
|
|
{
|
|
|
- if($v['last_id']>0) self::edit(['status'=>4],$v['last_id']);
|
|
|
- self::edit(['status'=>-3],$v['id']);
|
|
|
- $user =User::where('uid',$v['uid'])->find();
|
|
|
- User::where('uid',$v['uid'])->inc('notpay',1)->update();
|
|
|
- if($user['notpay']<9)
|
|
|
- {
|
|
|
- if(bcadd($user['notpay'],1) % 3==0)
|
|
|
- {
|
|
|
- $mark = "累计提时" .bcadd($user['notpay'],1) . '扣通行证100';
|
|
|
- $res1 = UserBill::expend('支付超时', $v['uid'], 'now_money', 'pay_money', 100, 0, bcsub($v['now_money'],100, 2), $mark);
|
|
|
- $res2 = User::where('uid', $v['uid'])->dec('now_money', 100)->update();
|
|
|
- }
|
|
|
+ $data['status'] = 2;
|
|
|
+ $data['paid'] = 1;
|
|
|
+ self::beginTrans();
|
|
|
+ try {
|
|
|
+ $confirm_receipt = bcmul($info['price'],bcdiv(sys_config('confirm_receipt'),100,2),2);
|
|
|
+ $package_income = bcmul($info['price'],bcdiv(sys_config('package_income'),100,2),2);
|
|
|
+ $confirm_receipt1 = bcmul($info['price'],bcdiv(bcsub(sys_config('confirm_receipt'),sys_config('not_confirm_receipt',2.2),2),100,2),2);
|
|
|
+ User::where('uid',$info['uid'])->inc('brokerage_price',$package_income)->update();
|
|
|
+ $user = User::where('uid',$info['uid'])->find();
|
|
|
+ UserBill::income('订单收益',$info['uid'],'now_money','brokerage',$package_income,$info['id'],$user['brokerage_price'],'订单收益'.$package_income);
|
|
|
+ $res = self::edit($data,$id);
|
|
|
+ User::where('uid',$info['to_uid'])->inc('brokerage_price',$confirm_receipt1)->update();
|
|
|
+ $to_user = User::where('uid',$info['to_uid'])->find();
|
|
|
+ UserBill::income('订单确认收益',$info['to_uid'],'now_money','brokerage',$confirm_receipt1,$info['id'],$to_user['brokerage_price'],'订单确认收益'.$confirm_receipt1.',未确认收货系统确认,扣除收益'.bcsub($confirm_receipt,$confirm_receipt1,2));
|
|
|
+ if($info['last_id']>0) self::edit(['status'=>4],$info['last_id']);
|
|
|
+ self::commitTrans();
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception $e)
|
|
|
{
|
|
|
- if($user['status'] ==1)
|
|
|
- User::where('uid',$v['uid'])->update(['status'=>0]);
|
|
|
+ Log::error('收货错误:' .$e->getFile().'行'.$e->getLine()."原因:".$e->getMessage());
|
|
|
+ self::setErrorInfo('收货确认错误',true);
|
|
|
}
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return self::setErrorInfo('未到'.sys_config('order_whole_time')."小时,不能后台确认");
|
|
|
}
|
|
|
- return ;
|
|
|
}
|
|
|
/**
|
|
|
* 获取中奖用户编号
|
|
@@ -402,16 +290,29 @@ class Package extends BaseModel
|
|
|
public static function lst($where)
|
|
|
{
|
|
|
$model = new self;
|
|
|
- if(isset($where['data']) && $where['data']!='') $model = $model->getModelTime($where,$model);
|
|
|
+ if(isset($where['data']) && $where['data']!='')
|
|
|
+ {
|
|
|
+ $model = $model->getModelTime($where,$model);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $model = $model->where('pay_time','<',strtotime("-1 day"));
|
|
|
+ }
|
|
|
if(isset($where['uid']) && $where['uid']>0) $model = $model->where('uid',$where['uid']);
|
|
|
if(isset($where['to_uid']) && $where['to_uid']>0) $model = $model->where('to_uid',$where['to_uid']);
|
|
|
if(isset($where['status']) && $where['status']>-4) $model = $model->where('status',$where['status']);
|
|
|
if(isset($where['time_id']) && $where['time_id']>-4) $model = $model->where('time_id',$where['time_id']);
|
|
|
$count = $model->value('count(id)')?:0;
|
|
|
- $data = $model->order('id desc')->page($where['page'],$where['limit'])->select();
|
|
|
+ $data = $model->order('id desc')->page($where['page'],$where['limit'])->select()->toarray();
|
|
|
foreach ($data as &$v)
|
|
|
{
|
|
|
- $v['whole'] = StoreWholesale::find($v['whole_id'])->toArray();
|
|
|
+ if($v['whole_id']) {
|
|
|
+ $v['whole'] = StoreWholesale::find($v['whole_id'])->toArray();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $v['whole'] = [];
|
|
|
+ }
|
|
|
$v['user'] = User::where('uid',$v['uid'])->field('real_name,avatar,phone')->find()->toArray();
|
|
|
if($v['to_uid']>0) {
|
|
|
$v['touser'] = User::where('uid', $v['to_uid'])->field('real_name,avatar,phone,wx_qr,wx_no,alipay_no,alipay_name,account_Bank,bank_card,bank_name,bank_branch')->find()->toArray();
|
|
@@ -421,46 +322,7 @@ class Package extends BaseModel
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 每天分账
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public static function day()
|
|
|
- {
|
|
|
- self::beginTrans();
|
|
|
- try {
|
|
|
- $list = self::where('status', 3)->where('end_day', '>', date("Y-m-d 00:00:00"))->where('sum_revenue', 'exp', '>use_revenue')->field('id,uid,order_id,sum_revenue/day as revenue,sum_revenue,use_revenue,price,pass')->select();
|
|
|
-
|
|
|
- if ($list) {
|
|
|
- foreach ($list->toarray() as $v) {
|
|
|
- if (floatval($v['sum_revenue']) - floatval($v['revenue']) - floatval($v['use_revenue']) > 0) {
|
|
|
- $data['use_revenue'] = bcadd($v['use_revenue'], $v['revenue'], 2);
|
|
|
- $number = $v['revenue'];
|
|
|
- } else {
|
|
|
- $data['use_revenue'] = $v['sum_revenue'];
|
|
|
- $number = bcsub($v['sum_revenue'], $v['use_revenue'], 2);
|
|
|
- $data['status'] = 4;
|
|
|
- }
|
|
|
- self::edit($data, $v['id']);
|
|
|
- $brokerage_price = User::where('uid', $v['uid'])->value('brokerage_price');
|
|
|
- User::where('uid',$v['uid'])->inc('brokerage_price',bcmul($number,0.8,2))->inc("integral",bcmul($number,0.2,2))->update();
|
|
|
- $mark = sprintf("订单号:%s,订单金额%d,当天收益%f,积分%f", $v['order_id'], $v['price'], bcmul($number,0.8,2),bcmul($number,0.2,2));
|
|
|
- UserBill::income('每天收益', $v['uid'], 'now_money', 'brokerage', bcmul($number,0.8,2), $v['id'], bcadd($brokerage_price, bcmul($number,0.8,2)), $mark);
|
|
|
- UserBill::income('每天收益积分', $v['uid'], 'integral', 'add', bcmul($number,0.2,2), $v['id'], bcadd($brokerage_price, bcmul($number,0.2,2)), $mark);
|
|
|
|
|
|
- unset($data);
|
|
|
- }
|
|
|
- }
|
|
|
- self::commitTrans();
|
|
|
- }
|
|
|
- catch (Exception $e)
|
|
|
- {
|
|
|
- return self::setErrorInfo('生成出错',true);
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
/**
|
|
|
* 获取会员升级订单
|
|
|
*/
|