ImsSaleController.php 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: chenye
  5. * Date: 2018/5/28
  6. * Time: 13:18
  7. * IMS销售类
  8. */
  9. class ImsSaleController extends Controller
  10. {
  11. public $layout = false;
  12. public function actionIndex()
  13. {
  14. //读取学校试用状态接口
  15. $http = http('order/coach/school/status', 'POST', $this->authUsername);
  16. $response = formatResponse($http);
  17. if ($response['status']) {
  18. $coachStatus = $response['data']['status'];
  19. }else{
  20. Yii::app()->jump->error($response['data']);
  21. }
  22. $this->render('index',array('coachStatus'=>$coachStatus));
  23. }
  24. /**
  25. * 产品试用规则
  26. */
  27. public function actionTrial()
  28. {
  29. $result = array();
  30. //当前赛季
  31. $http = http('sys/school/year/current', 'GET', $this->authUsername);
  32. $response = formatResponse($http);
  33. //debug($response);
  34. $data = $response['data'];
  35. if ($response['status']) {
  36. if ($data) {
  37. $result['seasonName'] = $data['periodName'].$data['semesterName'];
  38. $result['startDate'] = date('Y年m月d日', strtotime($data['semesterBeginTime']));
  39. $result['endDate'] = date('Y年m月d日', strtotime($data['semesterEndTime']));
  40. $result['examNum'] = $data['examNum'];
  41. $result['trialNum'] = $data['trialNum'];
  42. $result['seasonId'] = $data['seasonId'];
  43. }
  44. } else {
  45. Yii::app()->jump->error($data);
  46. }
  47. $this->render('trial', $result);
  48. }
  49. /**
  50. * @return array
  51. * 获取当前赛季信息
  52. */
  53. public function getCurrentSeason()
  54. {
  55. $result = array();
  56. $http = http('sys/school/year/current', 'GET', $this->authUsername);
  57. $response = formatResponse($http);
  58. $data = $response['data'];
  59. if ($response['status']) {
  60. if ($data) {
  61. // $result['seasonName'] = $data['seasonName'];
  62. // $result['startDate'] = date('Y年m月', strtotime($data['beginTime']));
  63. // $result['endDate'] = date('Y年m月', strtotime($data['endTime']));
  64. // $result['examNum'] = $data['examNum'];
  65. $result['schoolYearId'] = $data['schoolYearId'];
  66. $result['semesterId'] = $data['semesterId'];
  67. }
  68. }
  69. return $result;
  70. }
  71. /**
  72. * 产品试用列表
  73. */
  74. public function actionTrialTable()
  75. {
  76. $params = array();
  77. $result = array();
  78. $seasonId = Req::get('seasonId');
  79. $result['seasonName'] = Req::get('seasonName');
  80. $result['seasonId'] = $seasonId;
  81. $page = Req::get('page') ? Req::get('page') : 1;
  82. if(Req::get('seasonId')){
  83. $arr=explode('_',Req::get('seasonId'));
  84. $params['schoolYearId'] = $arr[0];
  85. $params['semesterId'] = $arr[1];
  86. }
  87. if (Req::get('goodsTypeId')) {
  88. $params['goodsTypeId'] = Req::get('goodsTypeId');
  89. }
  90. if (Req::get('grade')) {
  91. $params['grade'] = Req::get('grade');
  92. }
  93. if (Req::get('clazzId')) {
  94. $params['clazzId'] = Req::get('clazzId');
  95. }
  96. if (Req::get('subject')) {
  97. $params['subject'] = Req::get('subject');
  98. }
  99. //获取产品
  100. $goodArr = $this->getGoodType();
  101. $result['goodList'] = $goodArr;
  102. //获取赛季列表
  103. $seasonList = $this->getEnableImsSemester();
  104. $result['seasonList'] = $seasonList;
  105. $http = http('order/coach/trials/' . $page, 'POST', $this->authUsername, $params);
  106. $response = formatResponse($http);
  107. $data = $response['data'];
  108. if ($response['status']) {
  109. $result['page'] = $data;
  110. $result['list'] = isset($data['list'])?$data['list']:array();
  111. } else {
  112. $result['page'] = array();
  113. $result['list'] = array();
  114. }
  115. if(isset(Yii::app()->params['subjectId']) && Yii::app()->params['subjectId']){
  116. $result['subject']=Yii::app()->params['subjectId'];
  117. unset($result['subject'][6]);
  118. if(isset($result['subject'][20])) unset($result['subject'][20]);
  119. }
  120. // debug($result);
  121. return $this->render('trialTable', $result);
  122. }
  123. /*
  124. * 读取试用订单日志
  125. * */
  126. public function actionGetOrderLog(){
  127. $orderId = Req::post('orderId');
  128. $result['status']=0;
  129. if(!$orderId){
  130. exit(json_encode($result));
  131. }
  132. //请求日志
  133. $log = http('order/coach/trial/detail/'.$orderId, 'get', $this->authUsername, array());
  134. $logList=formatResponse($log);
  135. if(isset($logList['data']['orderLogs'])){
  136. $result['data']=$logList['data']['orderLogs'];
  137. }else{
  138. $result['data']=array();
  139. }
  140. $result['status']=1;
  141. exit(json_encode($result));
  142. }
  143. /**
  144. * 申请延长订单
  145. */
  146. public function actionRelayTrial()
  147. {
  148. $orderId = Req::post('orderId');
  149. $http = http('order/coach/trial/delay/'.$orderId,'put', $this->authUsername);
  150. $response = formatResponse($http);
  151. $this->imsLog("试用订单-申请延长",'order/coach/trial/delay/'.$orderId,array(),$response);
  152. if ($response['status']){
  153. $data = $response['data'];
  154. $needApply = isset($data['needApply'])?$data['needApply']:0;
  155. $delayDay = isset($data['delayDay'])?$data['delayDay']:0;
  156. if($needApply){
  157. $msg = "将延长试用".$delayDay."天,已通知后台审批";
  158. }else{
  159. $msg = "将延长试用".$delayDay."天,本次申请无需审批";
  160. }
  161. returnMsg(1,$msg);
  162. }else{
  163. returnMsg(0,$response['data']);
  164. }
  165. }
  166. /**
  167. * 开通产品试用列表
  168. */
  169. public function actionDoTrial()
  170. {
  171. //读取科目
  172. //$http = http('dictionary/coach/list/active-type/subject', 'get', $this->authUsername);
  173. $params=array();
  174. $params['onlyTrial']=1;
  175. $params['learningStage']=Yii::app()->params['section'];
  176. $http = http('goods-type/coach', 'get', $this->authUsername,$params);
  177. $response = formatResponse($http);
  178. $subjects=array();
  179. $goodArr=array();
  180. $schoolYear=0;
  181. if(isset($response['data']) && $response['status']==1){
  182. foreach ($response['data'] as $datum){
  183. $subjects[$datum['goodsTypeId']]=$datum['subjects'];
  184. $goodArr[]=array(
  185. 'goodsTypeId'=> $datum['goodsTypeId'],
  186. 'goodsTypeName'=> $datum['goodsTypeName'],
  187. );
  188. if(!$schoolYear){
  189. $schoolYear=$datum['schoolYear'];
  190. }
  191. }
  192. }
  193. if(!$schoolYear){
  194. Yii::app()->jump->error("获取学年异常");
  195. }
  196. //年级对应实际年级
  197. $semester=$this->schoolManager->getSemester($this->semesterId);
  198. $nowSemesterSchoolYear=$semester['school_year'];
  199. if(Yii::app()->params['section']!=0){
  200. if(strpos($semester['semester_name'],'上学期')!==false){
  201. $grade[1]=intval($schoolYear-($nowSemesterSchoolYear-1+1));
  202. $grade[2]=intval($schoolYear-($nowSemesterSchoolYear-2+1));
  203. $grade[3]=intval($schoolYear-($nowSemesterSchoolYear-3+1));
  204. }elseif(strpos($semester['semester_name'],'下学期')!==false || strpos($semester['semester_name'],'暑假')!==false || strpos($semester['semester_name'],'寒假')!==false){
  205. $grade[1]=intval($schoolYear-($nowSemesterSchoolYear-1));
  206. $grade[2]=intval($schoolYear-($nowSemesterSchoolYear-2));
  207. $grade[3]=intval($schoolYear-($nowSemesterSchoolYear-3));
  208. }
  209. }else{
  210. if(strpos($semester['semester_name'],'上学期')!==false){
  211. $grade[7]=intval($schoolYear-($nowSemesterSchoolYear-7+1));
  212. $grade[8]=intval($schoolYear-($nowSemesterSchoolYear-8+1));
  213. $grade[9]=intval($schoolYear-($nowSemesterSchoolYear-9+1));
  214. }elseif(strpos($semester['semester_name'],'下学期')!==false || strpos($semester['semester_name'],'暑假')!==false || strpos($semester['semester_name'],'寒假')!==false){
  215. $grade[7]=intval($schoolYear-($nowSemesterSchoolYear-7));
  216. $grade[8]=intval($schoolYear-($nowSemesterSchoolYear-8));
  217. $grade[9]=intval($schoolYear-($nowSemesterSchoolYear-9));
  218. }
  219. }
  220. if(Yii::app()->params['grade_list']){
  221. foreach (Yii::app()->params['grade_list'] as $id =>$param){
  222. $gradeName[$id]=$param['grade_name'];
  223. }
  224. }
  225. $result = array();
  226. //获取产品
  227. $result['goodList'] = $goodArr;
  228. $result['selectedStudent'] = array();
  229. $result['subjects']=$subjects;
  230. $result['grade']=$grade;
  231. $result['gradeName']=$gradeName;
  232. $this->render('doTrial', $result);
  233. }
  234. /**
  235. * 编辑产品试用列表
  236. */
  237. public function actionEditTrial()
  238. {
  239. $result = array();
  240. //获取产品
  241. $goodArr = $this->getGoodType();
  242. $result['goodList'] = $goodArr;
  243. //获取已经提交的数据
  244. $orderId = Req::get('orderId');
  245. $orderDetail = $this->getTrialOrderDetail($orderId);
  246. if(empty($orderDetail)){
  247. Yii::app()->jump->error("获取订单详情异常");
  248. }
  249. $result['grade'] = $orderDetail['grade'];
  250. $result['goodsTypeId'] = $orderDetail['goodsTypeId'];
  251. $result['startDate'] = $orderDetail['startDate'];
  252. //已经试用人数
  253. $http = http('order/coach/trial/students/'.$orderId, 'get', $this->authUsername);
  254. $response = formatResponse($http);
  255. $result['selectedStudent'] = $response['data'];
  256. $this->render('editTrial', $result);
  257. }
  258. /**
  259. * 提交试用订单(重新提交)
  260. */
  261. public function actionSaveTrial()
  262. {
  263. $studentIdArr = Req::post('studentList');
  264. $params['beginTime'] = Req::post('startTime');
  265. $params['grade'] = Req::post('grade');
  266. $params['goodsTypeId'] = Req::post('goodsTypeId');
  267. $params['subject'] = Req::post('subjectId');
  268. $params['trialType'] = Req::post('trialType');
  269. $params['yearSemester'] = Req::post('yearSemester');
  270. //$params['firstMarkTime'] = Req::post('endTime');
  271. $studentIdArr=str_replace('&quot;','"',$studentIdArr);
  272. @$studentIdArr=json_decode($studentIdArr,true);
  273. $students = array();
  274. if(!$studentIdArr){
  275. returnMsg(0,'学生数据解析失败');
  276. }
  277. foreach ($studentIdArr as $k=>$v){
  278. if(!$v['class'] || !$v['classId'] || !$v['value'] || !$v['name']){
  279. continue;
  280. }
  281. $students[$k]['studentName'] = $v['name'];
  282. $students[$k]['studentId'] = $v['value'];
  283. $students[$k]['clazzName'] = $v['class'];
  284. $students[$k]['clazzId'] = $v['classId'];
  285. }
  286. $params['students'] = $students;
  287. if (Req::post('orderId')){
  288. $params['orderId'] = Req::post('orderId');
  289. $http = http('order/coach/trial','put', $this->authUsername, $params);
  290. }else{
  291. $http = http('order/coach/trial','post', $this->authUsername, $params);
  292. }
  293. $response = formatResponse($http);
  294. $this->imsLog("试用订单-提交",'order/coach/trial',$params,$response);
  295. if($response['status']){
  296. returnMsg(1,$response['data']);
  297. }else{
  298. if(Yii::app()->params['handle_log_on_off'])
  299. {
  300. writeFileLog(jsonEncode(array(
  301. "exam_group_id" => 0,
  302. "operate_project" => 'zsyas2',
  303. "school_id" => $this->schoolId,
  304. "title" => '创建试用订单失败',
  305. "operate_account" => Yii::app()->session['coachInfo']['coach_name'],
  306. "operate_method" => $this->action,
  307. "operate_url" => $this->getRoute(),
  308. "operate_sql" =>'',
  309. "operate_param" =>json_encode(array('post'=>$_POST,'get'=>$_GET,'param'=>$params)),
  310. "date"=>date('Y-m-d H:i:s')
  311. )));
  312. }
  313. returnMsg(0,$response['data']);
  314. }
  315. }
  316. /**
  317. * @return null|string|string[]
  318. * 试用人数列表
  319. */
  320. public function actionTrialStudent()
  321. {
  322. $result = array();
  323. if (Req::get('orderId')){
  324. $orderId = Req::get('orderId');
  325. $page = Req::get('page')?Req::get('page'):1;
  326. $http = http('order/coach/trial/students/'.$orderId.'/'.$page, 'get', $this->authUsername);
  327. $responseArr = formatResponse($http);
  328. if($responseArr['status']){
  329. $result['page'] = $responseArr['data'];
  330. $result['list'] = $responseArr['data']['list'];
  331. }
  332. //订单详情
  333. $goodsDetail = $this->getTrialOrderDetail($orderId);
  334. if(empty($goodsDetail)){
  335. Yii::app()->jump->error("获取订单详情异常");
  336. }
  337. //判断是否可以开启试用
  338. $http=http('order-trial-enable/coach/can-apply/'.$orderId, 'get', $this->authUsername);
  339. $responseArr = formatResponse($http);
  340. $result['canOpen']=0;
  341. $result['errMsg']='';
  342. if($responseArr['status']){
  343. $result['canOpen']=$responseArr['data'];
  344. }else{
  345. $result['errMsg']=$responseArr['data'];
  346. }
  347. $result['goodDetail'] = $goodsDetail;
  348. $result['orderId']=$orderId;
  349. }else{
  350. Yii::app()->jump->error("订单id必须;");
  351. }
  352. $this->render('trialStudent', $result);
  353. }
  354. //请求暂停、开启班级列表
  355. public function actionGetClassesByOrderId(){
  356. $orderId=Req::post('orderId');
  357. $type=Req::post('type');
  358. $result['status']=0;
  359. //读取班级列表
  360. $http = http('order/coach/all/clazz/by/'.$orderId.'/'.$type, 'get', $this->authUsername);
  361. $responseArr = formatResponse($http);
  362. if($responseArr['status']==1){
  363. $result=$responseArr;
  364. $result['students']=array();
  365. //读取学生列表
  366. if($result['data']){
  367. $classId=$result['data'][0]['clazzId'];
  368. //$studentHttp= http('order/coach/all/student/by/'.$orderId.'/'.$classId.'/'.$type, 'get', $this->authUsername);
  369. $studentHttp= http('order/coach/all/student/by/'.$orderId.'/'.$classId.'/'.$type, 'get', $this->authUsername,array('stuName'=>''));
  370. $students=formatResponse($studentHttp);
  371. if($students['status']==1){
  372. $result['students']=$students['data'];
  373. }
  374. }
  375. }
  376. exit(json_encode($result));
  377. }
  378. //读取开启、暂停学生列表
  379. public function actionGetStudentByClassIdOrderId(){
  380. $orderId=Req::post('orderId');
  381. $type=Req::post('type');
  382. $classId=Req::post('classId');
  383. $stuName=Req::post('studentName')?Req::post('studentName'):'';
  384. $result['status']=0;
  385. // $studentHttp= http('order/coach/all/student/by/'.$orderId.'/'.$classId.'/'.$type, 'get', $this->authUsername);
  386. $studentHttp= http('order/coach/all/student/by/'.$orderId.'/'.$classId.'/'.$type, 'get', $this->authUsername,array('stuName'=>$stuName));
  387. $students=formatResponse($studentHttp);
  388. if($students['status']==1){
  389. $result['status']=1;
  390. $result['data']=$students['data'];
  391. }
  392. exit(json_encode($result));
  393. }
  394. //开启、暂停学生订单
  395. public function actionDoStudentOrder(){
  396. $orderId=Req::post('orderId');
  397. $type=Req::post('type');
  398. $reason=Req::post('reason');
  399. $students=Req::post('selectedDataValue');
  400. $result['status']=0;
  401. $params=$students;
  402. if($type==0){
  403. $http= http('order/coach/suspend/'.$orderId, 'post', $this->authUsername,$params);
  404. }else{
  405. $params=array(
  406. 'otId'=>$orderId,
  407. 'osIds'=>$students,
  408. 'reason'=>$reason
  409. );
  410. $http= http('order-trial-enable/coach', 'post', $this->authUsername,$params);
  411. // $http= http('order/coach/enable/'.$orderId, 'post', $this->authUsername,$params);
  412. }
  413. $students=formatResponse($http);
  414. if($students['status']==1){
  415. $result['status']=1;
  416. }
  417. exit(json_encode($result));
  418. }
  419. public function getTrialOrderDetail($orderId)
  420. {
  421. $result = array();
  422. $http = http('order/coach/trial/detail/'.$orderId,'get', $this->authUsername);
  423. $response = formatResponse($http);
  424. if ($response['status']){
  425. $data = $response['data'];
  426. $result['goodsTypeName'] = $data['orderGoods']['goodsTypeName'];
  427. $result['gradeName'] = $data['gradeName'];
  428. $result['date'] = $data['beginTime'].' ~ '.$data['endTime'];
  429. $result['status'] = $data['trialStatusName'];
  430. $result['grade'] = $data['grade'];
  431. $result['goodsTypeId'] = $data['orderGoods']['goodsTypeId'];
  432. $result['startDate'] = $data['beginTime'];
  433. $result['enableNum'] = $data['enableNum'];
  434. }
  435. return $result;
  436. }
  437. /**
  438. * 正式订单列表
  439. */
  440. public function actionOfficialTable()
  441. {
  442. $page = Req::get('page')?Req::get('page'):1;
  443. $result = array();
  444. $params = array();
  445. if(Req::get('goodsId')){
  446. $params['goodsId'] = Req::get('goodsId');
  447. }
  448. if(Req::get('packageId')){
  449. $params['packageId'] = Req::get('packageId');
  450. }
  451. if(Req::get('status')){
  452. $params['status'] = Req::get('status')-1;
  453. }
  454. if(Req::get('orderType')){
  455. $params['orderType'] = Req::get('orderType')-1;
  456. }
  457. //获取产品
  458. $goodArr = $this->getGood();
  459. $result['goodList'] = $goodArr;
  460. //获取审核字典
  461. $dict = $this->getDict('process_apply_status');
  462. $result['applyStatus'] = $dict;
  463. $http = http('order/coach/officials/'.$page, 'POST', $this->authUsername, $params);
  464. $response = formatResponse($http);
  465. $data = $response['data'];
  466. if($response['status']){
  467. $result['page'] = $data;
  468. $result['list'] = isset($data['list'])?$data['list']:array();
  469. }else{
  470. $result['page'] = array();
  471. $result['list'] = array();
  472. }
  473. // debug($result);
  474. $this->render('officialTable', $result);
  475. }
  476. /**
  477. * @return string
  478. * 订购页面
  479. */
  480. public function actionOrderOfficial()
  481. {
  482. $orderId = Req::get('orderId');
  483. $goodDetail = $this->getOfficialOrderDetail($orderId);
  484. $this->render('orderOfficial', array('orderId'=>$orderId,'goodDetail'=>$goodDetail));
  485. }
  486. /**
  487. * 提交订购
  488. */
  489. public function actionSaveOfficial()
  490. {
  491. $studentIdArr = Req::post('studentList');
  492. $params['orderId'] = Req::post('orderId');
  493. $students = array();
  494. foreach ($studentIdArr as $k=>$v){
  495. $value = explode('#',$v);
  496. if(count($value)==4){
  497. $students[$k]['studentName'] = trim($value[0]);
  498. $students[$k]['studentId'] = trim($value[1]);
  499. $students[$k]['clazzName'] = trim($value[2]);
  500. $students[$k]['clazzId'] = trim($value[3]);
  501. }
  502. }
  503. $params['students'] = $students;
  504. $http = http('order/coach/official/students','post', $this->authUsername, $params);
  505. $response = formatResponse($http);
  506. $this->imsLog("正式订单-订购",'order/coach/trial',$params,$response);
  507. if($response['status']){
  508. returnMsg(1,'提交成功');
  509. }else{
  510. returnMsg(0,$response['data']);
  511. }
  512. }
  513. /**
  514. * 正式订单 催办
  515. */
  516. public function actionUrge()
  517. {
  518. $params = array(
  519. 'userId'=> $this->coachId,
  520. 'businessKey'=> Req::post('businessKey'),
  521. 'smeDesc'=> Req::post('smeDesc'),
  522. );
  523. $http = http('message/coach/urge', 'post', $this->authUsername, $params);
  524. $response = formatResponse($http);
  525. $this->imsLog("正式订单-催办",'message/coach/urge',$params,$response);
  526. if ($response['status']){
  527. returnMsg(1, '提交成功!');
  528. }else{
  529. returnMsg(0, $response['data']);
  530. }
  531. }
  532. /**
  533. * 正式订单取消
  534. */
  535. public function actionStop()
  536. {
  537. $businessKey = Req::post('businessKey');
  538. $title = Req::post('title');
  539. $http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
  540. $response = formatResponse($http);
  541. $this->imsLog($title,'activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
  542. if ($response['status']){
  543. returnMsg(1, '提交成功!');
  544. }else{
  545. returnMsg(0, $response['data']);
  546. }
  547. }
  548. /**
  549. * 正式订单删除
  550. */
  551. public function actionDelete()
  552. {
  553. $businessKey = Req::post('businessKey');
  554. $title = Req::post('title');
  555. $http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
  556. $response = formatResponse($http);
  557. $this->imsLog($title,'activiti/coach/process-instances/'.$businessKey,array(),$response);
  558. if ($response['status']){
  559. returnMsg(1, '提交成功!');
  560. }else{
  561. returnMsg(0, $response['data']);
  562. }
  563. }
  564. /**
  565. * @return string
  566. * 明细订单
  567. */
  568. public function actionDetailOrder()
  569. {
  570. $params = array();
  571. $page = Req::get('page')?Req::get('page'):1;
  572. if (Req::get('orderNo')){
  573. $params['orderOfficialNo'] = Req::get('orderNo');
  574. }
  575. if (Req::get('orderOfficialNo')){
  576. $params['orderOfficialNo'] = Req::get('orderOfficialNo');
  577. }
  578. if(Req::get('goodsId')){
  579. $params['goodsId'] = Req::get('goodsId');
  580. }
  581. if(Req::get('packageId')){
  582. $params['packageId'] = Req::get('packageId');
  583. }
  584. if(Req::get('useStatus')){
  585. $params['useStatus'] = Req::get('useStatus')-1;
  586. }
  587. if(Req::get('payStatus')){
  588. $params['payStatus'] = Req::get('payStatus')-1;
  589. }
  590. if(Req::get('takeStatus')){
  591. $params['takeStatus'] = Req::get('takeStatus')-1;
  592. }
  593. if(Req::get('studentName') && Req::get('studentName')!=''){
  594. $params['studentName'] = Req::get('studentName');
  595. }
  596. if(Req::get('orderTypes')){
  597. $params['orderType'] = Req::get('orderTypes')-1;
  598. }
  599. if(Req::get('semesterTypes')){
  600. $params['semester'] = Req::get('semesterTypes')-1;
  601. }
  602. if(Req::get('schoolYearName') && Req::get('schoolYearName')!=''){
  603. $params['schoolYearId'] = Req::get('schoolYearName');
  604. }
  605. if(Req::get('className') && Req::get('className')!=''){
  606. $params['clazzName'] = Req::get('className');
  607. }
  608. if(Req::get('beginTime') && Req::get('beginTime')!=''){
  609. $params['beginTime'] = date('Y-m-d H:i:s',strtotime(Req::get('beginTime')));
  610. }
  611. if(Req::get('endTime') && Req::get('endTime')!=''){
  612. $params['endTime'] = date('Y-m-d 23:59:59',strtotime(Req::get('endTime')));
  613. }
  614. //获取产品
  615. $goodArr = $this->getGood();
  616. $result['goodList'] = $goodArr;
  617. //获取学年
  618. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  619. $response = formatResponse($http);
  620. $result['schoolYear'] = $response['data'];
  621. // debug($params);
  622. $http = http('order/coach/official/details/'.$page,'post', $this->authUsername, $params);
  623. $response = formatResponse($http);
  624. $data = $response['data'];
  625. if($response['status']){
  626. $result['page'] = $data;
  627. $result['list'] = $data['list'];
  628. }else{
  629. $result['page'] = array();
  630. $result['list'] = array();
  631. }
  632. $this->render('detailOrder', $result);
  633. }
  634. /**
  635. * @return string
  636. * 意向订单
  637. */
  638. public function actionPurposeTable()
  639. {
  640. $result = array();
  641. $params = array();
  642. $page = Req::get('page')?Req::get('page'):1;
  643. if(Req::get('schoolYearId')){
  644. $params['schoolYearId'] = Req::get('schoolYearId');
  645. }
  646. if(Req::get('goodsId')){
  647. $params['goodsId'] = Req::get('goodsId');
  648. }
  649. if(Req::get('beginTime')){
  650. $params['beginTime'] = Req::get('beginTime');
  651. }
  652. if(Req::get('endTime')){
  653. $params['endTime'] = Req::get('endTime');
  654. }
  655. if(Req::get('purposeOrderNo')){
  656. $params['orderNo'] = Req::get('purposeOrderNo');
  657. }
  658. //获取学年
  659. $http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
  660. $response = formatResponse($http);
  661. $result['schoolYear'] = $response['data'];
  662. //获取产品
  663. $goodArr = $this->getGood();
  664. $result['goodList'] = $goodArr;
  665. $http = http('order/coach/purposes/'.$page, 'post', $this->authUsername, $params);
  666. $response = formatResponse($http);
  667. $data = $response['data'];
  668. if($response['status']){
  669. $result['page'] = $data;
  670. $result['list'] = $data['list'];
  671. }else{
  672. $result['page'] = array();
  673. $result['list'] = array();
  674. }
  675. //debug($result);
  676. $this->render('purposeTable', $result);
  677. }
  678. /**
  679. * 意向订单转正式订单
  680. */
  681. public function actionToOfficial()
  682. {
  683. $params = array();
  684. if(Req::post('orderId')){
  685. $params['orderId'] = Req::post('orderId');
  686. }else{
  687. returnMsg(0,'orderId必须');
  688. }
  689. if(Req::post('officialNum')){
  690. $params['officialNum'] = Req::post('officialNum');
  691. }else{
  692. returnMsg(0,'officialNum必须');
  693. }
  694. $http = http('order/coach/purpose/to/official', 'post', $this->authUsername, $params);
  695. $response = formatResponse($http);
  696. $this->imsLog("意向订单-转正式订单",'order/coach/purpose/to/official',$params,$response);
  697. if ($response['status']){
  698. returnMsg(1,'操作成功');
  699. }else{
  700. returnMsg(0,$response['data']);
  701. }
  702. }
  703. /**
  704. * 意向订单转正式订单(重新提交)
  705. */
  706. public function actionReToOfficial()
  707. {
  708. $params = array();
  709. if(Req::post('orderId')){
  710. $params['orderOfficialId'] = Req::post('orderId');
  711. }else{
  712. returnMsg(0,'orderId必须');
  713. }
  714. if(Req::post('officialNum')){
  715. $params['officialNum'] = Req::post('officialNum');
  716. }else{
  717. returnMsg(0,'officialNum必须');
  718. }
  719. $http = http('order/coach/purpose/re-to/official', 'post', $this->authUsername, $params);
  720. $response = formatResponse($http);
  721. $this->imsLog("意向订单-重新提交",'order/coach/purpose/re-to/official',$params,$response);
  722. if ($response['status']){
  723. returnMsg(1,'操作成功');
  724. }else{
  725. returnMsg(0,$response['data']);
  726. }
  727. }
  728. /**
  729. * @return array
  730. * 获取订单详情-正式订单
  731. */
  732. public function getOfficialOrderDetail($orderId)
  733. {
  734. $result = array();
  735. $useDates = array();
  736. $http = http('order/coach/official/detail/'.$orderId,'get', $this->authUsername);
  737. $response = formatResponse($http);
  738. if ($response['status']){
  739. $data = $response['data'];
  740. $useDateArr = $data['orderGoods']['goodsPackageTimes'];
  741. foreach ($useDateArr as $k=>$v){
  742. $useDates[] = $v['timeName'];
  743. }
  744. $result['goodName'] = $data['orderGoods']['goodsName'];
  745. $result['packageName'] = $data['orderGoods']['goodsPackageName'];
  746. $result['useDate'] = implode(',',$useDates);
  747. $result['grade'] = $data['grade'];
  748. }
  749. return $result;
  750. }
  751. /**
  752. * 获取班级列表
  753. */
  754. public function actionGetClassList()
  755. {
  756. if (Req::post('grade')) {
  757. $grade = Req::post('grade');
  758. } else {
  759. $grade = 1;
  760. }
  761. $subjectId=Req::post('subjectId');
  762. $coachId = $this->coachId;
  763. $semesterId = $this->semesterId;
  764. $condition = "semester_id={$semesterId} AND grade={$grade} ";
  765. //判断是否开通走班
  766. if($subjectId){
  767. $classified=$this->schoolManager->getClassifiedBySubject($grade,$subjectId,$semesterId);
  768. if(!$classified || $classified['status']==0){
  769. $condition = "semester_id={$semesterId} AND grade={$grade} and class_type=1 ";
  770. }else{
  771. $condition = "semester_id={$semesterId} AND grade={$grade} and class_type=2 ";
  772. }
  773. }else{
  774. $condition = "semester_id={$semesterId} AND grade={$grade} ";
  775. }
  776. $select = 'class_id,class_name';
  777. $classList = SClass::model()->getClassList($select, $condition);
  778. if ($classList) {
  779. returnMsg(1, 'success', $classList);
  780. } else {
  781. returnMsg(0, '暂无数据');
  782. }
  783. }
  784. /**
  785. * 获取班级列表
  786. */
  787. public function actionGetClassListForClassifed()
  788. {
  789. if (Req::post('grade')) {
  790. $grade = Req::post('grade');
  791. } else {
  792. $grade = 1;
  793. }
  794. $subject=Req::post('subject');
  795. $coachId = $this->coachId;
  796. $semesterId = $this->semesterId;
  797. if(!$subject){
  798. //读取走班设置
  799. $result=array();
  800. $subjects=array();
  801. $classified=$this->sConn->createCommand("select subject_id from classified where grade='{$grade}' and semester_id='{$semesterId}' and status=1")->queryAll();
  802. if($classified){
  803. foreach ($classified as $val){
  804. $subjects[]=array(
  805. 'id'=>$val['subject_id'],
  806. 'name'=>Yii::app()->params['subjectId'][$val['subject_id']]
  807. );
  808. }
  809. }
  810. $result['subjects']=$subjects;
  811. $condition = "semester_id={$semesterId} AND grade={$grade} and class_type=1";
  812. $select = 'class_id,class_name';
  813. $classList = SClass::model()->getClassList($select, $condition);
  814. $result['classList']=$classList;
  815. if ($result) {
  816. returnMsg(1, 'success', $result);
  817. } else {
  818. returnMsg(0, '暂无数据');
  819. }
  820. }else{
  821. //读取走班学科班级
  822. $classData=$this->sConn->createCommand("select c.class_id,class_name from class c join class_subject_relation csr on c.class_id=csr.class_id where csr.subject_id='{$subject}' and c.class_type=2 and grade='{$grade}'")->queryAll();
  823. if($classData){
  824. returnMsg(1, 'success', $classData);
  825. }else{
  826. returnMsg(0, '暂无数据');
  827. }
  828. }
  829. }
  830. /**
  831. * 获取学生信息
  832. */
  833. public function actionGetStudent()
  834. {
  835. $result = array();
  836. $students = array();
  837. if (Req::post('classId')) {
  838. $classId = Req::post('classId');
  839. } else {
  840. returnMsg(0, 'classId必须');
  841. }
  842. $subjectId = Req::post('subjectId');
  843. if(!$subjectId){
  844. returnMsg(0, 'subjectId必须');
  845. }
  846. $studentName=Req::post('studentName');
  847. $trialType=Req::post('trialType');
  848. $semesterId=Req::post('semesterId');
  849. $grade=Req::post('grade');
  850. $startTime=Req::post('startTime');
  851. if($trialType==-1){
  852. returnMsg(0, '试用订单类型必须');
  853. }
  854. $studentIds=array();
  855. $list = SStudentClassRelation::model()->getStudentInfoByClassId($classId,$studentName);
  856. if($list){
  857. foreach ($list as $val){
  858. $studentIds[]=$val['student_id'];
  859. }
  860. }
  861. //获取本赛季已经开通的学生(页面需要 disabled)
  862. $currSeason = $this->getCurrentSeason();
  863. $studentArr = $this->getTrialStudentByStudentList($semesterId,$currSeason['schoolYearId'], Req::post('goodsTypeId'),$classId,$subjectId,$studentIds,$trialType,$grade,$startTime,$currSeason['semesterId']);
  864. if ($studentArr){
  865. foreach ($studentArr as $k=>$v)
  866. {
  867. $students[] = $v['studentId'];
  868. }
  869. }
  870. arrayMsort($list,'realname');
  871. if ($list) {
  872. $result['list'] = $list;
  873. $result['student'] = $students;
  874. returnMsg(1, 'success', $result);
  875. } else {
  876. returnMsg(0, '暂无数据');
  877. }
  878. }
  879. /**
  880. * 获取学生信息(正式订单)
  881. */
  882. public function actionGetOfficialStudent()
  883. {
  884. $result = array();
  885. $students = array();
  886. if (Req::post('classId')) {
  887. $classId = Req::post('classId');
  888. } else {
  889. returnMsg(0, 'classId必须');
  890. }
  891. $list = SStudentClassRelation::model()->getStudentInfoByClassId($classId);
  892. //获取本赛季已经开通的学生
  893. $studentArr = $this->getOfficialStudent(Req::post('orderId'), $classId);
  894. if ($studentArr){
  895. foreach ($studentArr as $k=>$v)
  896. {
  897. $students[] = $v['studentId'];
  898. }
  899. }
  900. if ($list) {
  901. $result['list'] = $list;
  902. $result['student'] = $students;
  903. returnMsg(1, 'success', $result);
  904. } else {
  905. returnMsg(0, '暂无数据');
  906. }
  907. }
  908. /**
  909. * @return array
  910. * 获取商品
  911. */
  912. public function getGood()
  913. {
  914. $result = array();
  915. $http = http('goods/up/list?schoolId='.$this->schoolId, 'get', $this->authUsername);
  916. $response = formatResponse($http);
  917. if($response['status']){
  918. $result = $response['data'];
  919. }
  920. return $result;
  921. }
  922. /**
  923. * @param $seasonId
  924. * @param $goodsTypeId
  925. * @param $classId
  926. * @return array
  927. * 获取已经订购的学生(意向订单)
  928. */
  929. public function getTrialStudent($semesterId,$schoolYearId, $goodsTypeId, $classId,$subjectId)
  930. {
  931. $http = http('order/coach/trial/'.$schoolYearId.'/'.$semesterId.'/'.$goodsTypeId.'/'.$classId.'/'.$subjectId.'/students', 'get', $this->authUsername);
  932. $response = formatResponse($http);
  933. if($response['status']){
  934. return $response['data'];
  935. }else{
  936. return array();
  937. }
  938. }
  939. /**
  940. * @param $seasonId
  941. * @param $goodsTypeId
  942. * @param $classId
  943. * @return array
  944. * 获取已经订购的学生(正式订单)
  945. */
  946. public function getOfficialStudent($orderId, $classId)
  947. {
  948. $http = http('order/coach/official/'.$orderId.'/'.$classId.'/students', 'get', $this->authUsername);
  949. $response = formatResponse($http);
  950. if($response['status']){
  951. return $response['data'];
  952. }else{
  953. return array();
  954. }
  955. }
  956. /**
  957. * 获取字典
  958. */
  959. public function getDict($codeType)
  960. {
  961. $result = array();
  962. $http = http('dictionary/list/type-code/'.$codeType, 'get', $this->authUsername);
  963. $response = formatResponse($http);
  964. if ($response['status']){
  965. $result = $response['data'];
  966. }
  967. return $result;
  968. }
  969. /**
  970. * 获取所有启用的销售赛季
  971. */
  972. public function getEnableSeason()
  973. {
  974. $result = array();
  975. $http = http('sales-season/enables', 'get', $this->authUsername);
  976. $response = formatResponse($http);
  977. if ($response['status']){
  978. $result = $response['data'];
  979. }
  980. return $result;
  981. }
  982. /**
  983. * 获取所有启用的销售学期
  984. */
  985. public function getEnableImsSemester()
  986. {
  987. $result = array();
  988. $http = http('sys/school/year/semester/list', 'get', $this->authUsername);
  989. $response = formatResponse($http);
  990. if ($response['status']){
  991. $result = $response['data'];
  992. }
  993. return $result;
  994. }
  995. /**
  996. * @return array
  997. * 获取商品类别
  998. */
  999. public function getGoodType()
  1000. {
  1001. $result = array(
  1002. array(
  1003. 'goodsTypeId'=> 1,
  1004. 'goodsTypeName'=> '错题本'
  1005. ),
  1006. array(
  1007. 'goodsTypeId'=> 2,
  1008. 'goodsTypeName'=> '个性化学习方案'
  1009. ),
  1010. array(
  1011. 'goodsTypeId'=> 3,
  1012. 'goodsTypeName'=> '个性化学习宝'
  1013. ),
  1014. );
  1015. return $result;
  1016. }
  1017. /**
  1018. * @return array
  1019. * 获取套餐
  1020. */
  1021. public function actionGetPackages()
  1022. {
  1023. $goodsId = Req::post('goodsId');
  1024. $http = http('goods/packages/'.$goodsId, 'GET', $this->authUsername);
  1025. $response = formatResponse($http);
  1026. if ($response['status']){
  1027. returnMsg(1,'success', $response['data']);
  1028. }else{
  1029. returnMsg(0, $response['data']);
  1030. }
  1031. }
  1032. /**
  1033. * 确认收货提示
  1034. */
  1035. public function actionConfirmWaning(){
  1036. $msg = '<table border="1">';
  1037. $hasMessage=0;
  1038. //收货提醒
  1039. $http = http('storage-allocate/coach/warning', 'GET', $this->authUsername);
  1040. $response = formatResponse($http);
  1041. if($response['status'] && $response['data']){
  1042. $hasMessage=1;
  1043. $url = Yii::app()->createUrl('imsStore/allocation');
  1044. $msg .= '<tr><td><div style="padding:10px 20px;"><p style="line-height:30px;color:#619aff;">确认收货提醒</p></div></td><td>已经有发货5天尚未确认收货的调拨单,请在到货后确认收货,如对物流有疑问,请联系总部 </td><td><div style="padding:10px 20px;"><a style="color:blue;" href='.$url.'>立即处理</a></div></td></tr>';
  1045. }
  1046. //清洁提醒
  1047. $http = http('equip/plan/coach/cleanCommitWarning', 'GET', $this->authUsername);
  1048. $response1 = formatResponse($http);
  1049. if($response1['status'] && $response1['data']){
  1050. $hasMessage=1;
  1051. $url = Yii::app()->createUrl('imsDevice/taskClean');
  1052. $msg .= '<tr><td><div style="padding:10px 20px;"><p style="line-height:30px;color:#619aff;">清洁任务提醒</p></div></td><td>你有待提交的清洁任务,请及时处理,否则会判定为不合格 </td><td><div style="padding:10px 20px;"><a style="color:blue;" href='.$url.'>立即处理</a></div></td></tr>';
  1053. }
  1054. //发货提醒
  1055. $http = http('storage-allocate/coach/deliverWarning', 'GET', $this->authUsername);
  1056. $response2 = formatResponse($http);
  1057. if($response2['status'] && $response2['data']){
  1058. $hasMessage=1;
  1059. $url = Yii::app()->createUrl('imsStore/allocation');
  1060. $msg .= '<tr><td><div style="padding:10px 20px;"><p style="line-height:30px;color:#619aff;">调拨单提醒</p></div></td><td>您有待发货的调拨单,请及时处理 </td><td><div style="padding:10px 20px;"><a style="color:blue;" href='.$url.'>立即处理</a></div></td></tr>';
  1061. }
  1062. //问调表
  1063. $http = http('storage-allocate/coach/experience-remind', 'GET', $this->authUsername);
  1064. $response2 = formatResponse($http);
  1065. if($response2['status'] && $response2['data']){
  1066. $hasMessage=1;
  1067. foreach ($response2['data'] as $datum){
  1068. $id = $datum['id'];
  1069. $fixedCode= $datum['fixedCode'];
  1070. $msg .= '<tr><td><div style="padding:10px 20px;"><p style="line-height:30px;color:#619aff;">问调表提醒</p></div></td><td>您有设备问调表待填写,请及时处理 </td><td><div style="padding:10px 20px;"><a style="color:blue;" href="#" id="'.$id.'" fixedCode="'.$fixedCode.'" class="survey">立即处理</a></div></td></tr>';
  1071. }
  1072. }
  1073. $msg .= '</table>';
  1074. returnMsg(1,$msg, $hasMessage);
  1075. // if ($response['status']){
  1076. // returnMsg(1,'success', $response['data']);
  1077. // }else{
  1078. // returnMsg(0, $response['data']);
  1079. // }
  1080. }
  1081. /**
  1082. * 清洁消息提示
  1083. */
  1084. public function actionCleanConfirmWaning(){
  1085. $http = http('storage-allocate/coach/deliverWarning', 'GET', $this->authUsername);
  1086. $response = formatResponse($http);
  1087. if ($response['status']){
  1088. returnMsg(1,'success', $response['data']);
  1089. }else{
  1090. returnMsg(0, $response['data']);
  1091. }
  1092. }
  1093. /**
  1094. * 发货提示
  1095. */
  1096. public function actionSendConfirmWaning(){
  1097. $http = http('equip/plan/coach/cleanCommitWarning', 'GET', $this->authUsername);
  1098. $response = formatResponse($http);
  1099. if ($response['status']){
  1100. returnMsg(1,'success', $response['data']);
  1101. }else{
  1102. returnMsg(0, $response['data']);
  1103. }
  1104. }
  1105. /**
  1106. *意向订单转正式订单
  1107. */
  1108. public function actionFormalOrder(){
  1109. $orderNo = Req::get('orderNo'); //订单号
  1110. $goodsName = Req::get('goodsName'); //商品名
  1111. // $grade = Req::get('grade'); //年级
  1112. $surplus = Req::get('surplus'); //剩余
  1113. $goodsTypeId=Req::get('goodsTypeId');
  1114. $orderId=Req::get('orderId');
  1115. $schoolYear=Req::get('schoolYear');
  1116. $useGrade=Req::get('useGrade');
  1117. $result['orderNo']=$orderNo;
  1118. $result['goodsName']=$goodsName;
  1119. $result['surplus']=$surplus;
  1120. $result['goodsTypeId']=$goodsTypeId;
  1121. $result['orderId']=$orderId;
  1122. $result['schoolYear']=$schoolYear;
  1123. $result['useGrade']=$useGrade;
  1124. //根据级别,计算当前所在年级
  1125. $grade=1;
  1126. $semester=$this->schoolManager->getSemester($this->semesterId);
  1127. $nowSemesterSchoolYear=$semester['school_year'];
  1128. if(Yii::app()->params['grade_list']){
  1129. foreach (Yii::app()->params['grade_list'] as $id =>$param){
  1130. $gradeText[$id]=$param['grade_name'];
  1131. }
  1132. }
  1133. if(Yii::app()->params['section']==0){
  1134. $addValue=7;
  1135. // if(Yii::app()->params['grade_group_fixed_year']==4){
  1136. // $addValue=6;
  1137. // }else{
  1138. // $addValue=7;
  1139. // }
  1140. if(strpos($semester['semester_name'],'上学期')!==false){
  1141. $grade=intval($nowSemesterSchoolYear-$schoolYear+$addValue);
  1142. }elseif(strpos($semester['semester_name'],'下学期')!==false || strpos($semester['semester_name'],'暑假')!==false || strpos($semester['semester_name'],'寒假')!==false){
  1143. $grade=intval($nowSemesterSchoolYear-$schoolYear+$addValue-1);
  1144. }
  1145. }else{
  1146. if(strpos($semester['semester_name'],'上学期')!==false){
  1147. $grade=intval($nowSemesterSchoolYear-$schoolYear+1);
  1148. }elseif(strpos($semester['semester_name'],'下学期')!==false || strpos($semester['semester_name'],'暑假')!==false || strpos($semester['semester_name'],'寒假')!==false){
  1149. $grade=intval($nowSemesterSchoolYear-$schoolYear);
  1150. }
  1151. }
  1152. if(!isset($gradeText[$grade])){
  1153. Yii::app()->jump->error("获取订单数据异常,学年不正确");
  1154. }
  1155. $result['grade']=$grade;
  1156. $result['gradeText']=$gradeText[$grade];
  1157. $this->render('formalOrder', $result);
  1158. }
  1159. //申请转正
  1160. public function actionTurnOrder(){
  1161. $orderId=Req::post('orderId');
  1162. $officialNum=Req::post('officialNum');
  1163. $students=Req::post('studentInfo');
  1164. $suplus=Req::post('suplus');
  1165. $students=str_replace('&quot;','"',$students);
  1166. @$studentIdArr=json_decode($students,true);
  1167. if(!$studentIdArr){
  1168. returnMsg(0,'学生数据解析失败');
  1169. }
  1170. if(count($studentIdArr) > $suplus) {
  1171. returnMsg(0,'学生人数不能大于剩余名额');
  1172. }
  1173. $studentInfo=array();
  1174. $rex = "/\([\s\S]*\)/i"; //过滤括号
  1175. foreach ($studentIdArr as $val){
  1176. if(!$val['class'] || !$val['classId'] || !$val['value'] || !$val['name']){
  1177. continue;
  1178. }
  1179. $studentName=preg_replace($rex,"",$val['name']);
  1180. $temp=array(
  1181. 'clazzId'=>$val['classId'],
  1182. 'clazzName'=>$val['class'],
  1183. 'studentId'=>$val['value'],
  1184. 'studentName'=>$studentName
  1185. );
  1186. $studentInfo[]=$temp;
  1187. }
  1188. $params['orderId']=$orderId;
  1189. $params['officialNum']=$officialNum;
  1190. $params['students']=$studentInfo;
  1191. $http = http('order/coach/purpose/to/official/v2', 'post', $this->authUsername, $params);
  1192. $response = formatResponse($http);
  1193. if ($response['status']){
  1194. returnMsg(1,'success', $response['data']);
  1195. }else{
  1196. returnMsg(0, $response['data']);
  1197. }
  1198. }
  1199. //查看正式订单申请
  1200. public function actionViewTurnOrder(){
  1201. $goodsName=Req::get('goodsName');
  1202. $gradeText=Req::get('gradeText');
  1203. $surplus=Req::get('surplus');
  1204. $orderNo=Req::get('orderNo');
  1205. $orderId=Req::get('orderId');
  1206. $page=Req::get('page');
  1207. $quantity=Req::get('quantity');
  1208. if(!$page) $page=1;
  1209. $params['orderOfficialNo']=$orderNo;
  1210. $http = http('order/coach/official/details/'.$page, 'post', $this->authUsername, $params);
  1211. $response = formatResponse($http);
  1212. //请求日志
  1213. $log = http('order/coach/official/detail/'.$orderId, 'get', $this->authUsername, array());
  1214. $logList=formatResponse($log);
  1215. if(isset($logList['data']['orderLogs'])){
  1216. $result['logList']=$logList['data']['orderLogs'];
  1217. }else{
  1218. $result['logList']=array();
  1219. }
  1220. //debug($result['logList']['data']['orderLogs']);
  1221. $result['quantity']=$quantity;
  1222. $result['orderNo']=$orderNo;
  1223. $result['goodsName']=$goodsName;
  1224. $result['surplus']=$surplus;
  1225. $result['gradeText']=$gradeText;
  1226. $result['pages']=$response['data']['pages'];
  1227. $result['list']=$response['data']['list'];
  1228. $result['page']=$page;
  1229. $result['total']=$response['data']['total'];
  1230. $pageArr=array(
  1231. 'goodsName'=>$goodsName,
  1232. 'gradeText'=>$gradeText,
  1233. 'surplus'=>$surplus,
  1234. 'orderNo'=>$orderNo,
  1235. 'quantity'=>$quantity
  1236. );
  1237. $result['query']=http_build_query($pageArr);
  1238. $this->render('viewFormalOrder', $result);
  1239. }
  1240. /**
  1241. * 获取学生信息
  1242. */
  1243. public function actionGetFilterStudent()
  1244. {
  1245. $result = array();
  1246. $students = array();
  1247. if (Req::post('classId')) {
  1248. $classId = Req::post('classId');
  1249. } else {
  1250. returnMsg(0, 'classId必须');
  1251. }
  1252. $studentName=Req::post('studentName');
  1253. $orderId=Req::post('orderId');
  1254. $list = SStudentClassRelation::model()->getStudentInfoByClassId($classId,$studentName);
  1255. arrayMsort($list,'realname');
  1256. //获取本赛季已经开通的学生(页面需要 disabled)
  1257. $http = http('order/coach/official/students/'.$orderId, 'get', $this->authUsername);
  1258. $response = formatResponse($http);
  1259. if($response['status']){
  1260. $studentArr= $response['data'];
  1261. }else{
  1262. $studentArr=array();
  1263. }
  1264. if ($studentArr){
  1265. foreach ($studentArr as $k=>$v)
  1266. {
  1267. $students[] = $v;
  1268. }
  1269. }
  1270. if ($list) {
  1271. $result['list'] = $list;
  1272. $result['student'] = $students;
  1273. returnMsg(1, 'success', $result);
  1274. } else {
  1275. returnMsg(0, '暂无数据');
  1276. }
  1277. }
  1278. public function actionCloudPrintTask()
  1279. {
  1280. $centerId = Req::get('centerId') ? Req::get('centerId') : 0 ;
  1281. $status = Req::get('status') > -1 ? Req::get('status') : -1 ;
  1282. $goodsTypeId = Req::get('goodsTypeId') ? Req::get('goodsTypeId') : 0 ;
  1283. $subjectId = Req::get('subjectId') ? Req::get('subjectId') : 0 ;
  1284. $clazzName = Req::get('clazzName');
  1285. $taskName = Req::get('taskName');
  1286. $page = Req::get('page');
  1287. if(!$page) $page=1;
  1288. $http = http('cloud-print/task/coach/cloud-product/all', 'get', $this->authUsername, array());
  1289. $response = formatResponse($http);
  1290. $productList = array();
  1291. if(isset($response['data']) && $response['data']){
  1292. foreach ($response['data'] as $val){
  1293. if(!$val['isShow']){
  1294. $productList[$val['productId']] = $val['productName'];
  1295. }
  1296. }
  1297. }
  1298. $params = array();
  1299. $params['centerId'] = $centerId;
  1300. $params['status'] = $status;
  1301. $params['goodsTypeId'] = $goodsTypeId;
  1302. $params['subjectId'] = $subjectId;
  1303. $params['clazzName'] = $clazzName;
  1304. $params['taskName'] = $taskName;
  1305. $params['pageNum'] = $page;
  1306. $params['pageSize'] = 20;
  1307. $http = http('cloud-print/task/coach/page', 'post', $this->authUsername, $params);
  1308. $response = formatResponse($http);
  1309. $result['centerId'] =$centerId;
  1310. $result['status'] =$status;
  1311. $result['goodsTypeId']=$goodsTypeId;
  1312. $result['productList']=$productList;
  1313. $result['subjectId'] =$subjectId;
  1314. $result['clazzName']=$clazzName;
  1315. $result['taskName'] =$taskName;
  1316. $result['pages'] =$response['data'];
  1317. $result['list'] =$response['data']['list'];
  1318. $result['page'] =$page;
  1319. $result['total'] =$response['data']['total'];
  1320. $pageArr=array(
  1321. 'centerId '=> $centerId,
  1322. 'status' => $status,
  1323. 'goodsTypeId'=> $goodsTypeId,
  1324. 'subjectId' => $subjectId,
  1325. 'clazzName' => $clazzName,
  1326. 'taskName' => $taskName
  1327. );
  1328. $result['query']=http_build_query($pageArr);
  1329. $print_centers = array();
  1330. $print_centers_query = http('cloud-print/task/coach/center/list', 'get', $this->authUsername);
  1331. $print_centers_query = formatResponse($print_centers_query);
  1332. if(!empty($print_centers_query['data']))
  1333. {
  1334. foreach($print_centers_query['data'] as $print_center)
  1335. {
  1336. $print_centers[$print_center['centerId']] = $print_center['centerName'];
  1337. }
  1338. }
  1339. $result['print_centers'] = $print_centers;
  1340. $this->render('cloudPrintTask', $result);
  1341. }
  1342. public function actionTaskDetail()
  1343. {
  1344. $task_id = Req::get('task_id');
  1345. $http = http('cloud-print/task/coach/detail/'.$task_id, 'get', $this->authUsername);
  1346. $response = formatResponse($http);
  1347. $this->render('taskDetail', $response);
  1348. }
  1349. public function actionTaskCancel()
  1350. {
  1351. $task_id = Req::post('task_id');
  1352. $res = http('cloud-print/task/coach/return/'.$task_id, 'put', $this->authUsername);
  1353. $res = formatResponse($res);
  1354. if($res['status'] == 1)
  1355. {
  1356. $cptp_info = \BusinessCloudPrintTask::model()->find('cloud_print_id=:cloud_print_id',array(':cloud_print_id' => $task_id));
  1357. if(!empty($cptp_info)) Yii::app()->cache->deleteValue($cptp_info['redis_key']);
  1358. }
  1359. returnMsg($res['status'], $res['data']);
  1360. }
  1361. public function actionTaskReceive()
  1362. {
  1363. $task_id = Req::post('task_id');
  1364. $res = http('cloud-print/task/coach/receive/'.$task_id, 'put', $this->authUsername);
  1365. $res = formatResponse($res);
  1366. returnMsg($res['status'], $res['data']);
  1367. }
  1368. public function actionTaskDelete()
  1369. {
  1370. $task_id = Req::post('task_id');
  1371. $res = http('cloud-print/task/coach/delete/'.$task_id, 'delete', $this->authUsername);
  1372. $res = formatResponse($res);
  1373. returnMsg($res['status'], $res['data']);
  1374. }
  1375. public function actionTaskPReceive()
  1376. {
  1377. $task_ids = Req::post('task_ids');
  1378. $param['taskIds'] = $task_ids;
  1379. $res = http('cloud-print/task/coach/receive/batch', 'put', $this->authUsername, $param);
  1380. $res = formatResponse($res);
  1381. returnMsg($res['status'], $res['data']);
  1382. }
  1383. public function actionContingencyPrint()
  1384. {
  1385. $this->render('contingencyPrint');
  1386. }
  1387. //保存应急打印任务
  1388. public function actionSaveContingencyPrint()
  1389. {
  1390. ini_set ('memory_limit', '300M');
  1391. if(!$_FILES)
  1392. {
  1393. echo json_encode(array('status' => 0, 'message' => '文件大小超过范围'));exit;
  1394. }else{
  1395. if(!isset($_FILES['file1']) || !isset($_FILES['file1']['size']) || $_FILES['file1']['size'] > 10485760)
  1396. {
  1397. echo json_encode(array('status' => 0, 'message' => '文件大小超过范围'));exit;
  1398. }
  1399. $info = $_FILES['file1']['name'];
  1400. $temp = explode('.', $info);
  1401. $type = end($temp);
  1402. $fileType = array('rar', 'zip');
  1403. if (!in_array($type, $fileType)) {
  1404. echo json_encode(array('status' => 0, 'message' => '请上传指定类型文件'));exit;
  1405. }
  1406. }
  1407. if (Yii::app()->request->getIsPostRequest())
  1408. {
  1409. // 保存上传文件至服务器
  1410. $pathName = dirname(dirname(dirname(__FILE__))).'/upload/tmpDir/ims/cloudTask/'. $this->schoolId.date('Y') .'/'. date('m') . '/'.date('d'). '/';
  1411. $pathName1 = 'upload/tmpDir/ims/cloudTask/'. $this->schoolId.date('Y') .'/'. date('m') . '/'.date('d'). '/';
  1412. if (!file_exists($pathName))
  1413. {
  1414. mkdir($pathName, 0777, true);
  1415. }
  1416. $ucloud = new HuaweiCloud();
  1417. $fileName = iconv("UTF-8", "gb2312",$_FILES['file1']['name']);
  1418. $extName = substr($_FILES['file1']['name'],strrpos($_FILES['file1']['name'],'.'));
  1419. if (!move_uploaded_file($_FILES['file1']['tmp_name'], $pathName.$fileName))
  1420. {
  1421. echo json_encode(array('status' => 0, 'message' => '文件上传失败'));
  1422. @unlink($pathName1.$fileName);exit;
  1423. }else{
  1424. $meg = $ucloud->putFile('zsyas2/ims/cloudTask/'.$this->schoolId.'/'.time().mt_rand().$extName,$pathName1.$fileName);
  1425. if($meg['status'] == 0){
  1426. echo json_encode(array('status' => 0, 'message' => $meg['msg']));exit();
  1427. }else{
  1428. $url = $meg['url'];
  1429. $url = str_replace("%2F","/",$url);
  1430. }
  1431. }
  1432. @unlink($pathName1.$fileName);
  1433. //任务发送ims端
  1434. $params = array(
  1435. "taskName" => Req::post('taskName'),
  1436. "centerId" => $this->getPrintCenter(),
  1437. 'subjectId' => Req::post('subject'),
  1438. 'grade' => Req::post('grade'),
  1439. 'printPieces' => Req::post('copies'),
  1440. 'singlePiecePages' => Req::post('eachCopies'),
  1441. 'sheetType' => Req::post('sheetType'),
  1442. 'url' => $url,
  1443. 'sendTime' => date('Y-m-d H:i:s')
  1444. );
  1445. $http = http('cloud-print/task/coach/add/emergency', 'POST', $this->authUsername, $params);
  1446. $response = formatResponse($http);
  1447. if ($response['status']) {
  1448. echo json_encode(array('status' => 1, 'message' => 'ok'));exit;
  1449. }else{
  1450. echo json_encode(array('status' => 0, 'message' => $response['data']));exit;
  1451. }
  1452. }
  1453. }
  1454. //获取云印点
  1455. protected function getPrintCenter(){
  1456. //获取云印点
  1457. if(Yii::app()->cache->getValue("cloud_print_coach_".$this->schoolId."_centerId"))
  1458. {
  1459. $centerId = Yii::app()->cache->getValue("cloud_print_coach_".$this->schoolId."_centerId");
  1460. }else{
  1461. $http1 = http('cloud-print/task/coach/center','GET', $this->authUsername, array());
  1462. $response1 = formatResponse($http1);
  1463. if(isset($response1['data']['centerId']) && is_numeric($response1['data']['centerId'])){
  1464. $centerId = $response1['data']['centerId'];
  1465. Yii::app()->cache->setValue("cloud_print_coach_".$this->schoolId."_centerId", $centerId, 86400);
  1466. }else{
  1467. echo json_encode(array('status' => 0, 'message' => '获取云印点失败'));exit;
  1468. }
  1469. }
  1470. return $centerId;
  1471. }
  1472. public function actionProductSign(){
  1473. $type = Req::get('type');
  1474. $begin = Req::get('begin');
  1475. $end = Req::get('end');
  1476. $name = Req::get('name');
  1477. $page=Req::get('page');
  1478. if(!$page) $page=1;
  1479. $result=array();
  1480. $result['list']=array();
  1481. $result['page']=array();
  1482. $param=array();
  1483. $param['page']=$page;
  1484. if($type){
  1485. $param['type']=$type;
  1486. }
  1487. if($begin){
  1488. if(strtotime($begin)>time()){
  1489. Yii::app()->jump->error('开始时间不能大于当前时间');
  1490. }
  1491. $param['begin']=date('Y-m-d H:i:s',strtotime($begin));
  1492. }
  1493. if($end){
  1494. if(strtotime($end)>time()){
  1495. Yii::app()->jump->error('结束时间不能大于当前时间');
  1496. }
  1497. $param['end']=date('Y-m-d H:i:s',(strtotime($end)+86400));
  1498. }
  1499. if($name){
  1500. $param['name']=$name;
  1501. }
  1502. $res = http('order/deliver/coach/query', 'post', $this->authUsername, $param);
  1503. $res = formatResponse($res);
  1504. if($res['status']==1){
  1505. $result['list']=$res['data']['list'];
  1506. $result['page']=$res['data'];
  1507. //读取AndroidApp下载链接
  1508. $softwareUrlAndroid=$this->schoolManager->getNewVersionBySoftwareId(12);
  1509. $result['softwareUrlAndroid']=$softwareUrlAndroid;
  1510. $result['softwareUrlIos']='https://testflight.apple.com/join/o0NJOqbz';
  1511. $this->render('productSign', $result);
  1512. }else{
  1513. Yii::app()->jump->error($res['data']);
  1514. }
  1515. }
  1516. public function actionViewProductSign(){
  1517. $id = Req::get('id');
  1518. $res = http('order/deliver/coach/detail/'.$id, 'get', $this->authUsername);
  1519. $res = formatResponse($res);
  1520. if($res['status']==1){
  1521. $this->render('viewProductSign',$res['data']);
  1522. }else{
  1523. Yii::app()->jump->error("接口错误");
  1524. }
  1525. }
  1526. /**
  1527. * @param $seasonId
  1528. * @param $goodsTypeId
  1529. * @param $classId
  1530. * @return array
  1531. * 获取已经订购的学生(意向订单)
  1532. */
  1533. public function getTrialStudentByStudentList($yearSemester,$schoolYearId, $goodsTypeId, $classId,$subjectId,$studentList,$trialType,$grade,$startTime,$semesterId)
  1534. {
  1535. $param=array();
  1536. $param['schoolYearId']=$schoolYearId;
  1537. $param['semesterId']=$semesterId;
  1538. $param['yearSemester']=$yearSemester;
  1539. $param['clazzId']=$classId;
  1540. $param['goodsTypeId']=$goodsTypeId;
  1541. $param['subjectId']=$subjectId;
  1542. $param['studentIds']=$studentList;
  1543. $param['trialType']=$trialType;
  1544. $param['grade']=$grade;
  1545. $param['beginTime']=$startTime;
  1546. $http = http('order/coach/trial/students', 'post', $this->authUsername,$param);
  1547. $response = formatResponse($http);
  1548. if($response['status']){
  1549. return $response['data'];
  1550. }else{
  1551. return array();
  1552. }
  1553. }
  1554. /**
  1555. * 明细订单导出
  1556. */
  1557. public function actionDetailOrderExcel(){
  1558. $params = array();
  1559. // if (Req::post('orderNo')){
  1560. // $params['orderOfficialNo'] = Req::post('orderNo');
  1561. // }
  1562. if (Req::post('orderOfficialNo')){
  1563. $params['orderOfficialNo'] = Req::post('orderOfficialNo');
  1564. }
  1565. if(Req::post('goodsId')){
  1566. $params['goodsId'] = Req::post('goodsId');
  1567. }
  1568. if(Req::post('packageId')){
  1569. $params['packageId'] = Req::get('packageId');
  1570. }
  1571. if(Req::post('useStatus')){
  1572. $params['useStatus'] = Req::post('useStatus')-1;
  1573. }
  1574. if(Req::post('payStatus')){
  1575. $params['payStatus'] = Req::post('payStatus')-1;
  1576. }
  1577. if(Req::post('takeStatus')){
  1578. $params['takeStatus'] = Req::post('takeStatus')-1;
  1579. }
  1580. if(Req::post('studentName') && Req::post('studentName')!=''){
  1581. $params['studentName'] = Req::post('studentName');
  1582. }
  1583. if(Req::post('orderTypes')){
  1584. $params['orderType'] = Req::post('orderTypes')-1;
  1585. }
  1586. if(Req::post('semesterTypes')){
  1587. $params['semester'] = Req::post('semesterTypes')-1;
  1588. }
  1589. if(Req::post('schoolYearName') && Req::post('schoolYearName')!=''){
  1590. $params['schoolYearId'] = Req::post('schoolYearName');
  1591. }
  1592. if(Req::post('className') && Req::post('className')!=''){
  1593. $params['clazzName'] = Req::post('className');
  1594. }
  1595. if(Req::post('beginTime') && Req::post('beginTime')!=''){
  1596. $params['beginTime'] = date('Y-m-d H:i:s',strtotime(Req::post('beginTime')));
  1597. }
  1598. if(Req::post('endTime') && Req::post('endTime')!=''){
  1599. $params['endTime'] = date('Y-m-d 23:59:59',strtotime(Req::post('endTime')));
  1600. }
  1601. $http = http('order/coach/official/details/export','post', $this->authUsername, $params);
  1602. $response = formatResponse($http);
  1603. if($response){
  1604. echo json_encode($response);exit;
  1605. }else{
  1606. echo json_encode(array("status"=>0,"error"=>"导出失败"));exit;
  1607. }
  1608. }
  1609. public function actionGetStudentInfo(){
  1610. $params = array();
  1611. if (Req::post('studentName')){
  1612. $params['studentName'] = Req::post('studentName');
  1613. }
  1614. if(Req::post('orderNo')){
  1615. $params['orderNo'] = Req::post('orderNo');
  1616. }
  1617. $http = http('order/coach/trial/students/list', 'post', $this->authUsername, $params);
  1618. $response = formatResponse($http);
  1619. // debug($response);
  1620. if($response){
  1621. echo json_encode($response);exit;
  1622. }else{
  1623. echo json_encode(array("status"=>0,"error"=>"导出失败"));exit;
  1624. }
  1625. }
  1626. /*
  1627. *未签收产品列表7天内
  1628. * 根据产品/考试id ,获取已下载的班级信息
  1629. * type:1 考试,2数学阶段个性化学习宝,3二轮提分手册,4考后指导,5晨读词汇 6阶段复习,7错题本,8二步个性化学习宝,9三步个性化学习宝,10 英语外刊阅读
  1630. * 1,2,4,6,7,8,9 考试类型
  1631. */
  1632. public function actionUnSign(){
  1633. $postArr=array();
  1634. $list=array();
  1635. //查询7天内考试
  1636. $examModel=new SExam();
  1637. $examParam=$examModel->getExamIdByTime();
  1638. //二轮提分指导手册
  1639. $mathReviewModel=new SMathReviewSetting();
  1640. $mathParam=$mathReviewModel->getMathReview();
  1641. //晨读词汇
  1642. $weekParam=$mathReviewModel->getEnglishWeek();
  1643. //外刊阅读
  1644. $readingParam=$mathReviewModel->getEnglishReading();
  1645. $postArr=array_merge($examParam,$mathParam,$weekParam,$readingParam);
  1646. // $postArr=array_merge($postArr,$mathParam);
  1647. // $postArr=array_merge($postArr,$weekParam);
  1648. // $postArr=array_merge($postArr,$readingParam);
  1649. // debug(json_encode($postArr));
  1650. //接口过滤已签名数据
  1651. $http = http('order/deliver/coach/no-deliver/query', 'post', $this->authUsername, $postArr);
  1652. $response = formatResponse($http);
  1653. if($response['status']){
  1654. $list= $response['data'];
  1655. }
  1656. $this->render('productUnSign',array('list'=>$list));
  1657. }
  1658. //回款反馈
  1659. public function actionPayment(){
  1660. $params = array();
  1661. if(Req::get('grade')){
  1662. $params['grade']=Req::get('grade');
  1663. }
  1664. if(Req::get('schoolYearId')){
  1665. $params['schoolYearId']=Req::get('schoolYearId');
  1666. }
  1667. if(Req::get('goodsId')){
  1668. $params['goodsId']=Req::get('goodsId');
  1669. }
  1670. if(Req::get('semester')){
  1671. $params['semester']=Req::get('semester')-1;
  1672. }
  1673. if(Req::get('startTime')){
  1674. $params['startTime']=Req::get('startTime').' 0:0:0';
  1675. }
  1676. if(Req::get('endTime')){
  1677. $params['endTime']=Req::get('endTime').' 0:0:0';
  1678. }
  1679. if(Req::get('page')){
  1680. $params['pageNum']=Req::get('page');
  1681. }else{
  1682. $params['pageNum']=1;
  1683. }
  1684. //列表
  1685. $http = http('finance/back/coach/client/list', 'post', $this->authUsername, $params);
  1686. $response = formatResponse($http);
  1687. if($response['status']==1){
  1688. $result['list']=$response['data']['list'];
  1689. $result['page'] = $response['data'];
  1690. }else{
  1691. if(isset($response['data']) && $response['data']){
  1692. Yii::app()->jump->error($response['data']);
  1693. }else{
  1694. Yii::app()->jump->error("保存失败");
  1695. }
  1696. }
  1697. //获取学年
  1698. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  1699. $response = formatResponse($http);
  1700. $result['schoolYear'] = $response['data'];
  1701. $goodArr = $this->getGood();
  1702. $result['goodList'] = $goodArr;
  1703. $result['params']=$params;
  1704. $this->render('paymentList',$result);
  1705. }
  1706. //新增回款反馈
  1707. public function actionNewPayment(){
  1708. if (Yii::app()->request->getIsPostRequest()){
  1709. //保存
  1710. $param['orderId']=Req::post('orderId');
  1711. $param['useNum']=Req::post('use_person');
  1712. $param['schoolYearId']=Req::post('schoolYearId');
  1713. if(Req::post('semester')){
  1714. $param['semester']=Req::post('semester')-1;
  1715. }
  1716. $param['grade']=Req::post('grade');
  1717. $param['goodsId']=Req::post('goodsId');
  1718. $param['downloadNum']=Req::post('down_person');
  1719. $param['price']=Req::post('price');
  1720. $param['feeNumUp']=Req::post('feeNumUp');
  1721. $param['priceSumUp']=Req::post('priceSumUp');
  1722. $param['feeNumDown']=Req::post('feeNumDown');
  1723. $param['priceSumDown']=Req::post('priceSumDown');
  1724. $param['feeTime']=date('Y-m-d H:i:s',strtotime(Req::post('charge_time')));
  1725. if(Req::post('pay_time')){
  1726. $param['remitDate']=date('Y-m-d H:i:s',strtotime(Req::post('pay_time')));
  1727. }
  1728. $param['remark']=Req::post('mark');
  1729. if(Req::post('id')){
  1730. $param['bcId']=Req::post('id');
  1731. $http = http('finance/back/coach/edit', 'post', $this->authUsername,$param);
  1732. }else{
  1733. $http = http('finance/back/coach/add', 'post', $this->authUsername,$param);
  1734. }
  1735. $response = formatResponse($http);
  1736. if($response['status']==1){
  1737. $this->redirect('/imsSale/payment');
  1738. }else{
  1739. if(isset($response['data']) && $response['data']){
  1740. Yii::app()->jump->error($response['data']);
  1741. }else{
  1742. Yii::app()->jump->error("保存失败");
  1743. }
  1744. }
  1745. }
  1746. $params = array();
  1747. //销售订单列表
  1748. $http = http('order/coach/purpose/list', 'get', $this->authUsername);
  1749. $response = formatResponse($http);
  1750. //debug($response);
  1751. if($response['status']==1){
  1752. $result['orderList']=$response['data'];
  1753. }
  1754. //获取学年
  1755. $http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
  1756. $response = formatResponse($http);
  1757. $result['schoolYear'] = $response['data'];
  1758. //debug($http);
  1759. $goodArr = $this->getGood();
  1760. $result['goodList'] = $goodArr;
  1761. $this->render('newPayment',$result);
  1762. }
  1763. //编辑回款反馈
  1764. public function actionEditPayment(){
  1765. $id=Req::get('id');
  1766. $http = http('finance/back/coach/'.$id, 'get', $this->authUsername);
  1767. $response = formatResponse($http);
  1768. //debug($response);
  1769. if($response['status']==1){
  1770. $result['data']=$response['data'];
  1771. }
  1772. //销售订单列表
  1773. $http = http('order/coach/purpose/list', 'get', $this->authUsername);
  1774. $response = formatResponse($http);
  1775. if($response['status']==1){
  1776. $result['orderList']=$response['data'];
  1777. }
  1778. //获取学年
  1779. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  1780. $response = formatResponse($http);
  1781. $result['schoolYear'] = $response['data'];
  1782. //debug($http);
  1783. $goodArr = $this->getGood();
  1784. $result['goodList'] = $goodArr;
  1785. $this->render('editPayment',$result);
  1786. }
  1787. //服务费查询
  1788. public function actionServiceCharge(){
  1789. $data=array();
  1790. $page=Req::get('page');
  1791. $param=array();
  1792. if(Req::get('semesterId')){
  1793. $param['semesterId']=Req::get('semesterId')-1;
  1794. }
  1795. if(Req::get('schoolYearId')){
  1796. $param['schoolYearId']=Req::get('schoolYearId');
  1797. }
  1798. if(Req::get('end')){
  1799. $param['end']=Req::get('end')." 23:59:59";
  1800. }
  1801. if(Req::get('begin')){
  1802. $param['begin']=Req::get('begin')." 00:00:00";
  1803. }
  1804. if(!$page) $page=1;
  1805. $http = http('coach-service-charge/coach/batch/query?pageNum='.$page, 'post', $this->authUsername,$param);
  1806. $response = formatResponse($http);
  1807. if($response['status']=1){
  1808. $data['list']=$response['data']['list'];
  1809. $data['page']=$response['data'];
  1810. }else{
  1811. $data['list']=array();
  1812. $data['page']=array();
  1813. }
  1814. //获取学年
  1815. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  1816. $response = formatResponse($http);
  1817. $data['schoolYear'] = $response['data'];
  1818. $this->render('serviceCharge',$data);
  1819. }
  1820. //商品变更
  1821. public function actionGoodsChange(){
  1822. $result=array();
  1823. $seasonId=Req::get('seasonId');
  1824. $begin=Req::get('begin');
  1825. $end=Req::get('end');
  1826. $status=Req::get('status');
  1827. $page = Req::get('page') ? Req::get('page') : 1;
  1828. $params=array();
  1829. if($seasonId){
  1830. $params['seasonId']=$seasonId;
  1831. }
  1832. if($begin){
  1833. $params['begin']=$begin.' 00:00:00';
  1834. }
  1835. if($end){
  1836. $params['end']=$end.' 23:59:59';
  1837. }
  1838. if($status){
  1839. $params['status']=$status-1;
  1840. }
  1841. if($page){
  1842. $params['pageNum']=$page;
  1843. }
  1844. //销售订单列表
  1845. $http = http('order/goods/change/coach/page', 'post', $this->authUsername,$params);
  1846. $response = formatResponse($http);
  1847. if($response['status']==1){
  1848. $result['list']=$response['data']['list'];
  1849. $result['page']=$response['data'];
  1850. }else{
  1851. $result['list']=array();
  1852. $result['page']=array();
  1853. }
  1854. $result['seasonId'] = $seasonId;
  1855. $result['begin'] = $begin;
  1856. $result['end'] = $end;
  1857. $result['status'] = $status;
  1858. //读取赛季
  1859. $seasonList=$this->getEnableSeason();
  1860. $result['seasonList']=$seasonList;
  1861. $this->render('goodsChange',$result);
  1862. }
  1863. //查看服务费详情
  1864. public function actionViewServiceCharge(){
  1865. $batchId=Req::get('batchId');
  1866. $data=array();
  1867. //查询服务费核算结果
  1868. $http = http('coach-service-charge/coach/batch/'.$batchId.'/query', 'get', $this->authUsername);
  1869. $response = formatResponse($http);
  1870. $data['batches']=$response['data'];
  1871. //查询订单维度核算过程
  1872. $http = http('coach-service-charge/coach/batch/'.$batchId.'/order/query?pageNum=1', 'get', $this->authUsername);
  1873. $response = formatResponse($http);
  1874. $data['order']=$response['data'];
  1875. //查询本学期扣款记录
  1876. $http = http('coach-service-charge/coach/deduction/query/'.$batchId.'?pageNum=1', 'get', $this->authUsername);
  1877. $response = formatResponse($http);
  1878. $data['recorder']=$response['data'];
  1879. $this->render('viewServiceCharge',$data);
  1880. }
  1881. //查询订单维度核算过程
  1882. public function actionAjaxSearchServiceCharge(){
  1883. $batchId=Req::post('batchId');
  1884. $page=Req::post('page');
  1885. $type=Req::post('type');
  1886. if(!$page) $page=1;
  1887. if($type==1){
  1888. //查询本学期扣款记录
  1889. $http = http('coach-service-charge/coach/deduction/query/'.$batchId.'?pageNum='.$page, 'get', $this->authUsername);
  1890. }else{
  1891. //查询订单维度核算过程
  1892. $http = http('coach-service-charge/coach/batch/'.$batchId.'/order/query?pageNum='.$page, 'get', $this->authUsername);
  1893. }
  1894. $response = formatResponse($http);
  1895. returnMsg(1,'success',$response['data']);
  1896. }
  1897. //查询未订购学生
  1898. public function actionSearchNoBuy(){
  1899. $param['schoolYearId']=Req::post('schoolYearId');
  1900. $param['gradeId']=Req::post('grade');
  1901. $param['pageNum']=Req::post('page');
  1902. if(Req::post('semesterId')){
  1903. $param['semesterId']=Req::post('semesterId')-1;
  1904. }
  1905. if(!$param['pageNum']) $param['pageNum']=1;
  1906. $http = http('order/coach/student/not-buy/page', 'post', $this->authUsername,$param);
  1907. $response = formatResponse($http);
  1908. $result['status']=0;
  1909. if($response['status']==1){
  1910. $result['status']=1;
  1911. $result['data']['list']=$response['data']['list'];
  1912. $result['data']['total_page']=$response['data']['pages'];
  1913. $result['data']['now_page']=$param['pageNum'];
  1914. }
  1915. exit(json_encode($result));
  1916. }
  1917. //导出未订购学生
  1918. public function actionExportNoBuyStudent(){
  1919. $param['schoolYearId']=Req::post('schoolYearId');
  1920. $param['gradeId']=Req::post('grade');
  1921. if(Req::post('semesterId')){
  1922. $param['semesterId']=Req::post('semesterId')-1;
  1923. }
  1924. $http = http('order/coach/student/not-buy/export', 'post', $this->authUsername,$param);
  1925. $response = formatResponse($http);
  1926. $result['status']=0;
  1927. if($response['status']==1){
  1928. $result['status']=1;
  1929. $result['data']=$response['data'];
  1930. }else{
  1931. $result['data']=$response['data'];
  1932. }
  1933. exit(json_encode($result));
  1934. }
  1935. //新建商品变更
  1936. public function actionNewGoodsChange(){
  1937. //获取学年
  1938. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  1939. $response = formatResponse($http);
  1940. $result['schoolYear'] = $response['data'];
  1941. $this->render('newGoodsChange',$result);
  1942. }
  1943. //根据学年查询可用于变更的销售订单
  1944. public function actionCanChangeOrder(){
  1945. $result=array();
  1946. $result['status']=0;
  1947. $schoolYearId=Req::post('schoolYearId');
  1948. if(!$schoolYearId){
  1949. $result['msg']='参数异常';
  1950. exit(json_encode($result));
  1951. }
  1952. $http = http('order/goods/change/coach/purpose-can-change-list', 'post', $this->authUsername,array('schoolYearId'=>$schoolYearId));
  1953. $response = formatResponse($http);
  1954. if($response['status']==1){
  1955. $result['status']=1;
  1956. $result['data']=$response['data'];
  1957. }
  1958. exit(json_encode($result));
  1959. }
  1960. //根据销售订单查询需要变更的财务订单
  1961. public function actionNeedChangeOrder(){
  1962. $result=array();
  1963. $result['status']=0;
  1964. $orderId=Req::post('orderId');
  1965. if(!$orderId){
  1966. $result['msg']='参数异常';
  1967. exit(json_encode($result));
  1968. }
  1969. $http = http('order/goods/change/coach/official-list/'.$orderId, 'get', $this->authUsername);
  1970. $response = formatResponse($http);
  1971. if($response['status']==1){
  1972. $result['status']=1;
  1973. $result['data']=$response['data'];
  1974. }else{
  1975. $result['msg']=$response['data'];
  1976. }
  1977. exit(json_encode($result));
  1978. }
  1979. //查询财务订单的学生列表
  1980. public function actionOrderStudentList(){
  1981. $result=array();
  1982. $result['status']=0;
  1983. $orderId=Req::post('orderId');
  1984. if(!$orderId){
  1985. $result['msg']='参数异常';
  1986. exit(json_encode($result));
  1987. }
  1988. $http = http('order/goods/change/coach/order-students/'.$orderId, 'get', $this->authUsername);
  1989. $response = formatResponse($http);
  1990. if($response['status']==1){
  1991. $result['status']=1;
  1992. $result['data']=$response['data'];
  1993. }
  1994. exit(json_encode($result));
  1995. }
  1996. //查看变更订单详情
  1997. public function actionViewGoodsChange(){
  1998. $ogcId=Req::get('id');
  1999. $page=Req::get('page') ? Req::get('page') : 1;
  2000. if(!$ogcId){
  2001. Yii::app()->jump->error("参数异常");
  2002. }
  2003. $http = http('order/goods/change/coach/'.$ogcId, 'get', $this->authUsername);
  2004. $response = formatResponse($http);
  2005. if($response['status']==1){
  2006. $result=$response['data'];
  2007. }else{
  2008. Yii::app()->jump->error($response['data']);
  2009. }
  2010. //读取订单学生
  2011. $http = http('order/goods/change/coach/'.$ogcId.'/students?pageNum='.$page, 'get', $this->authUsername);
  2012. $response = formatResponse($http);
  2013. $result['page']=$response['data'];
  2014. $result['id']=$ogcId;
  2015. $result['students']=$response['data']['list'];
  2016. $this->render('viewGoodsChange',$result);
  2017. }
  2018. //保存商品变更
  2019. public function actionSaveGoodsChange(){
  2020. $ogcId=Req::post('ogcId');
  2021. $oldOrderId=Req::post('oldOrderId');
  2022. $purposeOrderId=Req::post('purposeOrderId');
  2023. $studentIdArr=Req::post('studentList');
  2024. $goodsChange=Req::post('goodsChange');
  2025. $studentIdArr=str_replace('&quot;','"',$studentIdArr);
  2026. @$studentIdArr=json_decode($studentIdArr,true);
  2027. $students = array();
  2028. if(!$studentIdArr){
  2029. returnMsg(0,'学生数据解析失败');
  2030. }
  2031. foreach ($studentIdArr as $k=>$v){
  2032. if(!$v['value']){
  2033. continue;
  2034. }
  2035. $students[]=$v['value'];
  2036. }
  2037. $params['studentIds'] = $students;
  2038. $params['oldOrderId'] = $oldOrderId;
  2039. $params['purposeOrderId'] = $purposeOrderId;
  2040. $params['goodsChange'] = $goodsChange;
  2041. if($ogcId){
  2042. $http = http('order/goods/change/coach/'.$ogcId, 'PUT', $this->authUsername,$params);
  2043. }else{
  2044. $http = http('order/goods/change/coach', 'post', $this->authUsername,$params);
  2045. }
  2046. $response = formatResponse($http);
  2047. if($response['status']==1){
  2048. returnMsg(1,'提交成功');
  2049. }else{
  2050. returnMsg(0,$response['data']);
  2051. }
  2052. }
  2053. //查询用于商品变更的订单
  2054. public function actionSearchGoodsChange(){
  2055. if(Req::get('schoolYearId')){
  2056. $param['schoolYearId']=Req::get('schoolYearId');
  2057. }
  2058. if(Req::get('grade')){
  2059. $param['grade']=Req::get('grade');
  2060. }
  2061. $param['pageNum']= Req::get('page') ? Req::get('page') : 1;
  2062. //获取学年
  2063. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  2064. $response = formatResponse($http);
  2065. $result['schoolYear'] = $response['data'];
  2066. $http = http('order/goods/change/coach/purpose-page', 'post', $this->authUsername,$param);
  2067. $response = formatResponse($http);
  2068. if($response['status']==1){
  2069. $result['list']=$response['data']['list'];
  2070. $result['page']=$response['data'];
  2071. }else{
  2072. $result['list']=array();
  2073. $result['page']=array();
  2074. }
  2075. //debug($result);
  2076. $this->render('searchGoodsChange',$result);
  2077. }
  2078. //重新提交变更订单(编辑)
  2079. public function actionEditGoodsChange(){
  2080. $ogcId=Req::get('id');
  2081. if(!$ogcId){
  2082. Yii::app()->jump->error("参数异常");
  2083. }
  2084. $http = http('order/goods/change/coach/'.$ogcId, 'get', $this->authUsername);
  2085. $response = formatResponse($http);
  2086. if($response['status']==1){
  2087. $result=$response['data'];
  2088. }else{
  2089. Yii::app()->jump->error($response['data']);
  2090. }
  2091. //获取学年
  2092. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  2093. $response = formatResponse($http);
  2094. $result['schoolYear'] = $response['data'];
  2095. $result['ogcId']=$ogcId;
  2096. $result['studentIds']=array();
  2097. $this->render('editGoodsChange',$result);
  2098. }
  2099. //商品变更查询可变更人数
  2100. public function actionSearchChangeNum(){
  2101. $orderId=Req::post('orderId');
  2102. $financeOrderId=Req::post('financeOrderId');
  2103. $result['status']=0;
  2104. $http = http('order/goods/change/coach/can-change-num/'.$financeOrderId.'/'.$orderId, 'get', $this->authUsername);
  2105. $response = formatResponse($http);
  2106. if($response['status']==1){
  2107. $result['status']=1;
  2108. $result['data']=$response['data'];
  2109. }else{
  2110. Yii::app()->jump->error($response['data']);
  2111. }
  2112. exit(json_encode($result));
  2113. }
  2114. //服务费查询密码
  2115. public function actionValidationPwd(){
  2116. $password=Req::post('password');
  2117. $result['status']=0;
  2118. $http = http('coach-service-charge/coach/validation/'.$password, 'get', $this->authUsername);
  2119. $response = formatResponse($http);
  2120. if($response['status']==1){
  2121. $result['status']=1;
  2122. }else{
  2123. $result['msg']=$response['data'];
  2124. }
  2125. exit(json_encode($result));
  2126. }
  2127. //服务费修改查询密码
  2128. public function actionUpdateServicePwd(){
  2129. $password=Req::post('password');
  2130. $newPassword=Req::post('newPassword');
  2131. $checkPassword=Req::post('checkPassword');
  2132. $result['status']=0;
  2133. if(!$password || !$newPassword || !$checkPassword){
  2134. $result['msg']='密码不能为空';
  2135. exit(json_encode($result));
  2136. }
  2137. if($newPassword!=$checkPassword){
  2138. $result['msg']='两次密码输入不一致';
  2139. exit(json_encode($result));
  2140. }
  2141. $params=array(
  2142. 'oldPassword'=>$password,
  2143. 'newPassword'=>$newPassword,
  2144. 'confirmPassword'=>$checkPassword,
  2145. );
  2146. $http = http('coach-service-charge/coach/update/service-password', 'post', $this->authUsername,$params);
  2147. $response = formatResponse($http);
  2148. if($response['status']==1){
  2149. $result['status']=1;
  2150. }else{
  2151. $result['msg']=$response['data'];
  2152. }
  2153. exit(json_encode($result));
  2154. }
  2155. //销售订单推送名单
  2156. public function actionPushList(){
  2157. $orderId= Req::get('orderId');
  2158. $clazzId= Req::get('clazzId');
  2159. $isPay= Req::get('isPay');
  2160. $page = Req::get('page') ? Req::get('page') : 1;
  2161. $params=array(
  2162. 'orderId'=>$orderId,
  2163. 'pageNum'=>$page
  2164. );
  2165. if($clazzId){
  2166. $params['clazzId']=$clazzId;
  2167. }
  2168. if($isPay){
  2169. $params['isPay']=intval($isPay-1);
  2170. }
  2171. $res = http('order/coach/push-student/page', 'post', $this->authUsername,$params);
  2172. $response = formatResponse($res);
  2173. if($response['status']==1){
  2174. $result['list']=$response['data']['list'];
  2175. $result['page']=$response['data'];
  2176. }else{
  2177. $result['list']=array();
  2178. $result['page']=array();
  2179. }
  2180. //读取班级
  2181. $res = http('order/coach/push-student/clazz/'.$orderId, 'get', $this->authUsername);
  2182. $response = formatResponse($res);
  2183. if($response['status']==1){
  2184. $result['classList']=$response['data'];
  2185. }
  2186. $this->render('pushList',$result);
  2187. }
  2188. //销售订单推送名单导出
  2189. public function actionPushListExport(){
  2190. $orderId= Req::post('orderId');
  2191. $clazzId= Req::post('clazzId');
  2192. $isPay= Req::post('isPay');
  2193. $params=array(
  2194. 'orderId'=>$orderId,
  2195. );
  2196. if($clazzId){
  2197. $params['clazzId']=$clazzId;
  2198. }
  2199. if($isPay){
  2200. $params['isPay']=intval($isPay-1);
  2201. }
  2202. $res = http('order/coach/push-student/export', 'post', $this->authUsername,$params);
  2203. $response = formatResponse($res);
  2204. if($response){
  2205. echo json_encode($response);exit;
  2206. }else{
  2207. echo json_encode(array("status"=>0,"error"=>"导出失败"));exit;
  2208. }
  2209. }
  2210. //回款反馈申请
  2211. public function actionPaymentApply(){
  2212. $params = array();
  2213. if(Req::get('grade')){
  2214. $params['grade']=Req::get('grade');
  2215. }
  2216. if(Req::get('schoolYearId')){
  2217. $params['schoolYearId']=Req::get('schoolYearId');
  2218. }
  2219. if(Req::get('semester')){
  2220. $params['semester']=Req::get('semester')-1;
  2221. }
  2222. if(Req::get('recordNo')){
  2223. $params['recordNo']=Req::get('recordNo');
  2224. }
  2225. if(Req::get('bcNo')){
  2226. $params['bcNo']=Req::get('bcNo');
  2227. }
  2228. if(Req::get('page')){
  2229. $params['pageNum']=Req::get('page');
  2230. }else{
  2231. $params['pageNum']=1;
  2232. }
  2233. //列表
  2234. $http = http('finance/back/coach/client/record/page', 'post', $this->authUsername, $params);
  2235. $response = formatResponse($http);
  2236. if($response['status']==1){
  2237. $result['list']=$response['data']['list'];
  2238. $result['page'] = $response['data'];
  2239. }else{
  2240. if(isset($response['data']) && $response['data']){
  2241. Yii::app()->jump->error($response['data']);
  2242. }else{
  2243. Yii::app()->jump->error("保存失败");
  2244. }
  2245. }
  2246. //获取学年
  2247. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  2248. $response = formatResponse($http);
  2249. $result['schoolYear'] = $response['data'];
  2250. $goodArr = $this->getGood();
  2251. $result['goodList'] = $goodArr;
  2252. $result['params']=$params;
  2253. $this->render('paymentApplyList',$result);
  2254. }
  2255. //查看回款反馈申请
  2256. public function actionViewPaymentApply(){
  2257. $id=Req::get('id');
  2258. $http = http('finance/back/coach/record/detail/'.$id, 'get', $this->authUsername);
  2259. $response = formatResponse($http);
  2260. if($response['status']==1){
  2261. $result['data']=$response['data'];
  2262. }
  2263. $this->render('viewPaymentApply',$result);
  2264. }
  2265. //编辑回款反馈申请
  2266. public function actionEditPaymentApply(){
  2267. $id=Req::get('id');
  2268. if (Yii::app()->request->getIsPostRequest()){
  2269. $bdId=Req::post('bcId');
  2270. //保存
  2271. $param['orderId']=Req::post('orderId');
  2272. $param['useNum']=Req::post('use_person');
  2273. $param['schoolYearId']=Req::post('schoolYearId');
  2274. if(Req::post('semester')){
  2275. $param['semester']=Req::post('semester')-1;
  2276. }
  2277. $param['grade']=Req::post('grade');
  2278. $param['goodsId']=Req::post('goodsId');
  2279. $param['downloadNum']=Req::post('down_person');
  2280. $param['price']=Req::post('price');
  2281. $param['feeNumUp']=Req::post('feeNumUp');
  2282. $param['priceSumUp']=Req::post('priceSumUp');
  2283. $param['feeNumDown']=Req::post('feeNumDown');
  2284. $param['priceSumDown']=Req::post('priceSumDown');
  2285. $param['feeTime']=date('Y-m-d H:i:s',strtotime(Req::post('charge_time')));
  2286. if(Req::post('pay_time')){
  2287. $param['remitDate']=date('Y-m-d H:i:s',strtotime(Req::post('pay_time')));
  2288. }
  2289. $param['remark']=Req::post('mark');
  2290. $param['bcId']=$bdId;
  2291. $param['recordId']=$id;
  2292. $http = http('finance/back/coach/edit', 'post', $this->authUsername,$param);
  2293. $response = formatResponse($http);
  2294. if($response['status']==1){
  2295. $this->redirect('/imsSale/paymentApply');
  2296. }else{
  2297. if(isset($response['data']) && $response['data']){
  2298. Yii::app()->jump->error($response['data']);
  2299. }else{
  2300. Yii::app()->jump->error("保存失败");
  2301. }
  2302. }
  2303. }
  2304. $http = http('finance/back/coach/client/record/'.$id, 'get', $this->authUsername);
  2305. $response = formatResponse($http);
  2306. if($response['status']==1){
  2307. $result['data']=$response['data'];
  2308. }
  2309. //销售订单列表
  2310. $http = http('order/coach/purpose/list', 'get', $this->authUsername);
  2311. $response = formatResponse($http);
  2312. if($response['status']==1){
  2313. $result['orderList']=$response['data'];
  2314. }
  2315. //获取学年
  2316. $http = http('sys/school/year/period/list', 'get', $this->authUsername);
  2317. $response = formatResponse($http);
  2318. $result['schoolYear'] = $response['data'];
  2319. //debug($http);
  2320. $goodArr = $this->getGood();
  2321. $result['goodList'] = $goodArr;
  2322. $this->render('editPaymentApply',$result);
  2323. }
  2324. //取消回款反馈申请
  2325. public function actionCancelPaymentApply(){
  2326. $id=Req::get('id');
  2327. $http = http('activiti/coach/process-instances/'.$id.'/suspended', 'put', $this->authUsername);
  2328. $response = formatResponse($http);
  2329. if($response['status']==1){
  2330. $this->redirect('/imsSale/paymentApply');
  2331. }else{
  2332. if(isset($response['data']) && $response['data']){
  2333. Yii::app()->jump->error($response['data']);
  2334. }else{
  2335. Yii::app()->jump->error("取消失败");
  2336. }
  2337. }
  2338. }
  2339. //删除回款反馈申请
  2340. public function actionDeletePaymentApply(){
  2341. $id=Req::get('id');
  2342. $http = http('activiti/coach/process-instances/'.$id, 'delete', $this->authUsername);
  2343. $response = formatResponse($http);
  2344. if($response['status']==1){
  2345. $this->redirect('/imsSale/paymentApply');
  2346. }else{
  2347. if(isset($response['data']) && $response['data']){
  2348. Yii::app()->jump->error($response['data']);
  2349. }else{
  2350. Yii::app()->jump->error("删除失败");
  2351. }
  2352. }
  2353. }
  2354. //普通试用时间表
  2355. public function actionTimeTable(){
  2356. $http = http('order/coach/trial-date', 'get', $this->authUsername);
  2357. $response = formatResponse($http);
  2358. $result['status']=0;
  2359. if($response['status']==1){
  2360. $result['status']=1;
  2361. $result['data']=$response['data'];
  2362. }else{
  2363. $result['msg']=$response['data'];
  2364. }
  2365. exit(json_encode($result));
  2366. }
  2367. //试用订单,根据时间查可用学期
  2368. public function actionGetSemesterByBeginTime(){
  2369. $beginTime=Req::post('beginTime');
  2370. $param['beginTime']=date('Y-m-d 00:00:00',strtotime($beginTime));
  2371. $http = http('order/coach/trial/useful-semester', 'post', $this->authUsername,$param);
  2372. $response = formatResponse($http);
  2373. $result['status']=0;
  2374. if($response['status']==1){
  2375. $result['status']=1;
  2376. $result['data']=$response['data'];
  2377. }else{
  2378. $result['msg']=$response['data'];
  2379. }
  2380. exit(json_encode($result));
  2381. }
  2382. //试用订单,获取试用类型
  2383. public function actionGetUsefulType(){
  2384. $beginTime=Req::post('beginTime');
  2385. $goodsTypeId=Req::post('goodsTypeId');
  2386. $grade=Req::post('grade');
  2387. $subject=Req::post('subject');
  2388. $yearSemester=Req::post('yearSemester');
  2389. $param=array();
  2390. $param['beginTime']=date('Y-m-d 00:00:00',strtotime($beginTime));
  2391. $param['goodsTypeId']=$goodsTypeId;
  2392. $param['grade']=$grade;
  2393. $param['subject']=$subject;
  2394. $param['yearSemester']=$yearSemester;
  2395. $http = http('order/coach/trial/useful-type', 'post', $this->authUsername,$param);
  2396. $response = formatResponse($http);
  2397. $result['status']=0;
  2398. if($response['status']==1){
  2399. $result['status']=1;
  2400. $result['data']=$response['data'];
  2401. }else{
  2402. $result['msg']=$response['data'];
  2403. }
  2404. exit(json_encode($result));
  2405. }
  2406. //新增、编辑问调表
  2407. public function actionEditExperience(){
  2408. $param['appearanceFineness']=Req::post('appearanceFineness');
  2409. $param['printingEffect']=Req::post('printingEffect');
  2410. $param['scanPaperJam']=Req::post('scanPaperJam');
  2411. $param['printPaperJam']=Req::post('printPaperJam');
  2412. $param['id']=Req::post('id');
  2413. $http = http('storage-allocate/coach/edit-experience', 'post', $this->authUsername,$param);
  2414. $response = formatResponse($http);
  2415. $result['status']=0;
  2416. if($response['status']==1){
  2417. $result['status']=1;
  2418. $result['data']=$response['data'];
  2419. }else{
  2420. $result['msg']=$response['data'];
  2421. }
  2422. exit(json_encode($result));
  2423. }
  2424. /**
  2425. * 产品试用重启列表
  2426. */
  2427. public function actionTrialRestart()
  2428. {
  2429. $params = array();
  2430. $result = array();
  2431. $page = Req::get('page') ? Req::get('page') : 1;
  2432. if (Req::get('goodsTypeId')) {
  2433. $params['goodsTypeId'] = Req::get('goodsTypeId');
  2434. }
  2435. if (Req::get('grade')) {
  2436. $params['grade'] = Req::get('grade');
  2437. }
  2438. if (Req::get('orderNo')) {
  2439. $params['orderNo'] = Req::get('orderNo');
  2440. }
  2441. $params['pageNum']=$page;
  2442. //获取产品
  2443. $goodArr = $this->getGoodType();
  2444. $result['goodList'] = $goodArr;
  2445. $http = http('order-trial-enable/coach/page' , 'POST', $this->authUsername, $params);
  2446. $response = formatResponse($http);
  2447. $data = $response['data'];
  2448. if ($response['status']) {
  2449. $result['page'] = $data;
  2450. $result['list'] = isset($data['list'])?$data['list']:array();
  2451. } else {
  2452. $result['page'] = array();
  2453. $result['list'] = array();
  2454. }
  2455. return $this->render('trialTableRestart', $result);
  2456. }
  2457. //查看重启详情
  2458. public function actionViewRestart(){
  2459. $oteId = Req::get('oteId') ? Req::get('oteId') : 0;
  2460. if(!$oteId){
  2461. Yii::app()->jump->error('ID不正确');
  2462. }
  2463. $http = http('order-trial-enable/coach/detail/'.$oteId , 'GET', $this->authUsername);
  2464. $response = formatResponse($http);
  2465. $result=$response['data'];
  2466. //; debug($result);
  2467. return $this->render('trialTableRestartView', $result);
  2468. }
  2469. //试用订单删除学生申请列表
  2470. public function actionTrialDeleteList(){
  2471. $params = array();
  2472. $result = array();
  2473. $page = Req::get('page') ? Req::get('page') : 1;
  2474. if (Req::get('goodsTypeId')) {
  2475. $params['goodsTypeId'] = Req::get('goodsTypeId');
  2476. }
  2477. if (Req::get('grade')) {
  2478. $params['grade'] = Req::get('grade');
  2479. }
  2480. if (Req::get('orderNo')) {
  2481. $params['orderNo'] = Req::get('orderNo');
  2482. }
  2483. $params['pageNum']=$page;
  2484. //获取产品
  2485. $goodArr = $this->getGoodType();
  2486. $result['goodList'] = $goodArr;
  2487. $http = http('order-trial-delete/coach/page' , 'POST', $this->authUsername, $params);
  2488. $response = formatResponse($http);
  2489. $data = $response['data'];
  2490. if ($response['status']) {
  2491. $result['page'] = $data;
  2492. $result['list'] = isset($data['list'])?$data['list']:array();
  2493. } else {
  2494. $result['page'] = array();
  2495. $result['list'] = array();
  2496. }
  2497. return $this->render('trialTableDelete', $result);
  2498. }
  2499. //试用订单删除学生申请详情查看
  2500. public function actionTrialDeleteDetail(){
  2501. $otdId = Req::get('otdId') ? Req::get('otdId') : 0;
  2502. if(!$otdId){
  2503. Yii::app()->jump->error('ID不正确');
  2504. }
  2505. $http = http('order-trial-delete/coach/detail/'.$otdId , 'GET', $this->authUsername);
  2506. $response = formatResponse($http);
  2507. $result=$response['data'];
  2508. //; debug($result);
  2509. return $this->render('trialTableDeleteView', $result);
  2510. }
  2511. //试用订单删除学生选择学生页面
  2512. public function actionTrialDeleteApply(){
  2513. $orderId = Req::get('orderId') ? Req::get('orderId') : 0;
  2514. $result=array();
  2515. //判断是否能发起申请
  2516. $http = http('order-trial-delete/coach/can-apply/'.$orderId , 'GET', $this->authUsername);
  2517. $response = formatResponse($http);
  2518. if(!$response['status']){
  2519. Yii::app()->jump->error($response['data']);
  2520. }
  2521. $result['orderId']=$orderId;
  2522. return $this->render('trialTableDeleteApply', $result);
  2523. }
  2524. //新增试用订单删除学生申请
  2525. public function actionOrderTrialDelete(){
  2526. $orderId = Req::post('orderId') ? Req::post('orderId') : 0;
  2527. $reason = Req::post('reason') ? Req::post('reason') :'';
  2528. $osIds = Req::post('osIds') ? Req::post('osIds') : array();
  2529. $result=array();
  2530. $result['status']=0;
  2531. if(!$orderId){
  2532. $result['msg']="订单id不能为空";
  2533. exit(json_encode($result));
  2534. }
  2535. if(!$reason){
  2536. $result['msg']="删除原因不能为空";
  2537. exit(json_encode($result));
  2538. }
  2539. if(!$osIds){
  2540. $result['msg']="学生不能为空";
  2541. exit(json_encode($result));
  2542. }
  2543. $params=array();
  2544. $params['osIds']=$osIds;
  2545. $params['reason']=$reason;
  2546. $params['otId']=$orderId;
  2547. //判断是否能发起申请
  2548. $http = http('order-trial-delete/coach' , 'POST', $this->authUsername,$params);
  2549. $response = formatResponse($http);
  2550. if($response['status']==1){
  2551. $result['status']=1;
  2552. $result['data']=$response['data'];
  2553. }else{
  2554. $result['msg']=$response['data'];
  2555. }
  2556. exit(json_encode($result));
  2557. }
  2558. //请求暂停、开启班级列表
  2559. public function actionGetDeleteClassesByOrderId(){
  2560. $orderId=Req::post('orderId');
  2561. $result['status']=0;
  2562. //读取班级列表
  2563. $http = http('order-trial-delete/coach/clazz-list/'.$orderId, 'get', $this->authUsername);
  2564. $responseArr = formatResponse($http);
  2565. if($responseArr['status']==1){
  2566. $result=$responseArr;
  2567. $result['students']=array();
  2568. //读取学生列表
  2569. if($result['data']){
  2570. $classId=$result['data'][0]['clazzId'];
  2571. // $studentHttp= http('order-trial-delete/coach/student-list/'.$orderId.'/'.$classId, 'get', $this->authUsername);
  2572. $studentHttp= http('order-trial-delete/coach/student-list/'.$orderId.'/'.$classId, 'get', $this->authUsername,array('stuName'=>''));
  2573. $students=formatResponse($studentHttp);
  2574. if($students['status']==1){
  2575. $result['students']=$students['data'];
  2576. }
  2577. }
  2578. }
  2579. exit(json_encode($result));
  2580. }
  2581. //读取删除学生列表
  2582. public function actionGetDeleteStudentByClassIdOrderId(){
  2583. $orderId=Req::post('orderId');
  2584. $classId=Req::post('classId');
  2585. $studentName=Req::post('studentName')?Req::post('studentName'):'';
  2586. $result['status']=0;
  2587. $url='order-trial-delete/coach/student-list/'.$orderId.'/'.$classId;
  2588. // $studentHttp= http('order-trial-delete/coach/student-list/'.$orderId.'/'.$classId, 'get', $this->authUsername);
  2589. $studentHttp= http($url, 'get', $this->authUsername,array('stuName'=>$studentName));
  2590. $students=formatResponse($studentHttp);
  2591. if($students['status']==1){
  2592. $result['status']=1;
  2593. $result['data']=$students['data'];
  2594. }
  2595. exit(json_encode($result));
  2596. }
  2597. //服务费确认/提交异议
  2598. public function actionConfirmServiceCharge(){
  2599. $batchId=Req::post('batchId');
  2600. $verify=Req::post('verify');
  2601. $problem=Req::post('problem');
  2602. $result['status']=0;
  2603. if(!$batchId){
  2604. $result['data']='参数异常';
  2605. exit(json_encode($result));
  2606. }
  2607. if(!$verify) $verify=1;
  2608. $params=array();
  2609. $params['batchId']=$batchId;
  2610. $params['verify']=$verify;
  2611. if($problem){
  2612. $params['problem']=$problem;
  2613. }
  2614. $http = http('coach-service-charge/coach/archive/update-status', 'PUT', $this->authUsername,$params);
  2615. $response = formatResponse($http);
  2616. if($response['status']==1){
  2617. $result['status']=1;
  2618. }else{
  2619. $result['data']=$response['data'];
  2620. }
  2621. exit(json_encode($result));
  2622. }
  2623. }