PageRenderTime 59ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/KPPW/task/reward/control/admin/model_task.php

https://github.com/kazaff/destoon
PHP | 248 lines | 208 code | 40 blank | 0 comment | 32 complexity | 3771518e5e3b56f7a66bbef5a2f051b9 MD5 | raw file
  1. <?php
  2. if(!defined('ADMIN_KEKE')) {
  3. exit('Access Denied');
  4. }
  5. if ($op == 'del')
  6. {
  7. $task_id = $task_id?$task_id:Func_comm_class::adminshowmessage("错误的参数","index.php?do=model&model_id=$model_id&view=list");
  8. $task_obj = new Keke_witkey_task_class();
  9. $task_obj->setWhere("task_id='{$task_id}'");
  10. $task_arr = $task_obj->query_keke_witkey_task();
  11. if (in_array($task_arr[0]['task_status'],array(1,2,3,4)))
  12. {
  13. Func_comm_class::adminshowmessage("您不能删除当前状态下的任务","index.php?do=model&model_id=$model_id&view=list");
  14. }
  15. $task_obj->setWhere("task_id='{$task_id}'");
  16. $file_obj = new Keke_witkey_file_class();
  17. $file_arr = $file_obj->query_keke_witkey_file();
  18. $file_obj->setWhere("task_id='{$task_id}'");
  19. $file_obj->del_keke_witkey_file();
  20. $backup_patch = S_ROOT.'./data/uploads/';
  21. foreach ($file_arr as $file){
  22. if(file_exists($file['filename'])){
  23. chmod($backup_patch,777);
  24. chmod($file['filename'],777);
  25. unlink($backup_patch.$file['filename']);
  26. }
  27. }
  28. $task_obj->setWhere("task_id='{$task_id}'");
  29. $task_obj->del_keke_witkey_task();
  30. Func_comm_class::adminSystemLog("删除任务$task_id");
  31. Func_comm_class::notify_user("任务删除通知","您的任务 <b><a href=\"index.php?do=task&task_id={$task_arr[0]['task_id']}\">{$task_arr[0]['task_title']}</a></b> 被删除,如有疑问请联系本站客服",$task_arr[0]['uid'],$task_arr[0]['username']);
  32. $ttype = $task_arr[0]['model_id']==2?"tender":"reward";
  33. Func_comm_class::adminshowmessage("任务删除成功","index.php?do=model&model_id=$model_id&view=list");
  34. }
  35. if ($op == 'setstatus1')
  36. {
  37. $task_id = $task_id?$task_id:Func_comm_class::adminshowmessage("错误的参数","index.php?do=model&model_id=$model_id&view=list");
  38. $task_obj = new Keke_witkey_task_class();
  39. $task_obj->setWhere("task_id='{$task_id}'");
  40. $task_arr = $task_obj->query_keke_witkey_task();
  41. if ($task_arr[0]['task_status']!=1){
  42. Func_comm_class::adminshowmessage("该任务并不在待审核状态","index.php?do=model&model_id=$model_id&view=list");
  43. }
  44. $task_obj->setWhere("task_id='{$task_id}'");
  45. $task_obj->setTask_status(2);
  46. $xs_task_config = Cache_ext_Class::getConfig('xs_task');
  47. $task_day = 0;
  48. $end_time = $task_arr[0]['end_time']-$task_arr[0]['start_time']+time();
  49. $task_obj ->setEnd_time($end_time);
  50. $task_obj->edit_keke_witkey_task();
  51. Func_comm_class::adminSystemLog("审核任务$task_id");
  52. if ($task_arr[0]['model_id']==1){
  53. Func_comm_class::feed_add('<a href="index.php?do=space&member_id='.$task_arr[0]['uid'].'" target="_blank">'.$task_arr[0]['username'].'</a>发布了任务 <a target="_blank" href="index.php?do=task&task_id='.$task_arr[0]['task_id'].'">'.$task_arr[0]['task_title'].'</a>',$task_arr[0]['uid'],$task_arr[0]['username'],'pub_task',$task_arr[0]['task_id']);
  54. $message_obj = new Message_Class();
  55. if ($message_obj->validate('task_auth_success_isnotice')){
  56. $message_obj->setUid($task_arr[0]['uid']);
  57. $message_obj->setUsername($task_arr[0]['username']);
  58. $message_obj->setValue('任务编号',$task_arr[0]['task_id']);
  59. $message_obj->setValue('任务标题',$task_arr[0]['task_title']);
  60. $url= "<a href =\'index.php?do=task&task_id={$task_arr[0][task_id]}\' target=\'_blank\' >{$task_arr[0]['task_title']}</a>";
  61. $message_obj->setValue ( '任务链接', $url );
  62. $message_obj->setValue('开始时间',date('Y-m-d H:i:s',time()));
  63. $message_obj->setValue('结束时间',date('Y-m-d H:i:s',$end_time));
  64. $message_obj->setTitle('任务通过审核');
  65. $message_obj->send();
  66. }
  67. Func_comm_class::adminshowmessage("任务审核成功","index.php?do=model&model_id=$model_id&view=list");}
  68. else {
  69. Func_comm_class::feed_add('<a href="index.php?do=space&member_id='.$task_arr[0]['uid'].'" target="_blank">'.$task_arr[0]['username'].'</a>发布了任务 <a target="_blank" href="index.php?do=task&task_id='.$task_arr[0]['task_id'].'">'.$task_arr[0]['task_title'].'</a>',$task_arr[0]['uid'],$task_arr[0]['username'],'pub_task',$task_arr[0]['task_id']);
  70. Func_comm_class::adminshowmessage("任务审核成功","index.php?do=model&model_id=$model_id&view=list");
  71. }
  72. }
  73. if ($op == 'setstatus5'){
  74. $task_id = $task_id?$task_id:Func_comm_class::adminshowmessage("错误的参数","index.php?do=task&view=rewardlist");
  75. $task_obj = new Keke_witkey_task_class();
  76. $task_obj->setWhere("task_id='{$task_id}'");
  77. $task_arr = $task_obj->query_keke_witkey_task();
  78. if ($task_arr[0]['task_status']!=1){
  79. Func_comm_class::adminshowmessage("该任务并不在待审核状态","index.php?do=model&model_id=$model_id&view=list");
  80. }
  81. $task_obj->setWhere("task_id='{$task_id}'");
  82. $task_obj->setTask_status(10);
  83. if(!$task_arr[0]['uid'])
  84. {
  85. Func_comm_class::adminshowmessage("发布者信息错误","index.php?do=model&model_id=$model_id&view=list");
  86. }
  87. $user_obj = new Keke_witkey_space_class();
  88. $user_info = new Keke_witkey_space_class();
  89. $user_info = $user_obj->setWhere("uid='{$task_arr[0]['uid']}'");
  90. $user_info = $user_info[0];
  91. $return_cash =0;
  92. $flag = false;
  93. $fina_obj = new Keke_witkey_finance_class();
  94. $fina_obj->setFina_type(2);
  95. $fina_obj->setFina_narrate(8);
  96. $fina_obj->setUid($task_arr[0]['uid']);
  97. $fina_obj->setUsername($task_arr[0]['username']);
  98. $fina_obj->setTask_id($task_arr[0]['task_id']);
  99. $fina_obj->setFina_cash($task_arr[0]['cash_cost']);
  100. $fina_obj->setFina_credit($task_arr[0]['credit_cost']);
  101. $fina_obj->setFina_time(time());
  102. if ($task_arr[0]['cash_cost'])
  103. {
  104. $fina_obj->setUser_balance($user_info['balance']+$task_arr[0]['cash_cost']);
  105. db_factory::execute("update ".TABLEPRE."witkey_space set balance=balance+{$task_arr[0]['cash_cost']} where uid='{$task_arr[0]['uid']}'");
  106. }
  107. if ($task_arr[0]['credit_cost'])
  108. {
  109. $fina_obj->setUser_credit($user_info['credit']+$task_arr[0]['credit_cost']);
  110. db_factory::execute("update ".TABLEPRE."witkey_space set credit=credit+{$task_arr[0]['credit_cost']} where uid='{$task_arr[0]['uid']}'");
  111. }
  112. $fina_obj->create_keke_witkey_finance();
  113. if ($task_arr[0]['is_prom'])
  114. {
  115. $user_info = Func_comm_class::getuserinfo($task_arr[0]['uid']);
  116. $fina_obj2 = new Keke_witkey_finance_class();
  117. $fina_obj2->setFina_type(2);
  118. $fina_obj2->setFina_narrate(9);
  119. $fina_obj2->setUid($task_arr[0]['uid']);
  120. $fina_obj2->setUsername($task_arr[0]['username']);
  121. $fina_obj2->setTask_id($task_arr[0]['task_id']);
  122. $fina_obj2->setFina_cash($task_arr[0]['prom_cash']);
  123. $fina_obj2->setFina_credit($task_arr[0]['prom_credit']);
  124. $fina_obj2->setUser_balance($user_info['balance']+$task_arr[0]['prom_cash']);
  125. $fina_obj2->setUser_credit($user_info['credit']+$task_arr[0]['prom_credit']);
  126. $fina_obj2->setFina_time(time());
  127. $fina_obj2->create_keke_witkey_finance();
  128. db_factory::execute("update ".TABLEPRE."witkey_space set balance=balance+".($task_arr[0]['prom_cash']+0).",credit=credit+".($task_arr[0]['prom_credit']+0)." where uid='{$task_arr[0]['uid']}'");
  129. }
  130. $task_obj->edit_keke_witkey_task();
  131. Func_comm_class::adminSystemLog("否决任务$task_id的审核");
  132. $message_obj = new Message_Class();
  133. if ($message_obj->validate('task_auth_fail_isnotice')){
  134. $message_obj->setUid($task_arr[0]['uid']);
  135. $message_obj->setUsername($task_arr[0]['username']);
  136. $message_obj->setValue('任务编号',$task_arr[0]['task_id']);
  137. $message_obj->setValue('任务标题',$task_arr[0]['task_title']);
  138. $url= "<a href =\'index.php?do=task&task_id={$task_arr[0][task_id]}\' target=\'_blank\' >{$task_arr[0]['task_title']}</a>";
  139. $message_obj->setValue ( '任务链接', $url );
  140. $message_obj->setTitle('任务未通过审核');
  141. $message_obj->send();
  142. }
  143. if ($task_arr[0]['model_id']==1){
  144. Func_comm_class::adminshowmessage("操作成功","index.php?do=model&model_id=$model_id&view=list");}
  145. else {Func_comm_class::adminshowmessage("操作成功","index.php?do=model&model_id=$model_id&view=list");}
  146. }
  147. if ($op == 'setstatus6')
  148. {
  149. $task_id = $task_id?$task_id:Func_comm_class::adminshowmessage("错误的参数","index.php?do=model&model_id=$model_id&view=list");
  150. $task_obj = new Keke_witkey_task_class();
  151. $task_obj->setWhere("task_id='{$task_id}'");
  152. $task_arr = $task_obj->query_keke_witkey_task();
  153. if (!in_array($task_arr[0]['task_status'],array(2,3,4))){
  154. Func_comm_class::adminshowmessage("该任务无法冻结","index.php?do=model&model_id=$model_id&view=list");
  155. }
  156. $task_obj->setWhere("task_id='{$task_id}'");
  157. $task_obj->setTask_status(6);
  158. $task_frost_obj = new Keke_witkey_task_frost_class();
  159. $task_frost_obj->setTask_id($task_id);
  160. $task_frost_obj->setFrost_status($task_arr[0]['task_status']);
  161. $task_frost_obj->setFrost_time(time('now()'));
  162. $task_frost_obj->setAdmin_uid($myinfo_arr['uid']);
  163. $task_frost_obj->setAdmin_username($myinfo_arr['username']);
  164. $task_frost_obj->create_keke_witkey_task_frost();
  165. $task_obj->edit_keke_witkey_task();
  166. Func_comm_class::adminSystemLog("冻结任务$task_id");
  167. $message_obj = new Message_Class();
  168. if ($message_obj->validate('task_freeze_isnotice')){
  169. $message_obj->setUid($task_info['uid']);
  170. $message_obj->setUsername($task_info['username']);
  171. $message_obj->setValue("任务标题",$task_info['task_title']);
  172. $url= "<a href =\'index.php?do=task&task_id={$task_arr[0][task_id]}\' target=\'_blank\' >{$task_arr[0]['task_title']}</a>";
  173. $message_obj->setValue ( '任务链接', $url );
  174. $message_obj->setValue("任务编号",$task_info['task_id']);
  175. $message_obj->setTitle('任务冻结');
  176. $message_obj->send();
  177. }
  178. if ($task_arr[0]['model_id']==1){
  179. Func_comm_class::adminshowmessage("任务冻结成功","index.php?do=model&model_id=$model_id&view=list");}
  180. else {Func_comm_class::adminshowmessage("任务冻结成功","index.php?do=model&model_id=$model_id&view=list");}
  181. }
  182. if ($op == 'restore')
  183. {
  184. $task_id = $task_id?$task_id:Func_comm_class::adminshowmessage("错误的参数","index.php?do=model&model_id=$model_id&view=list");
  185. $task_obj = new Keke_witkey_task_class();
  186. $task_obj->setWhere("task_id='{$task_id}'");
  187. $task_arr = $task_obj->query_keke_witkey_task();
  188. if ($task_arr[0]['task_status']!=6){
  189. Func_comm_class::adminshowmessage("该任务不在冻结状态","index.php?do=model&model_id=$model_id&view=list");
  190. }
  191. $task_obj->setWhere("task_id='{$task_id}'");
  192. $task_frost_obj = new Keke_witkey_task_frost_class();
  193. $task_frost_obj->setWhere("task_id = '{$task_id}' order by frost_time desc limit 0,1");
  194. $frost_arr = $task_frost_obj->query_keke_witkey_task_frost();
  195. $frost_arr = $frost_arr[0];
  196. $task_frost_obj->setRestore_time(time('now()'));
  197. $task_obj->setTask_status($frost_arr['frost_status']);
  198. $task_obj->setEnd_time( $task_arr[0]['end_time']+ (time('now()')-$frost_arr['frost_time']) );
  199. $task_obj->edit_keke_witkey_task();
  200. $task_frost_obj->setWhere("frost_id = '{$frost_arr['frost_id']}'");
  201. $task_frost_obj->edit_keke_witkey_task_frost();
  202. $task_obj->edit_keke_witkey_task();
  203. Func_comm_class::adminSystemLog("恢复任务$task_id");
  204. Func_comm_class::notify_user("任务恢复提示","您的任务 <b><a href=\"index.php?do=task&task_id={$task_arr[0]['task_id']}\">{$task_arr[0]['task_title']}</a></b> 的冻结状态已被恢复,",$task_arr[0]['uid'],$task_arr[0]['username']);
  205. if ($task_arr[0]['model_id']==1){
  206. Func_comm_class::adminshowmessage("任务已恢复","index.php?do=model&model_id=$model_id&view=list");}
  207. else {Func_comm_class::adminshowmessage("任务已恢复","index.php?do=model&model_id=$model_id&view=list");}
  208. }