|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\models\system;
|
|
|
|
|
|
+use app\api\controller\user\UserController;
|
|
|
use app\models\store\StoreOrder;
|
|
|
use app\models\user\User;
|
|
|
use app\models\user\UserBill;
|
|
|
@@ -157,7 +158,67 @@ class SystemUserTask extends BaseModel
|
|
|
if ($SumPayPrice >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
|
|
|
return ['还需消费{$num}元', $SumPayPrice, $isComplete];
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 团队下级总累计消费
|
|
|
+ * @param int $task_id 任务id
|
|
|
+ * @param int $uid 用户id
|
|
|
+ * @param int $start_time 开始时间
|
|
|
+ * @param int $number 限定时间
|
|
|
+ * @return boolean
|
|
|
+ * */
|
|
|
+ public static function TeamConsumptionAmount($task_id, $uid = 0, $start_time = 0, $number = 0)
|
|
|
+ {
|
|
|
+ $isComplete = false;
|
|
|
+// $SumPayPrice = StoreOrder::where('paid', 1)->where('refund_status', 0)->where('is_del', 0)->where('uid', $uid)->where('add_time', '>', $start_time)->sum('pay_price');
|
|
|
|
|
|
+ $teamUids = UserController::getAllTeamMembers($uid); //获取团队所有成员
|
|
|
+ $team_achievement = 0;
|
|
|
+ if (!empty($teamUids)) {
|
|
|
+ $team_achievement = User::whereIn('uid', $teamUids)
|
|
|
+ ->sum('achievement');
|
|
|
+ }
|
|
|
+ @file_put_contents('quanju.txt', $team_achievement . "-总消费金额\r\n", 8);
|
|
|
+ $SumPayPrice =$team_achievement;
|
|
|
+ if ($SumPayPrice >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
|
|
|
+ return ['还需消费{$num}元', $SumPayPrice, $isComplete];
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 团队小区累计消费
|
|
|
+ * @param int $task_id 任务id
|
|
|
+ * @param int $uid 用户id
|
|
|
+ * @param int $start_time 开始时间
|
|
|
+ * @param int $number 限定时间
|
|
|
+ * @return boolean
|
|
|
+ * */
|
|
|
+ public static function CommunityConsumptionAmount($task_id, $uid = 0, $start_time = 0, $number = 0)
|
|
|
+ {
|
|
|
+ $isComplete = false;
|
|
|
+// $SumPayPrice = StoreOrder::where('paid', 1)->where('refund_status', 0)->where('is_del', 0)->where('uid', $uid)->where('add_time', '>', $start_time)->sum('pay_price');
|
|
|
+ $directSubordinateUids = User::where('spread_uid', $uid)->column('uid');
|
|
|
+
|
|
|
+ $max = 0;
|
|
|
+ $team_achievement=0;
|
|
|
+ if (!empty($directSubordinateUids)) {
|
|
|
+ foreach ($directSubordinateUids as $key => $value){
|
|
|
+ $teamUids = UserController::getAllTeamMembers($uid); //获取直推下级的团队所有成员
|
|
|
+ if (!empty($teamUids)) {
|
|
|
+ $personal_achievement = User::whereIn('uid', $teamUids)
|
|
|
+ ->sum('achievement');
|
|
|
+ $team_achievement += $personal_achievement;
|
|
|
+ if ($personal_achievement > $max){ //获取最高消费团队
|
|
|
+ $max = $personal_achievement;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $community_achievement = bcsub($team_achievement, $max, 2); //小区消费
|
|
|
+ @file_put_contents('quanju.txt', $team_achievement . "-总消费\r\n", 8);
|
|
|
+ @file_put_contents('quanju.txt', $max . "-大区消费\r\n", 8);
|
|
|
+ @file_put_contents('quanju.txt', $community_achievement . "-小区消费\r\n", 8);
|
|
|
+ $SumPayPrice =$community_achievement;
|
|
|
+ if ($SumPayPrice >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
|
|
|
+ return ['还需消费{$num}元', $SumPayPrice, $isComplete];
|
|
|
+ }
|
|
|
/**
|
|
|
* 累计消费次数
|
|
|
* @param int $task_id 任务id
|