ImsSaleController.php 100 KB

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