IntegralRecordApi.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <?php
  2. namespace app\common\api;
  3. use app\common\api\DictApi;
  4. use app\admin\model\Enterprise;
  5. use think\facade\Db;
  6. use app\common\model\IntegralRecord;
  7. use app\common\state\IntegralState;
  8. /**
  9. * Description of IntegralRecordApi
  10. *
  11. * @author sgq
  12. */
  13. class IntegralRecordApi {
  14. public static function getOne($id) {
  15. $result = IntegralRecord::where("id", "=", $id)->find();
  16. $result["enterprise"] = EnterpriseApi::getOne($result["enterprise_id"]);
  17. $result["enterprise"]["streetName"] = DictApi::findDictByCode($result["enterprise"]["street"])["name"];
  18. if ($result) {
  19. $result["items"] = $result->detail;
  20. }
  21. return $result;
  22. }
  23. public static function getList($params) {
  24. $where = [];
  25. $order = $params["order"] ?: "desc";
  26. $offset = $params["offset"] ?: 0;
  27. $limit = $params["limit"] ?: 10;
  28. $where[] = ["e.type", "=", session("user")["type"]];
  29. if (session("user")["usertype"] == 2) {
  30. $where[] = ["enterprise_id", "=", session("user")["uid"]];
  31. }
  32. $where[] = ["ir.delete", "=", 0];
  33. if ($params["apply_year"]) {
  34. $where[] = ["b.batch", "like", "%{$params['apply_year']}%"];
  35. }
  36. if ($params["name"]) {
  37. $where[] = ["ir.name", "like", "%{$params['name']}%"];
  38. }
  39. if ($params["card_number"]) {
  40. $where[] = ["ir.card_number", "like", "%{$params['card_number']}%"];
  41. }
  42. if ($params["phone"]) {
  43. $where[] = ["ir.phone", "like", "%{$params['phone']}%"];
  44. }
  45. if ($params["email"]) {
  46. $where[] = ["ir.email", "like", "%{$params['email']}%"];
  47. }
  48. if ($params["shareholder"]) {
  49. $where[] = ["ir.shareholder", "=", $params['shareholder']];
  50. }
  51. switch ($params["checkState"]) {
  52. case -1:
  53. $where[] = ["tl.state", "in", [IntegralState::VERIFY_FAIL, IntegralState::REVERIFY_FAIL, IntegralState::ZX_FAIL, IntegralState::ANNOUNCED_REVERIFY_FAIL, IntegralState::PUBLISH_FAIL]];
  54. break;
  55. case 1:
  56. $where[] = ["tl.state", "=", IntegralState::SAVE];
  57. break;
  58. case 2:
  59. $where[] = ["tl.state", "in", [IntegralState::VERIFY_REJECT, IntegralState::REVERIFY_REJECT]];
  60. break;
  61. case 3:
  62. $where[] = ["tl.state", "in", [IntegralState::SUBMIT, IntegralState::VERIFY_PASS]];
  63. break;
  64. case 4:
  65. $where[] = ["tl.state", ">=", IntegralState::REVERIFY_PASS];
  66. $where[] = ["tl.state", "not in", [IntegralState::REVERIFY_REJECT, IntegralState::REVERIFY_FAIL]];
  67. break;
  68. case 5:
  69. $where[] = ["tl.state", "=", IntegralState::SUCCESS];
  70. break;
  71. }
  72. $count = IntegralRecord::alias("ir")
  73. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  74. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  75. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")->where($where)->count();
  76. $list = IntegralRecord::alias("ir")
  77. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  78. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  79. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")->where($where)->field("ir.*,b.batch as apply_year,tl.state,tl.new_state,if(ir.updateTime is not null,ir.updateTime,ir.createTime) as orderTime")
  80. ->limit($offset, $limit)
  81. ->order("orderTime " . $order)
  82. ->select();
  83. foreach ($list as $key => $item) {
  84. $tmp_items = [];
  85. foreach ($item["detail"] as $_item) {
  86. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  87. $tmp_items[] = sprintf("%s(%s%s)", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"]);
  88. }
  89. $list[$key]["details"] = implode(",", $tmp_items);
  90. $list[$key]["type"] = session("user")["type"];
  91. $last_log = TalentLogApi::getLastLog($item["id"], \app\common\state\ProjectState::INTEGRAL);
  92. $list[$key]["real_state"] = $last_log["state"];
  93. $list[$key]["last_state"] = $last_log["last_state"];
  94. }
  95. return ["total" => $count, "rows" => $list];
  96. }
  97. public static function getPublicList($params) {
  98. $order = $params["order"];
  99. $offset = $params["offset"];
  100. $limit = $params["limit"];
  101. $where = [];
  102. $where[] = ["e.type", "=", session("user")["type"]];
  103. if ($params["name"]) {
  104. $where[] = ["ir.name", "like", "%" . $params["name"] . "%"];
  105. }
  106. if ($params["checkState"]) {
  107. $where[] = ["ir.checkState", "=", $params["checkState"]];
  108. }
  109. $type = $params["type"];
  110. switch ($type) {
  111. case 1:
  112. case 2:
  113. $where[] = ["ir.checkState", "=", TalentState::REVERIFY_PASS];
  114. break;
  115. case 3: //公示
  116. case 7: //公示预览
  117. $where[] = ["ir.checkState", "=", TalentState::ZX_PASS];
  118. break;
  119. case 4: //公示通过
  120. $where[] = ["ir.checkState", "=", TalentState::ANNOUNCED];
  121. break;
  122. case 5:
  123. case 8: //公布预览
  124. $where[] = ["ir.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  125. break;
  126. case 6:
  127. $where[] = ["ir.checkState", "=", TalentState::PUBLISH_PASS];
  128. break;
  129. }
  130. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  131. $count = IntegralRecord::alias("ir")->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")->where($where)->count();
  132. $list = IntegralRecord::alias("ir")->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
  133. ->where($where)
  134. ->limit($offset, $limit)
  135. ->order("ir.createTime " . $order)->field("ir.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  136. foreach ($list as &$item) {
  137. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
  138. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  139. }unset($item);
  140. return ["total" => $count, "rows" => $list];
  141. }
  142. public static function getListByProcess($params) {
  143. $process = $params["process"] ?: 1;
  144. $where = [];
  145. switch ($process) {
  146. case 1://初审阶段
  147. switch ($params["checkState"]) {
  148. case 1://待审核
  149. $where[] = ["ir.checkState", "=", IntegralState::SUBMIT];
  150. $where[] = ["tl.state", "=", IntegralState::SUBMIT];
  151. break;
  152. case 2://驳回
  153. $where[] = ["tl.new_state", "in", [IntegralState::SAVE]];
  154. $where[] = ["tl.state", "in", [IntegralState::VERIFY_REJECT]];
  155. break;
  156. case 3:
  157. //审核失败
  158. $where[] = ["ir.checkState", "in", [IntegralState::VERIFY_FAIL]];
  159. break;
  160. default:
  161. $where[] = ["tl.state", "in", [IntegralState::SUBMIT, IntegralState::VERIFY_REJECT, IntegralState::VERIFY_FAIL]];
  162. }
  163. break;
  164. case 2://复审阶段
  165. switch ($params["checkState"]) {
  166. case 1://待审核
  167. $where[] = ["tl.state", "=", IntegralState::VERIFY_PASS];
  168. break;
  169. case 3:
  170. //审核失败
  171. $where[] = ["tl.state", "in", [IntegralState::VERIFY_FAIL]];
  172. break;
  173. default:
  174. $where[] = ["tl.state", "in", [IntegralState::VERIFY_PASS, IntegralState::REVERIFY_FAIL]];
  175. }
  176. break;
  177. case 3://复审后征信公示等状态
  178. if ($params["checkState"]) {
  179. $where[] = ["ir.checkState", "=", $params["checkState"]];
  180. } else {
  181. $where[] = ["ir.checkState", "in", [IntegralState::REVERIFY_PASS, IntegralState::ZX_PASS, IntegralState::ZX_FAIL, IntegralState::ANNOUNCED, IntegralState::ANNOUNCED_REVERIFY_PASS, IntegralState::ANNOUNCED_REVERIFY_FAIL, IntegralState::PUBLISH_PASS, IntegralState::PUBLISH_FAIL, IntegralState::SUCCESS]];
  182. }
  183. break;
  184. }
  185. $order = $params["order"] ?: "desc";
  186. $offset = $params["offset"] ?: 0;
  187. $limit = $params["limit"] ?: 10;
  188. $where[] = ["delete", "=", 0];
  189. if ($params["apply_year"]) {
  190. $where[] = ["b.batch", "like", "%{$params['apply_year']}%"];
  191. }
  192. if ($params["name"]) {
  193. $where[] = ["ir.name", "like", "%{$params['name']}%"];
  194. }
  195. if ($params["card_number"]) {
  196. $where[] = ["ir.card_number", "like", "%{$params['card_number']}%"];
  197. }
  198. if ($params["phone"]) {
  199. $where[] = ["ir.phone", "like", "%{$params['phone']}%"];
  200. }
  201. if ($params["email"]) {
  202. $where[] = ["ir.email", "like", "%{$params['email']}%"];
  203. }
  204. if ($params["shareholder"]) {
  205. $where[] = ["ir.shareholder", "=", $params['shareholder']];
  206. }
  207. $count = IntegralRecord::alias("ir")->where($where)
  208. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  209. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  210. ->count();
  211. $list = IntegralRecord::alias("ir")->where($where)
  212. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  213. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  214. ->field("ir.*,b.batch as apply_year,tl.state as real_state,tl.last_state,if(ir.updateTime is not null,ir.updateTime,ir.createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
  215. foreach ($list as $key => $item) {
  216. $tmp_items = [];
  217. foreach ($item["detail"] as $_item) {
  218. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  219. $tmp_items[] = sprintf("%s(%s%s)", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"]);
  220. }
  221. $list[$key]["details"] = implode(";", $tmp_items);
  222. $list[$key]["type"] = session("user")["type"];
  223. //$last_log = TalentLogApi::getLastLog($item["id"], \app\common\state\ProjectState::INTEGRAL);
  224. //$list[$key]["real_state"] = $last_log["state"];
  225. //$list[$key]["last_state"] = $last_log["last_state"];
  226. }
  227. return ["total" => $count, "rows" => $list];
  228. }
  229. public static function checkIsEditable($id) {
  230. $info = self::getOne($id);
  231. if (!$info || !in_array($info["checkState"], [0, IntegralState::SAVE]))
  232. return false;
  233. return true;
  234. }
  235. static public function chkIsOwner($id, $uid) {
  236. $info = self::getOne($id);
  237. if ($info["enterprise_id"] != $uid)
  238. return null;
  239. return $info;
  240. }
  241. /**
  242. * 导出
  243. * @param type $process
  244. * @param type $params
  245. * @return type
  246. */
  247. public static function getExportDatas($process, $params) {
  248. $where[] = [];
  249. //特殊字段处理
  250. $fields = [];
  251. $fields[] = "ir.id";
  252. foreach ($params as $param) {
  253. if (!in_array($param, ["enterpriseName", "street", "checkMsg", "project", "year"])) {
  254. $fields[] = "ir." . $param;
  255. }
  256. }
  257. $fields[] = "e.name as enterpriseName";
  258. $fields[] = "e.street";
  259. $fields[] = "tl.description as checkMsg";
  260. $fields[] = "b.batch as year";
  261. if (in_array("card_type", $params)) {
  262. $cardTypes = DictApi::selectByParentCode("card_type");
  263. }
  264. if (in_array("street", $params)) {
  265. $streets = DictApi::selectByParentCode("street");
  266. }
  267. $sex = [1 => "男", 2 => "女"];
  268. $where = [];
  269. $where[] = ["e.type", "=", session("user")["type"]];
  270. switch ($process) {
  271. case 1:
  272. $where = "ir.checkState in (" . IntegralState::SUBMIT . "," . IntegralState::VERIFY_FAIL . ")";
  273. break;
  274. case 2:
  275. $where = "ir.checkState in (" . IntegralState::VERIFY_PASS . "," . IntegralState::REVERIFY_FAIL . ")";
  276. break;
  277. case 3:
  278. $where = "ir.checkState >= " . IntegralState::REVERIFY_PASS;
  279. break;
  280. }
  281. $list = IntegralRecord::alias("ir")
  282. ->field($fields)
  283. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
  284. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  285. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  286. //->leftJoin("new_talent_checklog tl", "tl.mainId=ti.id and tl.id=(select id from new_talent_checklog where mainId=ti.id and `step` is null and active=1 and typeFileId is null order by createTime desc limit 1)")
  287. ->whereRaw($where)
  288. ->select()->toArray();
  289. foreach ($list as &$item) {
  290. $item["card_type"] = $cardTypes[$item["card_type"]];
  291. $item["street"] = $streets[$item["street"]];
  292. $item["sex"] = $sex[$item["sex"]];
  293. $item["checkState"] = IntegralState::getStateName($item["checkState"]);
  294. $detail = \app\common\model\IntegralDetail::where("record_id", $item["id"])->select();
  295. $tmp_items = [];
  296. foreach ($detail as $_item) {
  297. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  298. $tmp_items[] = sprintf("%s(%s%s)", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"]);
  299. }
  300. $item["project"] = implode(";", $tmp_items);
  301. }unset($item);
  302. return $list;
  303. }
  304. /**
  305. * 计算积分
  306. * @param type $enterpriseId 企业id
  307. * @param type $cardType 证件类型
  308. * @param type $cardNumber 证件号码
  309. * @param type $itemId 标准id
  310. * @param type $amount 达成数额
  311. * @return \stdClass 完整积分记录对象
  312. */
  313. public static function calIntegral($enterpriseId, $cardType, $cardNumber, $itemId, $amount) {
  314. $returnObj = new \stdClass();
  315. $returnObj->amount = $amount;
  316. $item = getCacheById("IntegralItem", $itemId);
  317. $projectRemainderPoints = 0; //项目剩余总上限
  318. $itemRemainderPoints = 0; //标准剩余总上限
  319. $points = 0; //当前可获得积分
  320. if ($item) {
  321. $project = getCacheById("IntegralProject", $item["projectId"]);
  322. $projectRemainderPoints = $project["max"]; //初始化项目可获得剩余积分
  323. $itemRemainderPoints = $item["max"]; //初始化标准可获得剩余积分
  324. if ($project["limit"] == 1) {
  325. //项目下所有规则总上限
  326. $where = [];
  327. $where[] = ["r.enterprise_id", "=", $enterprise_id];
  328. $where[] = ["r.card_type", "=", $cardType];
  329. $where[] = ["r.card_number", "=", $cardNumber];
  330. $where[] = ["r.checkState", ">=", IntegralState::SUCCESS];
  331. $where[] = ["i.projectId", "=", $project["id"]];
  332. if ($project["yearly"] == 1) {
  333. //年度重置只算当年度
  334. $startTime = date("Y-01-01 00:00:00");
  335. $endTime = date("Y-12-31 23:59:59");
  336. $where[] = ["r.createTime", "between", [$startTime, $endTime]];
  337. $returnObj->projectYearly = 1;
  338. }
  339. $totalPoints = Db::table("new_integral_detail")->alias("d")->leftJoin("new_integral_record r", "r.id=d.record_id")->leftJoin("new_integral_item i", "i.id=d.item_id")->where($where)->sum("d.point");
  340. $projectRemainderPoints -= $totalPoints;
  341. $returnObj->projectMaxPoints = $project["max"];
  342. $returnObj->projectRemainderPoints = $projectRemainderPoints;
  343. }
  344. if ($item["limit"] == 1) {
  345. //规则上限
  346. $where = [];
  347. $where[] = ["r.enterprise_id", "=", $enterprise_id];
  348. $where[] = ["r.card_type", "=", $cardType];
  349. $where[] = ["r.card_number", "=", $cardNumber];
  350. $where[] = ["r.checkState", ">=", IntegralState::SUCCESS];
  351. $where[] = ["d.item_id", "=", $itemId];
  352. if ($item["yearly"] == 1) {
  353. //年度重置只算当年度
  354. $startTime = date("Y-01-01 00:00:00");
  355. $endTime = date("Y-12-31 23:59:59");
  356. $where[] = ["r.createTime", "between", [$startTime, $endTime]];
  357. $returnObj->itemYearly = 1;
  358. }
  359. $totalPoints = Db::table("new_integral_detail")->alias("d")->leftJoin("new_integral_record r", "r.id=d.record_id")->where($where)->sum("d.point");
  360. $itemRemainderPoints -= $totalPoints;
  361. $returnObj->itemMaxPoints = $item["max"];
  362. $returnObj->itemRemainderPoints = $itemRemainderPoints;
  363. }
  364. $where = [];
  365. $where[] = ["r.enterprise_id", "=", $enterprise_id];
  366. $where[] = ["r.card_type", "=", $cardType];
  367. $where[] = ["r.card_number", "=", $cardNumber];
  368. $where[] = ["r.checkState", ">=", IntegralState::SUCCESS];
  369. $where[] = ["d.item_id", "=", $itemId];
  370. $fstGain = Db::table("new_integral_detail")->alias("d")->leftJoin("new_integral_record r", "r.id=d.record_id")->where($where)->field("d.*")->order("createTime asc")->find();
  371. if ($item["stepNeedAmount"] && $item["stepGainPoints"]) {
  372. $returnObj->stepNeedAmount = $item["stepNeedAmount"];
  373. $returnObj->stepGainPoints = $item["stepGainPoints"];
  374. if ($fstGain) {
  375. $returnObj->fstGainRecordId = $fstGain["record_id"];
  376. $returnObj->fstGainDetailId = $fstGain["id"];
  377. //有配置增量积分
  378. if ($item["stepIsYear"] == 1) {
  379. //较上年度增量
  380. $where = [];
  381. $where[] = ["r.enterprise_id", "=", $enterprise_id];
  382. $where[] = ["r.card_type", "=", $cardType];
  383. $where[] = ["r.card_number", "=", $cardNumber];
  384. $where[] = ["r.checkState", ">=", IntegralState::SUCCESS];
  385. $where[] = ["d.item_id", "=", $itemId];
  386. $startTime = date("Y-m-d 00:00:00", strtotime("first day of last year"));
  387. $endTime = date("Y-12-31 23:59:59", strtotime("last day of last year"));
  388. $where[] = ["r.createTime", "between", [$startTime, $endTime]];
  389. $lastYearTotalAmount = Db::table("new_integral_detail")->alias("d")->leftJoin("new_integral_record r", "r.id=d.record_id")->where($where)->sum("d.amount");
  390. $newGainAmount = $amount - $lastYearTotalAmount;
  391. $times = floor($newGainAmount / $item["stepNeedAmount"]);
  392. $returnObj->stepIsYear = 1;
  393. $returnObj->lastYearTotalAmount = $lastYearTotalAmount;
  394. $returnObj->newGainAmount = $newGainAmount;
  395. } else {
  396. $times = floor($amount / $item["stepNeedAmount"]);
  397. $returnObj->stepAmount = $amount;
  398. }
  399. $points = $item["stepGainPoints"] * $times;
  400. $returnObj->times = $times;
  401. $returnObj->points = $returnObj->stepPoints = $points;
  402. } else {
  403. //首次
  404. $returnObj->fstNeedAmount = $item["fstNeedAmount"];
  405. $returnObj->fstGainPoints = $item["fstGainPoints"];
  406. $returnObj->fstAmount = $amount >= $item["fstNeedAmount"] ? $item["fstNeedAmount"] : $amount;
  407. $returnObj->fstPoints = $amount >= $item["fstNeedAmount"] ? $item["fstGainPoints"] : 0;
  408. if ($item["stepIsYear"] != 1) {
  409. //未设置较上年度增量时,首次还需计算增量部分
  410. $stepAmount = $amount - $item["fstNeedAmount"];
  411. if ($stepAmount > 0) {
  412. $times = floor($stepAmount / $item["stepNeedAmount"]);
  413. $returnObj->stepAmount = $stepAmount;
  414. $returnObj->times = $times;
  415. $returnObj->stepPoints = $item["stepGainPoints"] * $times;
  416. }
  417. } else {
  418. $returnObj->stepIsYear = 1;
  419. }
  420. $returnObj->points = $returnObj->stepPoints ? $returnObj->fstPoints + $returnObj->stepPoints : $returnObj->fstPoints;
  421. }
  422. } else {
  423. //仅首次可得积分
  424. if ($fstGain) {
  425. $returnObj->points = 0;
  426. $returnObj->msg = "仅首次能获得积分";
  427. } else {
  428. $returnObj->fstNeedAmount = $item["fstNeedAmount"];
  429. $returnObj->fstGainPoints = $item["fstGainPoints"];
  430. $returnObj->fstAmount = $amount >= $item["fstNeedAmount"] ? $item["fstNeedAmount"] : $amount;
  431. $returnObj->points = $returnObj->fstPoints = $amount >= $item["fstNeedAmount"] ? $item["fstGainPoints"] : 0;
  432. }
  433. }
  434. $point1 = $project["limit"] == 1 ? ($returnObj->projectRemainderPoints > $returnObj->points ? $returnObj->points : $returnObj->projectRemainderPoints) : $returnObj->points;
  435. $point2 = $item["limit"] == 1 ? ($returnObj->itemRemainderPoints > $returnObj->points ? $returnObj->points : $returnObj->itemRemainderPoints) : $returnObj->points;
  436. $returnObj->theoretical = $returnObj->points; //理论值
  437. $returnObj->points = $point1 > $point2 ? $point2 : $point1; //实际值,当有限额时,会与理论值有偏差
  438. }
  439. return $returnObj;
  440. }
  441. }