ApproveService.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <?php
  2. namespace app\common\service;
  3. use app\common\constant\ApplyConstant;
  4. use app\common\constant\CommonConstant;
  5. use app\common\model\Approve;
  6. use app\common\model\ApproveApplyGoods;
  7. use app\common\model\ApproveCopy;
  8. use app\common\model\ApproveEvectionPeerUser;
  9. use app\common\model\ApproveInfo;
  10. use app\common\model\ApproveInfoLog;
  11. use app\common\model\ApproveMaintain;
  12. use app\common\model\ApproveStockGoods;
  13. use app\common\model\ApproveUseGoods;
  14. use app\common\model\GoodsStock;
  15. use app\common\model\GoodsStockLog;
  16. use app\common\model\User;
  17. use think\Db;
  18. use think\Exception;
  19. /**
  20. * 审批服务类
  21. */
  22. class ApproveService
  23. {
  24. /**
  25. * 审批待处理统计
  26. *
  27. * @param mixed $user 用户信息
  28. **/
  29. public static function get_count(User $user)
  30. {
  31. $get_module_list = CommonConstant::get_module_list();
  32. $modules = array_keys($get_module_list);
  33. $userid = $user['userid'];
  34. $ids = Approve::where('status', CommonConstant::STATUS_2)
  35. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  36. ->where('approve_user', $userid)
  37. ->column('info_id');
  38. $key = [];
  39. if ($ids) {
  40. $list = ApproveInfo::field('module,count(id) as number')
  41. ->where('id', 'in', $ids)
  42. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  43. ->where('module', 'in', $modules)
  44. ->where('status', CommonConstant::STATUS_2)
  45. ->group('module')
  46. ->select()
  47. ->toArray();
  48. $key = $list ? array_column($list, null, 'module') : [];
  49. }
  50. $data = [];
  51. foreach ($get_module_list as $module => $value) {
  52. $module_text = $value;
  53. $number = 0;
  54. if (array_key_exists($module, $key)) {
  55. $number = $key[$module]['number'];
  56. }
  57. $params = compact('module', "module_text", 'number');
  58. $data[] = $params;
  59. }
  60. return $data;
  61. }
  62. /**
  63. * 审批列表
  64. *
  65. * @param integer $status 处理状态
  66. * @param integer $module 模块类型
  67. * @param string $start_time 申请开始时间
  68. * @param string $end_time 申请结束时间
  69. * @param string $search 搜索
  70. * @param integer $offset 起始位置
  71. * @param integer $length 查询数量
  72. * @param mixed $user 用户信息
  73. **/
  74. public static function get_list($status, $module, $start_time, $end_time, $search, $offset, $length, $user)
  75. {
  76. if (!in_array($status, [1, 2, 3])) {
  77. return [];
  78. }
  79. if ($module && !array_key_exists($module, CommonConstant::get_module_list())) {
  80. return [];
  81. }
  82. $userids = $search && !is_numeric($search) ? User::where('name', 'like', '%' . $search . '%')->column('userid') : [];
  83. $userid = $user['userid'];
  84. $group = $status == 3 ? 'approve_copy' : 'approve';
  85. if ($group == 'approve') {
  86. $model = Approve::class;
  87. $field = 'id as approve_id,info_id,status,create_at';
  88. } else {
  89. $model = ApproveCopy::class;
  90. $field = 'id as approve_id,info_id,create_at';
  91. }
  92. $aliasName = 'approve.';
  93. $jobName = 'approveInfo.';
  94. $joinField = 'module,user_id,apply_user_id,order_no,apply_date,reason,type,desc,start_time,end_time';
  95. $field = CommonService::getAliasField($field, $aliasName);
  96. $joinField = CommonService::getAliasField($joinField, $jobName);
  97. $field = implode(',', array_merge($field, $joinField));
  98. $list = $model::alias('approve')
  99. ->field($field)
  100. ->when($status, function ($query) use ($aliasName, $status) {
  101. if ($status == 1) {
  102. $query->where($aliasName . 'status', CommonConstant::STATUS_2);
  103. // $query->where($aliasName . 'status', 'in', [CommonConstant::STATUS_1, CommonConstant::STATUS_2]);
  104. }
  105. if ($status == 2) {
  106. $query->where($aliasName . 'status', 'in', [CommonConstant::STATUS_3, CommonConstant::STATUS_4]);
  107. }
  108. })
  109. ->where($aliasName . 'is_deleted', CommonConstant::IS_DELETED_0)
  110. ->when($group, function ($query) use ($aliasName, $group) {
  111. if ($group == 'approve') {
  112. $query->where($aliasName . 'group', CommonConstant::IS_WHO_0);
  113. }
  114. })
  115. ->when($group, function ($query) use ($aliasName, $group) {
  116. if ($group == 'approve') {
  117. $query->where($aliasName . 'state', CommonConstant::IS_WHO_0);
  118. }
  119. })
  120. ->where($aliasName . 'approve_user', $userid)
  121. ->where($jobName . 'is_deleted', CommonConstant::IS_DELETED_0)
  122. ->when($module, function ($query) use ($jobName, $module) {
  123. $query->where($jobName . 'module', 'in', $module);
  124. })
  125. ->when(!empty($start_time) && !empty($end_time), function ($query) use ($aliasName, $start_time, $end_time) {
  126. $query->where($aliasName . 'create_at', 'BETWEEN', [$start_time, $end_time]);
  127. })
  128. ->when($userids, function ($query) use ($jobName, $userids) {
  129. $query->where($jobName . 'user_id', 'in', $userids);
  130. })
  131. ->when($search, function ($query) use ($search, $userids) {
  132. if (!$userids) {
  133. if (!is_numeric($search)) {
  134. $query->where('order_no|reason', 'like', '%' . $search . '%');
  135. } else {
  136. $query->where('order_no', 'like', '%' . $search . '%');
  137. }
  138. }
  139. })
  140. ->join('__APPROVE_INFO__ approveInfo', 'approve.info_id = approveInfo.id', 'INNER');
  141. if ($status == 1) {
  142. // 待处理(待审批 审批中) 才关联 审批人信息
  143. $list->with([
  144. 'approveInfoUser' => function ($query) {
  145. $query->field('userid,name');
  146. },
  147. 'approveOne' => function ($query) {
  148. $query->field('id,info_id,status,approve_user')
  149. ->where('status', CommonConstant::STATUS_2)
  150. ->where('group', CommonConstant::IS_WHO_0)
  151. ->where('state', CommonConstant::IS_WHO_0)
  152. ->with([
  153. 'user' => function ($query) {
  154. $query->field('userid,name');
  155. }
  156. ]);
  157. }
  158. ]);
  159. } else {
  160. $list->with([
  161. 'approveInfoUser' => function ($query) {
  162. $query->field('userid,name');
  163. }
  164. ]);
  165. }
  166. $list = $list->order('approve_id desc')
  167. ->limit($offset, $length)
  168. ->select();
  169. return self::get_array($list);
  170. }
  171. public static function get_array($list)
  172. {
  173. $apply_goods_info_ids = [];
  174. $stock_goods_info_ids = [];
  175. $use_goods_info_ids = [];
  176. $peer_user_info_ids = [];
  177. $apply_goods_list = [];
  178. $stock_goods_list = [];
  179. $use_goods_list = [];
  180. $peer_user_list = [];
  181. foreach ($list as $value) {
  182. $module = $value['module'];
  183. switch ($module) {
  184. case CommonConstant::MODULE_1:
  185. if ($value['type'] == ApplyConstant::TYPE_1) {
  186. $apply_goods_info_ids[] = $value['info_id'];
  187. }
  188. break;
  189. case CommonConstant::MODULE_3:
  190. $stock_goods_info_ids[] = $value['info_id'];
  191. break;
  192. case CommonConstant::MODULE_4:
  193. $use_goods_info_ids[] = $value['info_id'];
  194. break;
  195. case CommonConstant::MODULE_5:
  196. $peer_user_info_ids[] = $value['info_id'];
  197. break;
  198. }
  199. }
  200. if ($apply_goods_info_ids) {
  201. $apply_goods_list = ApproveApplyGoods::field('id,info_id,goods_name')
  202. ->where('info_id', 'in', $apply_goods_info_ids)
  203. ->select()
  204. ->toArray();
  205. }
  206. if ($stock_goods_info_ids) {
  207. $stock_goods_list = ApproveStockGoods::field('id,info_id,goods_name')
  208. ->where('info_id', 'in', $stock_goods_info_ids)
  209. ->select()
  210. ->toArray();
  211. }
  212. if ($use_goods_info_ids) {
  213. $use_goods_list = ApproveUseGoods::field('id,info_id,goods_name')
  214. ->where('info_id', 'in', $use_goods_info_ids)
  215. ->select()
  216. ->toArray();
  217. }
  218. if ($peer_user_info_ids) {
  219. $peer_user_list = ApproveEvectionPeerUser::field('id,info_id,name')
  220. ->where('info_id', 'in', $peer_user_info_ids)
  221. ->select()
  222. ->toArray();
  223. }
  224. foreach ($list as $value) {
  225. $module = $value['module'];
  226. $apply_goods = [];
  227. $stock_goods = [];
  228. $use_goods = [];
  229. $peer_user = [];
  230. switch ($module) {
  231. case CommonConstant::MODULE_1:
  232. if ($value['type'] == ApplyConstant::TYPE_1) {
  233. foreach ($apply_goods_list as $val) {
  234. if ($value['info_id'] == $val['info_id']) {
  235. $apply_goods[] = $val;
  236. }
  237. }
  238. }
  239. break;
  240. case CommonConstant::MODULE_3:
  241. foreach ($stock_goods_list as $val) {
  242. if ($value['info_id'] == $val['info_id']) {
  243. $stock_goods[] = $val;
  244. }
  245. }
  246. break;
  247. case CommonConstant::MODULE_4:
  248. foreach ($use_goods_list as $val) {
  249. if ($value['info_id'] == $val['info_id']) {
  250. $use_goods[] = $val;
  251. }
  252. }
  253. break;
  254. case CommonConstant::MODULE_5:
  255. foreach ($peer_user_list as $val) {
  256. if ($value['info_id'] == $val['info_id']) {
  257. $peer_user[] = $val;
  258. }
  259. }
  260. break;
  261. }
  262. $value['apply_goods'] = $apply_goods;
  263. $value['stock_goods'] = $stock_goods;
  264. $value['use_goods'] = $use_goods;
  265. $value['peer_user'] = $peer_user;
  266. }
  267. return $list;
  268. // $info_ids = [];
  269. // foreach ($list as $value){
  270. // if($value['status'] == CommonConstant::STATUS_1) {
  271. // $info_ids[] = $value['info_id'];
  272. // }
  273. // }
  274. // if($info_ids){
  275. // $approve_one_list = Approve::field('id,info_id,status,approve_user')
  276. // ->where('info_id','in',$info_ids)
  277. // ->where('status',CommonConstant::STATUS_2)
  278. // ->where('is_deleted', CommonConstant::IS_DELETED_0)
  279. // ->with(['user' => function ($query) {
  280. // $query->field('userid,name');
  281. // }])
  282. // ->select();
  283. // $approve_one_data = array_column($approve_one_list, null, 'info_id');
  284. // foreach ($list as $val){
  285. // if(array_key_exists($val['info_id'],$approve_one_data)){
  286. // $val['approve_one'] = $approve_one_data[$val['info_id']];
  287. // }
  288. // }
  289. // }
  290. }
  291. /**
  292. * 详情
  293. *
  294. * @param integer $id 审批ID
  295. * @param mixed $user 用户信息
  296. * @param string $group 类别:approve=审批,approve_copy=审批抄送
  297. * @param string $type 类型:detail=详情,info=信息
  298. **/
  299. public static function get_detail($id, $user, $group, $type)
  300. {
  301. $userid = $user['userid'];
  302. if ($group == 'approve') {
  303. $model = Approve::class;
  304. $field = 'id,info_id,status';
  305. } else {
  306. $model = ApproveCopy::class;
  307. $field = 'id,info_id';
  308. }
  309. $info = $model::field($field)
  310. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  311. ->when($group, function ($query) use ($group) {
  312. if ($group == 'approve') {
  313. $query->where('group', CommonConstant::IS_WHO_0);
  314. }
  315. })
  316. ->when($group, function ($query) use ($group) {
  317. if ($group == 'approve') {
  318. $query->where('state', CommonConstant::IS_WHO_0);
  319. }
  320. })
  321. ->where('approve_user', $userid)
  322. ->find($id);
  323. $data = [];
  324. $is_maintain = false;
  325. $is_feedback = false;
  326. if ($info) {
  327. $data = ApproveInfoService::get_detail($info['info_id'], $user, CommonConstant::IS_WHO_0, $type);
  328. if ($data) {
  329. $data['approve_id'] = $id;
  330. $data['approve_status'] = isset($info['status']) ? $info['status'] : CommonConstant::STATUS_1;
  331. if ($group == 'approve') {
  332. // 条件:维修模块 审批的审批状态是审批中 用户是物业主管或信息负责人 是否显示维修人员:false=不显示,true=显示 目的:审批
  333. // 条件:维修模块 审批申请的审批状态是审批同意 用户是物业主管或信息负责人 反馈状态 是否显示上传反馈结果:false=不显示,true=显示 目的:上传反馈结果
  334. if ($data['module'] == CommonConstant::MODULE_8) {
  335. if ($data['approve_status'] == CommonConstant::STATUS_2) {
  336. $is_maintain = CommonService::isMaintain($user);
  337. }
  338. if ($data['status'] == CommonConstant::STATUS_3) {
  339. // if (CommonService::isMaintain($user) && $data['maintain_user_id'] > 0 && $data['module_info']['feedback_status'] == CommonConstant::IS_WHO_0) {
  340. if (CommonService::isMaintain($user) && $data['module_info']['feedback_status'] == CommonConstant::IS_WHO_0) {
  341. $is_feedback = true;
  342. }
  343. }
  344. }
  345. }
  346. $data['is_maintain'] = $is_maintain;
  347. $data['is_feedback'] = $is_feedback;
  348. }
  349. }
  350. return $data;
  351. }
  352. /**
  353. * 操作方法
  354. *
  355. * @param integer $id 审批ID
  356. * @param array $params 数组
  357. * @param mixed $user 用户信息
  358. * @param string $type 类型:audit=审批,edit=修改,feedback=上传反馈结果
  359. **/
  360. public static function make($id, $params, $user, $type)
  361. {
  362. $userid = $user['userid'];
  363. $approve = Approve::field('id,info_id,status,approve_user,approve_flow,approve_time')
  364. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  365. ->where('group', CommonConstant::IS_WHO_0)
  366. ->where('state', CommonConstant::IS_WHO_0)
  367. ->where('approve_user', $userid)
  368. ->with([
  369. 'approveInfo' => function ($query) {
  370. $query->field('is_deleted', true);
  371. }
  372. ])
  373. ->find($id);
  374. switch ($type) {
  375. case 'audit':
  376. if (!$approve) {
  377. except('审批记录不存在或已删除');
  378. }
  379. if ($approve->status != CommonConstant::STATUS_2) {
  380. except('非待处理状态无法操作');
  381. }
  382. $info = $approve->approve_info;
  383. if (!$info) {
  384. except('申请记录不存在或已删除');
  385. }
  386. if ($info->status != CommonConstant::STATUS_2) {
  387. except('非待处理状态无法操作!');
  388. }
  389. self::audit($approve, $info, $params, $user);
  390. break;
  391. case 'edit':
  392. if (!$approve) {
  393. except('审批记录不存在或已删除');
  394. }
  395. if ($approve->status != CommonConstant::STATUS_2) {
  396. except('非待处理状态无法操作');
  397. }
  398. $info = $approve->approve_info;
  399. if (!$info) {
  400. except('申请记录不存在或已删除');
  401. }
  402. if ($info->status != CommonConstant::STATUS_2) {
  403. except('非待处理状态无法操作!');
  404. }
  405. $info->module_info;
  406. if (!$info->module_info) {
  407. except(CommonConstant::get_module_list()[$params['module']] . '记录不存在或已删除');
  408. }
  409. self::edit($approve, $info, $params);
  410. break;
  411. case 'feedback':
  412. if (!$approve) {
  413. except('审批记录不存在或已删除');
  414. }
  415. if ($approve->status != CommonConstant::STATUS_3) {
  416. except('非审批同意状态无法操作');
  417. }
  418. $info = $approve->approve_info;
  419. if (!$info) {
  420. except('申请记录不存在或已删除');
  421. }
  422. if ($info->status != CommonConstant::STATUS_3) {
  423. except('非审批同意状态无法操作!');
  424. }
  425. if ($info->module != CommonConstant::MODULE_8) {
  426. except(CommonConstant::get_module_list()[CommonConstant::MODULE_8] . '记录不存在或已删除');
  427. }
  428. $is_maintain = CommonService::isMaintain($user);
  429. if (!$is_maintain) {
  430. except('您没有权限操作');
  431. }
  432. // TODO 没有判断反馈状态
  433. // 更新维修信息
  434. $params['maintain_user_id'] = $info->maintain_user_id;
  435. $params['feedback_status'] = CommonConstant::IS_WHO_1;
  436. try {
  437. ApproveMaintain::where('info_id', $info->id)->update($params);
  438. } catch (Exception $e) {
  439. except('出现错误:' . $e->getMessage());
  440. }
  441. break;
  442. }
  443. return true;
  444. }
  445. /**
  446. * 审批
  447. *
  448. * @param mixed $approve 审批信息
  449. * @param mixed $info 申请信息
  450. * @param array $params 数组
  451. * @param mixed $user 用户信息
  452. **/
  453. public static function audit($approve, $info, $params, $user)
  454. {
  455. $status = $params['status'];
  456. $remark = $params['remark'];
  457. $maintain_user_id = $params['maintain_user_id'];
  458. $approve_time = date('Y-m-d H:i:s');
  459. $duration = time() - strtotime($approve['approve_time']);
  460. if ($status == CommonConstant::STATUS_3) {
  461. if ($info->module == CommonConstant::MODULE_3) {
  462. // 入库商品列表
  463. $goods = $info->stock_goods;
  464. if (!$goods->toArray()) {
  465. except('入库商品不存在');
  466. }
  467. }
  468. if ($info->module == CommonConstant::MODULE_8) {
  469. // 维修
  470. $is_maintain = CommonService::isMaintain($user);
  471. if ($is_maintain && !$maintain_user_id) {
  472. except('请选择维修人员');
  473. }
  474. // 维修人员ID
  475. if ($maintain_user_id > 0) {
  476. $info->maintain_user_id = $maintain_user_id;
  477. }
  478. }
  479. }
  480. if ($status == CommonConstant::STATUS_4) {
  481. if ($info->module == CommonConstant::MODULE_4) {
  482. // 领用商品列表 TODO
  483. $goods = $info->use_goods;
  484. if (!$goods->toArray()) {
  485. except('领用商品不存在');
  486. }
  487. }
  488. }
  489. Db::startTrans();
  490. try {
  491. // 更新审批申请
  492. if ($status == CommonConstant::STATUS_3) {
  493. // 审批流程批次小于审批次数 更新下一级审批状态
  494. if ($approve['approve_flow'] < $info['approve_num']) {
  495. Approve::where(['info_id' => $approve['info_id'], 'approve_flow' => $approve['approve_flow'] + 1])->update(['status' => CommonConstant::STATUS_2, 'approve_time' => $approve_time]);
  496. } else {
  497. // 审批通过
  498. $info->status = $status;
  499. if ($info->module == CommonConstant::MODULE_3) {
  500. // 入库商品列表
  501. $goodsStockSave = [];
  502. $goodsStockLog = [];
  503. foreach ($goods as $key => $val) {
  504. foreach ($val['goods_stock_text'] as $k => $v) {
  505. $goodsStockSave[] = [
  506. 'id' => $v['id'],
  507. 'stock' => ['inc', $v['stock']],
  508. ];
  509. $goodsStockLog[] = [
  510. 'info_id' => $val['info_id'],
  511. 'goods_id' => $v['goods_id'],
  512. 'stock_id' => $v['id'],
  513. 'name' => $v['name'],
  514. 'price' => $v['price'],
  515. 'stock' => $v['stock'],
  516. ];
  517. }
  518. }
  519. if ($goodsStockSave) {
  520. // 批量更新商品库存
  521. (new GoodsStock)->saveAll($goodsStockSave);
  522. }
  523. if ($goodsStockLog) {
  524. // 批量添加商品入库记录
  525. GoodsStockLog::insertAll($goodsStockLog);
  526. }
  527. }
  528. }
  529. }
  530. if ($status == CommonConstant::STATUS_4) {
  531. // 审批驳回
  532. $info->status = $status;
  533. }
  534. $info->cur_num = $info['cur_num'] + 1;
  535. $info->save();
  536. // 更新审批
  537. $approve->status = $status;
  538. $approve->approve_time = $approve_time;
  539. $approve->remark = $remark;
  540. $approve->time = $duration;
  541. $approve->time_text = get_stay_time($duration);
  542. $approve->save();
  543. Db::commit();
  544. } catch (Exception $e) {
  545. except('出现错误:' . $e->getMessage(), 2, $e);
  546. }
  547. return true;
  548. }
  549. /**
  550. * 修改
  551. *
  552. * @param mixed $approve 审批信息
  553. * @param mixed $info 申请信息
  554. * @param array $params 数组
  555. **/
  556. public static function edit($approve, $info, $params)
  557. {
  558. $data = [
  559. 'reason' => $params['reason'],
  560. 'type' => $params['type'],
  561. 'desc' => $params['desc'],
  562. 'start_time' => $params['module'] == CommonConstant::MODULE_6 ? $params['start_time'] . ' ' . $params['start_am'] : $params['start_time'],
  563. 'end_time' => $params['module'] == CommonConstant::MODULE_6 ? $params['end_time'] . ' ' . $params['end_am'] : $params['end_time'],
  564. 'apply_id' => $params['apply_id'],
  565. ];
  566. Db::startTrans();
  567. try {
  568. // 编辑对应模块
  569. $module = $params['module'];
  570. $result = ApproveInfoService::create_module($module, $params, $info->id, $info, 'update');
  571. // 编辑审批申请
  572. if ($module == CommonConstant::MODULE_9) {
  573. // 9=合同呈批 不编辑合同编号
  574. unset($data['reason']);
  575. }
  576. $info->save($data);
  577. // 保存修改记录
  578. self::create_approve_info_log($approve, $info, $result);
  579. Db::commit();
  580. } catch (Exception $e) {
  581. except('出现错误:' . $e->getMessage(), 2, $e);
  582. }
  583. return true;
  584. }
  585. /**
  586. * 保存修改记录
  587. *
  588. * @param mixed $approve 审批信息
  589. * @param mixed $info 申请信息
  590. * @param array $params 数组
  591. **/
  592. public static function create_approve_info_log($approve, $info, $params)
  593. {
  594. $info['module_info'] = $params['module_info'];
  595. $info['other'] = $params['other'] ? $params['other']['data'] : [];
  596. $data = [
  597. 'info_id' => $info->id,
  598. 'user_id' => $approve->approve_user,
  599. 'data' => json_encode($info, JSON_UNESCAPED_UNICODE),
  600. ];
  601. ApproveInfoLog::create($data);
  602. return true;
  603. }
  604. }