// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\console\service; use app\console\library\Tools; use app\common\service\BaseService; use app\console\model\User; use app\console\model\User as UserModel; use app\console\model\user\BonusHistory; use app\console\model\user\CommissionsDetail; /** * 服务类:每日计算店内职员的当月的业绩 * Class UserGrade * @package app\console\service */ class DailyBonus extends BaseService { /** * 每日计算店内职员的当月的业绩v.1.3.6 * @param int $storeId * @return array|bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function calBonusMoney36(int $storeId) { // 获取店内员工的预计佣金 $data = []; $userList = UserModel::getAllSellers(); $month= (int)date('m'); $year = (int)date('Y'); $from = mktime(0,0,0,$month,1,$year); $to = time(); // 遍历整理数据 foreach ($userList as $user) { $infos = CommissionsDetail::getFullBonusInfo36($user,$from,$to); if (count($infos)){ foreach ($infos as $info){ $bflag = BonusHistory::add36($user['user_id'],$year,$month,$info['shop_id'],$info['role'] ,$info['saleVolume'],$info['refundVolume'],$info['refundCount'],$info['countOvertimeSign'] ,$info['sumOvertimeSign'],$info['bonusRate'],$info['bonusMoney'],$info['orderCount'],$info['bonusLadder']); if ($bflag == false){ log_record(__METHOD__.':false:User:'.$user['user_id'].',shopId:'.$info['shop_id'].',role:'.$info['role']); } } }else{ continue; } } // 记录日志 Tools::taskLogs('DailyBonus', 'calBonusMoney', [ 'storeId' => $storeId, 'data' => $data ]); return true; } }