1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\common\api;
- use app\common\api\DictApi;
- use app\admin\model\Enterprise;
- use think\facade\Db;
- use app\common\model\IntegralRecord;
- use app\common\state\IntegralState;
- /**
- * Description of IntegralRecordApi
- *
- * @author sgq
- */
- class IntegralRecordApi {
- public static function getOne($id) {
- return IntegralRecord::where("id", "=", $id)->find();
- }
- public static function getList($params) {
- $where = [];
- $order = $params["order"] ?: "desc";
- $offset = $params["offset"] ?: 0;
- $limit = $params["limit"] ?: 10;
- $count = IntegralRecord::where($where)->count();
- $list = IntegralRecord::where($where)->field("*,if(updateTime is not null,updateTime,createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
- foreach ($list as $key => $item) {
- var_dump($item->detail->toArray());exit();
- $list[$key]["detail"] = $item->detail();
- }
- return ["total" => $count, "rows" => $list];
- }
- public static function checkIsEditable($id) {
- $info = self::getOne($id);
- if (!$info || !in_array($info["checkState"], [0, IntegralState::SAVE]))
- return false;
- return true;
- }
- static public function chkIsOwner($id, $uid) {
- $info = self::getOne($id);
- if ($info["enterprise_id"] != $uid)
- return null;
- return $info;
- }
- }
|