1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331 |
- <?php
- /**
- * Created by PhpStorm.
- * Date: 2018/5/28
- * Time: 17:14
- * 仓库类
- */
- class ImsStoreController extends Controller
- {
- /***************** 仓库调拨 *****************/
- //调拨列表
- public function actionAllocation()
- {
- $result = array();
- $params = array();
- $page = Req::get('page') ? Req::get('page') : 1;
- if (Req::get('deliveryStatus') && Req::get('deliveryStatus') != '') {
- $params['deliveryStatus'] = Req::get('deliveryStatus')-1;
- }
- if (Req::get('itemId')) {
- $params['itemId'] = Req::get('itemId');
- }
- if(Req::get('startDate')){
- $params['startTime'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
- }
- if(Req::get('endDate')){
- $params['endTime'] =date('Y-m-d 23:59:59',strtotime(Req::get('endDate')));
- }
- //品目名称
- $pmNameList = $this->getPmList();
- $result['itemList'] = $pmNameList;
- $res = $this->getHttp('storage-allocate/coach/list/' . $page, 'POST', $params);
- $result['schoolName']=$this->schoolInfo['school_name'];
- $result['list'] = array();
- if ($res['status'] == 1) {
- $result['list'] = $res['data']['list'];
- $result['page'] = $res['data'];
- } else {
- $result['list'] = array();
- $result['page'] = array();
- }
- $this->render('allocation', $result);
- }
- /**
- * 耗材调拨申请
- */
- public function actionApplyAllocation(){
- $atId = Req::get('atId');
- if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
- $param['coach_name']=Yii::app()->session['coachInfo']['real_name'];
- }else{
- $param['coach_name']=Yii::app()->session['coachInfo']['coach_name'];
- }
- //发货仓库
- $warehouse = $this->getHttp('storage/type/item/0/3','GET');
- $data['warehouse'] = isset($warehouse['data']) && $warehouse['data'] ? $warehouse['data'] : '';
- //查询所有零件
- $partRs=$this->getHttp('fixed/part/list/all','GET');
- $data['part_list']='';
- if($partRs['status']==1){
- if($partRs['data']){
- $partHtml='<select class="part_list">';
- $partHtml.='<option value="0">请选择</option>';
- foreach ($partRs['data'] as $item){
- $partHtml.='<option value="'.$item['partType'].'">'.$item['partName'].'</option>';
- }
- $partHtml.="</select>";
- $data['part_list']=$partHtml;
- }
- }
- //读取品目类型
- $res = $this->getHttp('storage-inventory/coach/low/list/3','GET');
- if ($res['status'] == 1) {
- $data['pm_type']=$res['data'];
- }else{
- $this->errorMsg('品目类型读取失败');
- }
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $data['uploadUrl'] = $url;
- $data['basic'] = $this->setToken();
- if($atId){
- $res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
- $warehouseKeyVal = $data['warehouse'] ? _array_column($data['warehouse'],'storageName','storageId') : array();
- if($res1['status']==1){
- $data['title']=$res1['data']['atTitle'];
- $data['deliverName']=$res1['data']['deliverName']; //总仓
- $data['consignorName']=$res1['data']['consignorName']; //管理员
- $data['school_name']=$this->schoolInfo['school_name'];
- $data['receiveDate']=date('Y-m-d',strtotime($res1['data']['arriveDate']));
- $data['receiveUser']=$res1['data']['receiver'];
- $data['telephone']=$res1['data']['receiveMobile'];
- $data['address']=$res1['data']['receivePlace'];
- $data['remark']=$res1['data']['remark'];
- $data['atCode']=$res1['data']['atCode'];
- $data['atId']=$res1['data']['atId'];
- $data['images']=$res1['data']['images'];
- $data['deliverStorage']=$res1['data']['deliverStorage'];
- $data['deliverStorageName']=isset($warehouseKeyVal[$res1['data']['deliverStorage']]) ? $warehouseKeyVal[$res1['data']['deliverStorage']] : '';
- $data['receiveStorage']=$res1['data']['receiveStorage'];
- $data['operateType']='edit';
- if($res1['data']['details']){
- foreach ($res1['data']['details'] as $val){
- $data['allocateDetail'][]=array(
- 'itemId'=>$val['itemId'],
- 'itemName'=>$val['itemName'],
- 'applyNo'=>$val['applyNo'],
- 'invNo'=>$val['invNo'],
- 'unitName'=>$val['unitName'],
- 'typeName'=>$val['typeName']
- );
- }
- }
- //零件
- if($res1['data']['partDetailList']){
- foreach ($res1['data']['partDetailList'] as $val){
- //加载设备列表
- $device = $this->getHttp('storage-inventory/query-fixed/list/'.$val['fpTypeId'].'/'.$data['receiveStorage'], 'get');
- $deviceHtml='';
- $deviceHtml='<select class="device_list">';
- $deviceHtml.='<option value="0">请选择</option>';
- if($device['data']){
- foreach ($device['data'] as $item){
- if($val['fcId']==$item['fcId']){
- $deviceHtml.='<option selected value="'.$item['fcId'].'">'.$item['fixedCode'].'</option>';
- $val['itemName']=$item['itemName'];
- }else{
- $deviceHtml.='<option value="'.$item['fcId'].'">'.$item['fixedCode'].'</option>';
- }
- }
- }
- $deviceHtml.='</select>';
- $val['device_list']=$deviceHtml;
- $partHtml='<select class="part_list">';
- $partHtml.='<option value="0">请选择</option>';
- if($partRs['data']){
- foreach ($partRs['data'] as $item){
- if($val['fpTypeId']==$item['partType']){
- $partHtml.='<option selected value="'.$item['partType'].'">'.$item['partName'].'</option>';
- }else{
- $partHtml.='<option value="'.$item['partType'].'">'.$item['partName'].'</option>';
- }
- }
- }
- $partHtml.="</select>";
- $val['part_list']=$partHtml;
- $data['partDetailList'][]=$val;
- }
- }
- $this->render('allocationEdit',$data);
- exit;
- }else{
- $this->errorMsg('ID不正确');
- }
- }else{
- // debug($this->schoolInfo);
- $data['title']=$this->schoolInfo['school_name'].'-'.$param['coach_name'].'的耗材调拨申请'.date('Ymd');
- $data['school_name']=$this->schoolInfo['school_name'];
- $data['coach_name']=$param['coach_name'];
- $data['coach_phone']=$this->coachInfo['telephone'];
- $data['address']=$this->schoolInfo['address'];
- $data['operateType']='add';
- }
- $this->render('allocationCreate',$data);
- }
- /**
- * 品目列表
- */
- public function actionInventory(){
- $type=Req::post('type');
- $name=Req::post('name');
- $page=Req::post('page');
- $warehouse=Req::post('warehouse');
- $params=array();
- if($type){
- $params['typeId']=$type;
- }
- if(!$page) $page=1;
- if($name){
- $params['itemName']=$name;
- }
- $params['storageId'] = $warehouse;
- // debug($params);
- $res = $this->getHttp("storage-inventory/coach/not-in-part-type/{$page}", 'POST', $params);
- //debug($res);
- $result['list'] = array();
- $result['now_page'] = $page;
- if ($res['status'] == 1) {
- $result['list'] = $res['data']['list'];
- //$result['total_page'] = $res['data']['lastPage'];
- $result['total_page'] = $res['data']['pages'];
- } else {
- $result['list'] = array();
- $result['total_page'] = array();
- }
- exit(json_encode(array('status'=>1,'data'=>$result)));
- }
- /**
- * 调拨申请
- */
- public function actionApplySubmit(){
- $result['status']=0;
- $warehouse=Req::post('warehouse');
- $allocateDetail=Req::post('allocateDetail');
- $receiveDate=Req::post('receiveDate');
- $receiveUser=Req::post('receiveUser');
- $telephone=Req::post('telephone');
- $address=Req::post('address');
- $remark=Req::post('remark');
- $img = Req::post('img');
- $receiveStorage=Req::post('receiveStorage');
- $partDetail=Req::post('partDetail');
- if(!$warehouse || !$receiveDate || !$receiveUser || !$telephone || !$address || !$receiveStorage || !$img || (!$allocateDetail && !$partDetail)){
- exit(json_encode($result));
- }
- if(strtotime($receiveDate)<strtotime(date('Ymd'))){
- $result['msg']='收货日期不正确';
- exit(json_encode($result));
- }
- $params=array();
- if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
- $coach_name=Yii::app()->session['coachInfo']['real_name'];
- }else{
- $coach_name=Yii::app()->session['coachInfo']['coach_name'];
- }
- $params['alType']=3;
- $params['atTitle']=$this->schoolInfo['school_name'].'-'.$coach_name.'的耗材调拨申请'.date('Ymd');
- $params['deliverStorage']=$warehouse;
- $params['receivePlace']=$address;
- $params['receiver']=$receiveUser;
- $params['receiveMobile']=$telephone;
- $params['arriveDate']=$receiveDate;
- $params['remark']=$remark;
- $params['consigneeName']=$receiveUser;
- $params['doorDoor']=0;
- $params['images']=$img;
- $params['transportType']=1;
- $params['receiveStorage']=$receiveStorage;
- if($allocateDetail){
- foreach ($allocateDetail as $val){
- @$idNum=explode('///',$val);
- if(isset($idNum[0]) && isset($idNum[1])){
- $params['requestAllocateDetail'][]=array(
- 'itemId'=>$idNum[0],
- 'applyNo'=>round($idNum[1],6),
- );
- }
- }
- }
- if($partDetail){
- foreach ($partDetail as $val){
- $partArr=explode('///',$val);
- if(isset($partArr[0]) && isset($partArr[1]) && isset($partArr[2])){
- $params['partReqDTOList'][]=array(
- 'applyNo'=>round($partArr[0],6),
- 'fpTypeId'=>$partArr[1],
- 'fcId'=>$partArr[2]
- );
- }
- }
- }
- $res = $this->getHttp("storage-allocate/coach/add", 'POST', $params);
- if($res['status']==1){
- $result['status']=1;
- }else{
- $result['msg']=$res['msg'];
- }
- exit(json_encode($result));
- }
- /**
- * 编辑调拨申请
- */
- public function actionApplyEdit(){
- $result['status']=0;
- $allocateDetail=Req::post('allocateDetail');
- $receiveDate=Req::post('receiveDate');
- $receiveUser=Req::post('receiveUser');
- $telephone=Req::post('telephone');
- $address=Req::post('address');
- $remark=Req::post('remark');
- $atCode=Req::post('atCode');
- $atId=Req::post('atId');
- $img = Req::post('img');
- $warehouse=Req::post('warehouse');
- $receiveStorage=Req::post('receiveStorage');
- $partDetail=Req::post('partDetail');
- if(!$warehouse || !$receiveDate || !$receiveUser || !$telephone || !$address || !$receiveStorage || !$img || (!$allocateDetail && !$partDetail)){
- exit(json_encode($result));
- }
- if(strtotime($receiveDate)<strtotime(date('Ymd'))){
- $result['msg']='收货日期不正确';
- exit(json_encode($result));
- }
- $params=array();
- if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
- $coach_name=Yii::app()->session['coachInfo']['real_name'];
- }else{
- $coach_name=Yii::app()->session['coachInfo']['coach_name'];
- }
- $params['alType']=3;
- $params['atTitle']=$this->schoolInfo['school_name'].'-'.$coach_name.'的耗材调拨申请'.date('Ymd');
- $params['deliverStorage']=$warehouse;
- $params['receivePlace']=$address;
- $params['receiver']=$receiveUser;
- $params['receiveMobile']=$telephone;
- $params['arriveDate']=$receiveDate;
- $params['remark']=$remark;
- $params['consigneeName']=$receiveUser;
- $params['doorDoor']=0;
- $params['transportType']=1;
- $params['atCode']=$atCode;
- $params['atId']=$atId;
- $params['images']=$img;
- $params['receiveStorage']=$receiveStorage;
- if($allocateDetail){
- foreach ($allocateDetail as $val){
- @$idNum=explode('///',$val);
- if(isset($idNum[0]) && isset($idNum[1])){
- $params['requestAllocateDetail'][]=array(
- 'itemId'=>$idNum[0],
- 'applyNo'=>round($idNum[1],6),
- );
- }
- }
- }
- if($partDetail){
- foreach ($partDetail as $val){
- $partArr=explode('///',$val);
- if(isset($partArr[0]) && isset($partArr[1]) && isset($partArr[2])){
- $params['partReqDTOList'][]=array(
- 'applyNo'=>round($partArr[0],6),
- 'fpTypeId'=>$partArr[1],
- 'fcId'=>$partArr[2]
- );
- }
- }
- }
- $res = $this->getHttp("storage-allocate/coach/edit", 'POST', $params);
- if($res['status']==1){
- $result['status']=1;
- }else{
- $result['msg']=$res['msg'];
- }
- exit(json_encode($result));
- }
- /**
- * 调拨查看物流/确认收货
- */
- public function actionAllocationView()
- {
- $result = array();
- $atId = trim(Req::get('atId'));
- $result['atId'] = $atId;
- $result['sendData'] = array();
- $result['receiveData'] = array();
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- if ($atId) {
- //发货记录
- $sendRes = $this->getHttp('storage-allocate/coach/deliver-record/' . $atId, 'get');
- if ($sendRes['status'] == 1) {
- $result['sendData'] = $sendRes['data'];
- $logisticsTime = array();
- foreach ($sendRes['data'] as $v){
- $logisticsTime[] = $v['logisticsTime'];
- }
- $_logisticsTime = time() - strtotime(min($logisticsTime));
- if($_logisticsTime){
- $result['logisticsTime'] = floor($_logisticsTime/(24*3600));
- }else{
- $result['logisticsTime'] = 0;
- }
- } else {
- $this->errorMsg($sendRes['msg']);
- }
- //收货记录
- $receiveRes = $this->getHttp('storage-allocate/coach/receive-record/' . $atId, 'get');
- if ($receiveRes['status'] == 1) {
- foreach ($receiveRes['data'] as $value) {
- $result['receiveData'][$value['atoId']] = $value;
- }
- } else {
- $this->errorMsg($receiveRes['msg']);
- }
- $res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
- if($res1['status']==1){
- if(isset($res1['data']['resDTOList'])){
- $result['logList']=$res1['data']['resDTOList'];
- }else{
- $result['logList']=array();
- }
- }
- } else {
- $this->errorMsg('调拨ID不正确');
- }
- //debug($result);
- $this->render('allocationView', $result);
- }
- /**
- * 确认收货
- */
- public function actionAjaxReceipt()
- {
- $result = array();
- $error = array();
- $atId = Req::post('atId');
- $atoId = Req::post('atoId');
- $qualifiedNo = round(Req::post('qualifiedNo'),6);
- $scrapNo = round(Req::post('scrapNo'),6);
- $tallyNo = round(Req::post('tallyNo'),6);
- $picUrl = (array)Req::post('imgArr');
- $fixedCodes = (array)Req::post('fixedCodes');
- $params = array(
- 'atId' => $atId,
- 'atoId' => $atoId,
- 'images' => $picUrl,
- 'qualifiedNo' => $qualifiedNo, //合格
- 'tallyNo'=>$qualifiedNo, //记账
- 'scrapNo' => $scrapNo, //不合格
- 'arriveNo'=> $tallyNo, //到账
- 'itemId' => Req::post('itemId'),
- 'fixedCodes' => $fixedCodes
- );
- $res = $this->getHttp('storage-allocate/coach/receipt', 'post', $params);
- $this->imsLog("仓库调拨-确认收货",'storage-allocate/coach/receipt',$params,$res);
- if ($res['status'] == 1) {
- $result = $res['data'];
- } else {
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>', $error)));
- } else {
- echo json_encode(array('status' => 1, 'data' => $result));
- }
- }
- /**
- * 调拨查看物流/确认收货
- */
- public function actionAllocationViewDetail()
- {
- $atId = Req::get('atId');
- $data = array();
- if($atId){
- $res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
- if($res1['status']==1){
- $data['title']=$res1['data']['atTitle'];
- $data['deliverName']=$res1['data']['deliverName']; //总仓
- $data['consignorName']=$res1['data']['consignorName']; //管理员
- $data['school_name']=$this->schoolInfo['school_name'];
- $data['receiveDate']=date('Y-m-d',strtotime($res1['data']['arriveDate']));
- $data['receiveUser']=$res1['data']['receiver'];
- $data['telephone']=$res1['data']['receiveMobile'];
- $data['address']=$res1['data']['receivePlace'];
- $data['remark']=$res1['data']['remark'];
- $data['atCode']=$res1['data']['atCode'];
- $data['atId']=$res1['data']['atId'];
- $data['images']=$res1['data']['images'];
- $data['receiveName']=$res1['data']['receiveName'];
- if(isset($res1['data']['resDTOList'])){
- $data['logList']=$res1['data']['resDTOList'];
- }else{
- $data['logList']=array();
- }
- if($res1['data']['details']){
- foreach ($res1['data']['details'] as $val){
- $data['allocateDetail'][]=array(
- 'itemId'=>$val['itemId'],
- 'itemName'=>$val['itemName'],
- 'applyNo'=>$val['applyNo'],
- 'invNo'=>$val['invNo'],
- 'unitName'=>$val['unitName'],
- 'typeName'=>$val['typeName']
- );
- }
- }
- if($res1['data']['partDetailList']){
- $data['partDetail']=$res1['data']['partDetailList'];
- }
- //读取问调表
- $res = $this->getHttp('storage-allocate/coach/experience-info/'.$atId,'GET');
- if($res['status']==1){
- $data['survey']=$res['data'];
- }
- $this->render('allocationViewDetail',$data);
- exit;
- }else{
- $this->errorMsg('ID不正确');
- }
- }
- }
- /***************** 销售出库 *****************/
- /**
- * 销售出库列表
- */
- public function actionDelivery()
- {
- $result = array();
- $params = array();
- $page = Req::get('page') ? Req::get('page') : 1;
- if (Req::get('isUse')) {
- $params['isUse'] = Req::get('isUse')-1;
- }
- if (Req::get('itemId')) {
- $params['itemId'] = Req::get('itemId');
- }
- if (Req::get('startDate')) {
- $params['startOutDate'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
- }
- if(Req::get('endDate')){
- $params['endOutDate'] = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
- }
- //品目名称
- $pmNameList = $this->getPmList();
- $result['itemList'] = $pmNameList;
- $res = $this->getHttp('storage-output/coach/list/' . $page, 'POST',$params);
- $result['pmDataList'] = array();
- if ($res['status'] == 1) {
- $result['pmDataList'] = $res['data'];
- }
- $result['useOutType']='use';
- $this->render('delivery', $result);
- }
- /*销售退库*/
- public function actionDeliveryOut(){
- $result = array();
- $params = array();
- $page = Req::get('page') ? Req::get('page') : 1;
- if (Req::get('isUse')) {
- $params['inputStatus'] = Req::get('isUse')-1;
- }
- if (Req::get('itemId')) {
- $params['itemId'] = Req::get('itemId');
- }
- if (Req::get('startDate')) {
- $params['startTime'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
- }
- if(Req::get('endDate')){
- $params['endTime'] = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
- }
- //品目名称
- $pmNameList = $this->getPmList();
- $result['itemList'] = $pmNameList;
- $params['pageNo'] = $page;
- $res = $this->getHttp('storage-input/coach/sale/list/' , 'POST',$params);
- $result['pmDataList'] = array();
- if ($res['status'] == 1) {
- $result['pmDataList'] = $res['data'];
- }
- $result['useOutType']='out';
- $this->render('deliveryOut', $result);
- }
- /*确认退库*/
- public function actionSubmitSale(){
- $inId = Req::post('inId');
- $res = $this->getHttp('storage-input/coach/sale/'.$inId, 'put');
- if ($res['status']){
- returnMsg(1,$res['msg']);
- }else{
- returnMsg(0,$res['msg']);
- }
- }
- /*退库学生列表*/
- public function actionAjaxSaleStudentList(){
- $inId = Req::post('inId');
- $page=Req::post('page');
- if(!$page) $page=1;
- $res = $this->getHttp("storage-input/coach/students/{$inId}/{$page}", 'get');
- if ($res['status']){
- returnMsg(1,'',$res['data']);
- }else{
- returnMsg(0,$res['msg']);
- }
- }
- /**
- * 销售出库编辑
- */
- public function actionDeliveryEdit()
- {
- $result = array();
- $outId = Req::get('outId');
- //品目名称
- $pmNameList = $this->getSalePmList();
- if (empty($pmNameList)){
- $this->errorMsg('暂无出库品目,无法新增出库单!');
- }
- $result['pmNameList'] = $pmNameList;
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- if (is_numeric($outId) && $outId > 0) {
- $res = $this->getHttp('storage-output/coach/' . $outId, 'get');
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- $result['itemId'] = $res['data']['outputDetails'][0]['itemId'];
- $result['total'] = $res['data']['outputDetails'][0]['no'];
- //出库学生列表
- $outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
- $result['pmStudent'] = $outStudent['data'];
- $result['reStudentCount'] = count($outStudent['data']);
- } else {
- $this->errorMsg($res['msg']);
- }
- } else {
- $this->errorMsg('出库单ID不正确!');
- }
- $this->render('deliveryEdit', $result);
- }
- /**
- * 查看销售出库
- */
- public function actionDeliveryView()
- {
- $result = array();
- $outId = Req::get('outId');
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- if (is_numeric($outId) && $outId > 0) {
- $res = $this->getHttp('storage-output/coach/' . $outId, 'get');
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- $result['itemName'] = $res['data']['outputDetails'][0]['itemName'];
- $result['itemId'] = $res['data']['outputDetails'][0]['itemId'];
- $result['total'] = $res['data']['outputDetails'][0]['no'];
- //出库学生列表
- $outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
- $result['pmStudent'] = $outStudent['data'];
- // dd($outStudent);
- $result['reStudentCount'] = count($outStudent['data']);
- } else {
- $this->errorMsg($res['msg']);
- }
- } else {
- $this->errorMsg('出库单ID不正确!');
- }
- $this->render('deliveryView', $result);
- }
- /**
- * 销售出库增加
- */
- public function actionDeliveryAdd()
- {
- $result = array();
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- //品目名称
- $pmNameList = $this->getSalePmList();
- if (empty($pmNameList)){
- $this->errorMsg('暂无出库品目,无法新增出库单!');
- }
- $result['pmNameList'] = $pmNameList;
- $result['pmData'] = array();
- $this->render('deliveryAdd', $result);
- }
- /**
- * 删除出库
- */
- public function actionAjaxDelOut()
- {
- $outId = Req::post('outId');
- $http = http('storage-output/coach/'.$outId, 'delete', $this->authUsername);
- $response = formatResponse($http);
- $this->imsLog("销售出库-删除出库",'storage-output/coach/'.$outId,array(),$response);
- if ($response['status']){
- returnMsg(1, '提交成功!');
- }else{
- returnMsg(0, $response['data']);
- }
- }
- /**
- * 确认出库
- */
- public function actionAjaxUseOut()
- {
- $outId = Req::post('outId');
- $res = $this->getHttp('storage-output/coach/use/'.$outId, 'put');
- if ($res['status']){
- returnMsg(1,$res['msg']);
- }else{
- returnMsg(0,$res['msg']);
- }
- }
- /**
- * 销售出库编辑学生
- * @throws CException
- */
- public function actionAjaxEditStu(){
- $result = array();
- $error = array();
- $hasSelected = array();
- $orderId = trim(Req::post('orderId'));
- $outId = Req::post('outId')?Req::post('outId'):0;
- //正式订单列表的学生
- $res = $this->getHttp('order/coach/official/sale-out/students/'.$orderId, 'get');
- //出库学生列表
- if($outId){
- $outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
- if ($outStudent['data']){
- foreach ($outStudent['data'] as $k=>$v){
- $hasSelected[$v['osId']] = $v;
- }
- }
- }
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $this->renderPartial('_selectStu',array('relStuList'=>$result,'hasSelected'=>$hasSelected,'outId'=>$outId), true)));
- }
- }
- /**
- * ajax销售出库增加
- */
- public function actionAjaxDeliveryAdd(){
- $result = array();
- $error = array();
- $orderId = Req::post('orderId');
- $itemId = Req::post('itemId');
- $outDate = Req::post('outDate');
- $outTitle = Req::post('outTitle');
- $stuGetNum = (int)Req::post('stuGetNum');
- $stuIds= (array)Req::post('stuSeledArr');
- $imgArr= (array)Req::post('imgArr');
- //品目名称
- $pmNameList = $this->getSalePmList();
- $pmNameArr = array();
- foreach($pmNameList as $value){
- if($value['itemId'] == $itemId){
- $pmNameArr = $value;
- }
- }
- if(!$pmNameArr){
- $error[] = '品目信息不正确!';
- }
- if(!$error){
- $params = array(
- 'deliverStorage' => 0,
- 'itemType' => 2,
- 'orderId' => $orderId,
- 'osIds' => $stuIds,
- 'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
- 'outTitle' => $outTitle,
- 'outType' => 1,
- 'images' => $imgArr,
- 'outputDetails' => array(
- array(
- 'itemCode' => $pmNameArr['itemCode'],
- 'itemId' => $pmNameArr['itemId'],
- 'itemName' => $pmNameArr['itemName'],
- 'itemSpec' => $pmNameArr['itemSpec'],
- 'no' => $stuGetNum*count($stuIds),
- )
- ),
- 'useType' => 0,
- 'userId' => 0,
- 'userName' => '',
- );
- //编辑
- if(Req::post('outId')){
- $params['outId'] = Req::post('outId');
- $res = $this->getHttp('storage-output/coach/edit', 'put',$params);
- $this->imsLog("销售出库-编辑出库单",'storage-output/coach/edit',$params,$res);
- }else{
- //新增
- $res = $this->getHttp('storage-output/coach/add', 'post',$params);
- $this->imsLog("销售出库-新增出库单",'storage-output/coach/add',$params,$res);
- }
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- }
- /**
- * 关联正式订单
- */
- public function actionAjaxRelOrder(){
- $error = array();
- $result = array();
- $page = (int)Req::post('page');
- $orderId = Req::post('orderId');
- $doType = Req::post('doType');
- $page = $page ? $page : 1;
- if($doType=='edit'){
- //编辑单独调取
- $res = $this->getHttp('order/coach/official/not-take/details/'.$page.'/except/'.$orderId, 'get');
- }else{
- $res = $this->getHttp('order/coach/official/not-take/details/'.$page, 'get');
- }
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- }
- /***************** 仓库盘点 *****************/
- /**
- * 盘点页面
- */
- public function actionStock(){
- $result = array();
- $params = array();
- $page = Req::get('page')?Req::get('page'):1;
- if(Req::get('status')){
- $params['status'] = Req::get('status')-1;
- }
- if(Req::get('lossType')){
- $params['lossType'] = Req::get('lossType')-1;
- }
- if(Req::get('itemId')){
- $params['itemId'] = Req::get('itemId');
- }
- if(Req::get('startStockDate')){
- $params['startStockDate'] = date('Y-m-d H:i:s',strtotime(Req::get('startStockDate')));
- }
- if(Req::get('endStockDate')){
- $params['endStockDate'] = date('Y-m-d H:i:s',strtotime(Req::get('endStockDate')));
- }
- $res = $this->getHttp('storage-stock/coach/list/'.$page, 'post', $params);
- if($res['status']){
- $result['list'] = $res['data']['list'];
- $result['page'] = $res['data'];
- }else{
- $result['list'] = array();
- $result['page'] = array();
- }
- // debug($result['list']);
- //所有品目
- $item = $this->getHttp('item/all', 'get');
- $result['itemList'] = $item['data'];
- //审批状态
- $dict = $this->getDict('process_apply_status');
- $result['applyStatus'] = $dict;
- $this->render('stock',$result);
- }
- /**
- * 新增盘点
- */
- public function actionStockAdd(){
- $result = array();
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- $this->render('stockAdd',$result);
- }
- //保存更新数据
- public function actionAjaxStockAdd(){
- $params = array();
- $params['stockTitle'] = Req::post('stockTitle');
- $params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
- $params['itemId'] = Req::post('itemId');
- $params['itemCode'] = Req::post('itemCode');
- $params['itemName'] = Req::post('itemName');
- $params['itemSpec'] = Req::post('itemSpec');
- $params['unit'] = Req::post('unitId');
- $params['itemType'] = Req::post('itemType');
- $params['theoreticalNo'] = Req::post('theoreticalNo');
- $params['stockNo'] = Req::post('stockNo')?Req::post('stockNo'):0;
- $params['images'] = (array)Req::post('imgArr');
- $params['lossNo'] = Req::post('stockNo') - Req::post('theoreticalNo');
- $params['fixedCodes'] = (array)Req::post('fixedCodes');
- $params['invFixedCodes'] = (array)Req::post('invFixedCodes');
- $params['remark'] = Req::post('remark');
- if(Req::post('stockId')){
- //编辑
- $params['stockId'] = Req::post('stockId');
- //详情
- $detail = $this->getHttp('storage-stock/coach/'.$params['stockId'], 'get');
- $params['processInfo'] = $detail['data']['processInfo'];
- $response = $this->getHttp('storage-stock/coach/edit','put',$params);
- $this->imsLog("销售盘点-重盘",'storage-stock/coach/edit',$params,$response);
- }else{
- $response = $this->getHttp('storage-stock/coach/add','post',$params);
- $this->imsLog("销售盘点-新增",'storage-stock/coach/add',$params,$response);
- }
- if ($response['status']){
- returnMsg(1,$response['msg']);
- }else{
- returnMsg(0,$response['msg']);
- }
- }
- /**
- * 重盘
- */
- public function actionStockEdit(){
- $result = array();
- //品目
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- $stockId = Req::get('stockId');
- //详情
- $detail = $this->getHttp('storage-stock/coach/'.$stockId, 'get');
- if($detail['status']){
- $result['detail'] = $detail['data'];
- if(isset($detail['data']['remark'])){
- $result['detail']['remark'] = $detail['data']['remark'];
- }else{
- $result['detail']['remark'] = '';
- }
- //品目
- $itemType = $detail['data']['itemType'];
- $http = $this->getHttp('storage-inventory/coach-item/'.$itemType, 'get');
- $result['itemList'] = $http['data'];
- $this->render('stockEdit',$result);
- }else{
- Yii::app()->jump->error($detail['msg']);
- }
- }
- //取消盘点
- public function actionAjaxStopStock()
- {
- $businessKey = Req::post('businessKey');
- $http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
- $response = formatResponse($http);
- $this->imsLog("销售盘点-取消",'activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
- if ($response['status']){
- returnMsg(1, '提交成功!');
- }else{
- returnMsg(0, $response['data']);
- }
- }
- //删除盘点
- public function actionAjaxDeleteStock()
- {
- $businessKey = Req::post('businessKey');
- $http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
- $response = formatResponse($http);
- $this->imsLog("销售盘点-删除",'activiti/coach/process-instances/'.$businessKey,array(),$response);
- if ($response['status']){
- returnMsg(1, '提交成功!');
- }else{
- returnMsg(0, $response['data']);
- }
- }
- /**
- * 查看
- */
- public function actionStockView()
- {
- $stockId = Req::get('stockId');
- $processInstanceId = Req::get('processInstanceId');
- //详情
- $detail = $this->getHttp('storage-stock/coach/'.$stockId, 'get');
- //审核人员
- $process = $this->getHttp('activiti/coach/process-instances/'.$processInstanceId.'/trace','get');
- if($detail['status']){
- $result['detail'] = $detail['data'];
- $result['process'] = $process['data']['tasks'];
- $result['startUserName'] = $process['data']['startUserName'];
- $result['createTime'] = $process['data']['createTime'];
- $result['endTime'] = $process['data']['endTime'];
- $result['itemTypeName'] = itemType($detail['data']['itemType']);
- if(isset($detail['data']['remark'])){
- $result['detail']['remark'] = $detail['data']['remark'];
- }else{
- $result['detail']['remark'] = '';
- }
- $this->render('stockView',$result);
- }else{
- Yii::app()->jump->error($detail['msg']);
- }
- }
- //根据品类获取品目
- public function actionGetItem()
- {
- $itemType = Req::post('itemType');
- $http = $this->getHttp('storage-inventory/coach-item/'.$itemType, 'get');
- if($http['status']){
- if($http['data']){
- returnMsg(1,'success',$http['data']);
- }else{
- returnMsg(0,'暂无数据');
- }
- }else{
- returnMsg(0,$http['msg']);
- }
- }
- //获取固定资产编号
- public function actionGetFixCode()
- {
- $itemId = Req::post('itemId');
- $http = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
- if($http['status']){
- if($http['data']){
- returnMsg(1,'success',$http['data']);
- }else{
- returnMsg(0,'暂无数据');
- }
- }else{
- returnMsg(0,$http['msg']);
- }
- }
- /**
- * 获取审核内容
- */
- public function actionGetTask()
- {
- $taskId = Req::post('taskId');
- $task = $this->getHttp('activiti/coach/tasks/'.$taskId.'/form' ,'get');
- if($task['status']){
- returnMsg(1,'success',$task['data']);
- }else{
- returnMsg(0,$task['msg']);
- }
- }
- /***************** 库存报表 *****************/
- public function actionReport()
- {
- $params = array();
- $result = array();
- $page = Req::get('page')?Req::get('page'):1;
- $itemId = trim(Req::get('itemId'));
- $itemType = trim(Req::get('itemsType'));
- if($itemId){
- $params['itemId'] = Req::get('itemId');
- }
- if($itemType){
- $params['itemIdType'] = $itemType;
- }
- //获取品目名称
- $itemList = $this->getPmList();
- $result['itemList'] = $itemList;
- $res = $this->getHttp('storage-inventory/coach/report/'.$page, 'post',$params);
- $result['list'] = array();
- if ($res['status'] == 1) {
- $result['list'] = $res['data']['list'];
- $result['page'] = $res['data'];
- } else {
- $result['list'] = array();
- $result['page'] = array();
- }
- $this->render('report', $result);
- // $params = array();
- // $result = array();
- //
- // $page = Req::get('page')?Req::get('page'):1;
- // $itemId = trim(Req::get('itemId'));
- //
- // if($itemId){
- // $params['itemId'] = Req::get('itemId');
- // }
- //
- // //获取品目名称
- // $itemList = $this->getPmList();
- // $result['itemList'] = $itemList;
- //
- // $res = $this->getHttp('storage-inventory/report-coach/'.$page, 'post',$params);
- // $result['reportList'] = array();
- // if ($res['status'] == 1) {
- // $result['reportList'] = $res['data'];
- // } else {
- // $result['reportList'] = array();
- // }
- //
- // $this->render('report', $result);
- }
- /***************** 出入库账薄 *****************/
- public function actionAccount(){
- $params = array();
- $result = array();
- $itemId = trim(Req::get('itemId'));
- $page = Req::get('page') ? Req::get('page') : 1;
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- if($itemId){
- $params['itemId'] = $itemId;
- }
- $params['pageNum'] = $page;
- $params['storageId'] = $schoolId;
- $res = $this->getHttp('storage-inventory/coach/records', 'post',$params);
- $result['list'] = array();
- if ($res['status'] == 1) {
- $result['list'] = $res['data']['list'];
- $result['page'] = $res['data'];
- } else {
- $result['list'] = array();
- $result['page'] = array();
- }
- $this->render('account', $result);
- // $params = array();
- // $result = array();
- //
- // $itemId = trim(Req::get('itemId'));
- // $startTime = trim(Req::get('startDate'));
- // $endTime = trim(Req::get('endDate'));
- //
- // //获取品目名称
- // $itemList = $this->getPmList(true);
- // $result['itemList'] = $itemList;
- //
- // if($itemId ){
- // $params['itemId'] = Req::get('itemId');
- // if($startTime){
- // if(!getCheckDate($startTime)){
- // $this->errorMsg('开始日期不正确!');
- // }
- // $params['startTime'] = $startTime;
- // }
- //
- // if($endTime){
- // if(!getCheckDate($endTime)){
- // $this->errorMsg('结束日期不正确!');
- // }
- // $params['endTime'] = $endTime;
- // }
- // $result['startTime'] = $startTime;
- // $result['endTime'] = $endTime;
- //
- // if(!isset($itemList[$itemId])){
- // $this->errorMsg('品目不存在!');
- // }else{
- // $result['currItem'] = $itemList[$itemId];
- // }
- // $res = $this->getHttp('storage-inventory/ledger-coach/', 'post',$params);
- //
- // $result['reportList'] = array();
- // if ($res['status'] == 1) {
- // $result['reportList'] = $res['data'];
- // } else {
- // $this->errorMsg($res['msg']);
- // }
- // }else{
- // $result['reportList'] = array();
- // }
- // $result['dateStrArr'] = $this->getDateStr();
- //
- //
- // $this->render('account', $result);
- }
- /***************** 所需方法 *****************/
- /**
- * 处理接口返回的数据
- * @param $res
- * @return array
- */
- public function handleRes($res){
- $result = array(
- 'status' => 0,
- 'data' => array(),
- 'msg' => '暂无数据',
- );
- if($res){
- $res = json_decode($res,true);
- if(isset($res['errCode']) && $res['errCode'] == '00'){
- $result['status'] = 1;
- $result['data'] = isset($res['data'])?$res['data']:array();
- $result['msg'] = $res['errMsg'];
- }else{
- if(isset($res['errMsg'])){
- $result['msg'] = $res['errMsg'];
- }
- }
- }
- unset($res);
- return $result;
- }
- /**
- * 获取调拨所有品目列表
- * @return array|mixed
- */
- private function getPmList($isRel = false){
- $pmList = array();
- $res = http('item/all', 'get', $this->authUsername);
- if($res){
- $result = $this->handleRes($res);
- if($result['status'] == 1){
- if($isRel){
- foreach($result['data'] as $value){
- $pmList[$value['itemId']] = $value;
- }
- }else{
- $pmList = $result['data'];
- }
- }
- }
- unset($res);
- return $pmList;
- }
- /**
- * 获取销售品目列表
- * @return array|mixed
- */
- private function getSalePmList($itemType=2){
- $pmList = array();
- $res = http('storage-inventory/coach-item/'.$itemType, 'get',$this->authUsername);
- if($res){
- $result = $this->handleRes($res);
- if($result['status'] == 1){
- $pmList = $result['data'];
- }
- }
- unset($res);
- return $pmList;
- }
- /**
- * 获取接口数据
- * @param $url
- * @param $method
- * @param array $params
- * @return array
- */
- private function getHttp($url,$method,$params = array()){
- $res = http($url, $method, $this->authUsername, $params);
- $res = $this->handleRes($res);
- return $res;
- }
- /**
- * 错误信息
- * @param $msg
- */
- private function errorMsg($msg){
- Yii::app()->jump->error($msg);
- }
- /**
- * 获取日期段
- * @return array
- */
- private function getDateStr(){
- $result = array();
- $time = time();
- $dayTime = 24*3600;
- $week = date('w');
- $result['curr_week_start'] = date('Y-m-d',$time - ($week - 1) * $dayTime );
- $result['curr_week_end'] = date('Y-m-d',$time - ($week - 1) * $dayTime + 6*$dayTime);
- $result['pre_week_start'] = date('Y-m-d',$time - ($week - 1) * $dayTime - 7*$dayTime);
- $result['pre_week_end'] = date('Y-m-d',$time - ($week - 1) * $dayTime + 6*$dayTime - 7*$dayTime);
- $result['curr_month_start'] = date("Y-m-01",$time);
- $result['curr_month_end'] = date("Y-m-d",strtotime($result['curr_month_start']." +1 month -1 day"));
- $result['pre_month_start'] = date("Y-m-d",strtotime($result['curr_month_start']." -1 month"));
- $result['pre_month_end'] = date("Y-m-d",strtotime($result['pre_month_start']." +1 month -1 day"));
- $result['curr_year_start'] = date("Y-01-01",$time);
- $result['curr_year_end'] = date("Y-m-d",strtotime($result['curr_year_start']." +1 year -1 day"));
- $result['pre_year_start'] = date('Y-m-d',strtotime($result['curr_year_start']." -1 year"));
- $result['pre_year_end'] = date("Y-m-d",strtotime($result['pre_year_start']." +1 year -1 day"));
- return $result;
- }
- public function setToken(){
- $sign = $this->authUsername.Yii::app()->params['ims']['sign_url'].Yii::app()->params['ims']['sign'];
- $authPassword = md5($sign);
- $basic = "Basic ". base64_encode($this->authUsername.":".$authPassword);
- return $basic;
- }
- /**
- * @param $codeType
- * @return array
- * 获取字典
- */
- public function getDict($codeType)
- {
- $result = array();
- $http = http('dictionary/list/type-code/'.$codeType, 'get', $this->authUsername);
- $response = formatResponse($http);
- if ($response['status']){
- $result = $response['data'];
- }
- return $result;
- }
- public function actionSign(){
- $result = array();
- $result['data'] = array();
- $outId = Req::get('outId');
- $http = http('storage-output/coach/' . $outId, 'get',$this->authUsername);
- if($http){
- $http = json_decode($http,true);
- }
- if(isset($http['data']) && $http['data']){
- $result['data'] = $http['data'];
- $classSign = $singInfo = array();
- $className = array();
- $_data = array();
- $result['data']['currClassId'] = 0;
- if(isset($http['data']['signDetails']) && $http['data']['signDetails']){
- $signDetails = $http['data']['signDetails'];
- foreach ($signDetails as $value){
- $classSign[$value['clazzId']] = $value['classSign'];
- //签字图片,签字人
- $_signInfo = array();
- if(isset($value['signUrl']) && $value['signUrl']){
- $_signInfo = array(
- 'signUrl' => $value['signUrl'],
- 'signRole' => $value['signRole'],
- 'signPhone' => $value['signPhone']
- );
- }
- $singInfo[$value['clazzId']] = $_signInfo;
- //班级名称数组
- $className[$value['clazzId']] = $value['clazzName'];
- if(isset($value['studentNames']) && $value['studentNames']){
- foreach ($value['studentNames'] as $v){
- if(!$result['data']['currClassId']){
- $result['data']['currClassId'] = $value['clazzId'];
- }
- $item = array();
- $item['orderNo'] = isset($http['data']['orderNo'])?$http['data']['orderNo']:0;
- $item['className'] = $value['clazzName'];
- $item['classId'] = $value['clazzId'];
- $item['studentName'] = $v;
- $_data[] = $item;
- }
- }
- }
- }
- $result['data']['_signDetails'] = $_data;
- $result['data']['classSign'] = $classSign;
- $result['data']['singInfo'] = $singInfo;
- $result['data']['className'] = $className;
- }else{
- $this->errorMsg(isset($http['errMsg'])?$http['errMsg']:'接口获取数据失败');
- }
- $this->render('sign', $result);
- }
- /**********************************************************************************/
- //领用出库
- public function actionUseOut(){
- $result = array();
- $params = array();
- $page = Req::get('page') ? Req::get('page') : 1;
- if (Req::get('isUse')) { //状态
- $params['status'] = Req::get('isUse')-1;
- }
- if (Req::get('itemId')) {
- $params['itemId'] = Req::get('itemId');
- }
- if (Req::get('itemType')) {
- $params['itemType'] = Req::get('itemType');
- }
- if (Req::get('inCode')) {
- $params['inCode'] = Req::get('inCode');
- }
- if (Req::get('inputStatus')) {
- $params['inputStatus'] = Req::get('inputStatus')-1;
- }
- $useOutType = Req::get('useOutType');
- if(!$useOutType){
- $useOutType = 'use';
- }
- if (Req::get('startDate')) {
- $startDate = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
- if($useOutType == 'use'){
- $params['outDateBegin'] = $startDate;
- }elseif($useOutType == 'useOut'){
- $params['inDateBegin'] = $startDate;
- }else{
- $params['startTime'] = $startDate;
- }
- }
- if(Req::get('endDate')){
- $endDate = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
- if($useOutType == 'use'){
- $params['outDateEnd'] = $endDate;
- }elseif($useOutType == 'useOut'){
- $params['inDateEnd'] = $endDate;
- }else{
- $params['endTime'] = $endDate;
- }
- }
- $params['pageNo'] = $page;
- //品目名称
- $pmNameList = $this->getPmList();
- $result['itemList'] = $pmNameList;
- if($useOutType == 'use'){
- $res = $this->getHttp('storage/coach/client/take/list', 'POST',$params);
- }elseif($useOutType == 'out'){
- //退库
- $res = $this->getHttp('storage/coach/client/refound/list', 'POST',$params);
- }else{
- $res = $this->getHttp('storage-input/coach/cancel/list' , 'POST',$params);
- // $res = $this->getHttp('storage/coach/client/refound/list', 'POST',$params);
- }
- $result['pmDataList'] = array();
- if ($res['status'] == 1) {
- $result['pmDataList'] = $res['data'];
- }
- $result['useOutType'] = $useOutType;
- //debug($result);
- $this->render('useOut', $result);
- }
- /**
- * 出库单出库
- */
- public function actionUseView()
- {
- $result = array();
- $outId = Req::get('outId');
- $scrapNo = 0;
- if (is_numeric($outId) && $outId > 0) {
- $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['coachName']=$res['data']['userName'];
- $result['pmData'] = $res['data'];
- $result['coachName'] = isset($result['pmData']['userName'])?$result['pmData']['userName']:'';
- if(isset($res['data']['itemList']) && $res['data']['itemList'][0]){
- $result['itemName'] = $res['data']['itemList'][0]['itemName'];
- $result['itemId'] = $res['data']['itemList'][0]['itemId'];
- $result['stockNum'] = $res['data']['itemList'][0]['num'];
- $result['itemTotal'] = $res['data']['itemList'][0]['invNo'];
- $result['unitName'] = isset($res['data']['itemList'][0]['unitName'])?$res['data']['itemList'][0]['unitName']:'';
- $result['itemType'] = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:0;
- if(isset($res['data']['itemList'][0]['scrapNo'])){
- $scrapNo = $res['data']['itemList'][0]['scrapNo'];
- }
- $result['fcCode'] = isset($res['data']['itemList'][0]['fcCode'])?$res['data']['itemList'][0]['fcCode']:'';
- $result['fcName'] = isset($res['data']['itemList'][0]['fcName'])?$res['data']['itemList'][0]['fcName']:'';
- $result['print'] = isset($res['data']['itemList'][0]['print'])?$res['data']['itemList'][0]['print']:'';
- //$result['itemType'] = $res['data']['itemType'];
- $result['fcId'] =isset($res['data']['itemList'][0]['fcId'])?$res['data']['itemList'][0]['fcId']:0;
- // $result['orderNo'] = $res['data']['orderNo'];
- // $result['packageNo'] = $res['data']['packageNo'];
- // $result['quantity'] = $res['data']['quantity'];
- // $result['waitCheckNo'] = $res['data']['waitCheckNo'];
- // $result['saleNo'] = $res['data']['saleNo'];
- }else{
- $this->errorMsg('数据为空');
- }
- if(isset($res['data']['processLogs'])){
- $result['logList']=$res['data']['processLogs'];
- }else{
- $result['logList']=array();
- }
- } else {
- $this->errorMsg($res['msg']);
- }
- } else {
- $this->errorMsg('出库单ID不正确!');
- }
- //$result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $http = http('storage/coach/take/print/all', 'get', $this->authUsername);
- $response = formatResponse($http);
- $result['printList'] = $response['data'];
- $result['schoolName'] = $this->getSchoolName($schoolId);
- $result['scrapNo'] = $scrapNo;
- $this->render('useView', $result);
- }
- /**
- * 出库单增加
- */
- public function actionUseAddEdit()
- {
- $result = array();
- $outId = Req::get('outId');
- $itemType = Req::get('itemType')?Req::get('itemType'):0;
-
-
- $result['pmData'] = array();
- if($outId){
- $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- $result['itemName'] = $res['data']['itemList'][0]['itemName'];
- $result['itemId'] = $res['data']['itemList'][0]['itemId'];
- $result['stockNum'] = $res['data']['itemList'][0]['num'];
- if(!$itemType){
- $itemType = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:$itemType;
- $result['fcId'] = isset($res['data']['itemList'][0]['fcId'])?$res['data']['itemList'][0]['fcId']:0;
- }
-
- } else {
- $this->errorMsg($res['msg']);
- }
- }
- //品目名称
- $itemType = $itemType?$itemType:2;
- $pmNameList = $this->getSalePmList($itemType);
- // if (empty($pmNameList)){
- // $this->errorMsg('暂无出库品目,无法新增出库单!');
- // }
- $result['pmNameList'] = $pmNameList;
- $result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $result['schoolName'] = $this->getSchoolName($schoolId);
- $result['itemType'] = $itemType;
- //获取学年
- $http = http('sys/school/year/period/list', 'get', $this->authUsername);
- $response = formatResponse($http);
- $result['schoolYear'] = $response['data'];
- //获取产品
- $goodArr = $this->getGood();
- $result['goodList'] = $goodArr;
- //获取打印设备
- $http = http('storage/coach/take/print/all', 'get', $this->authUsername);
- $response = formatResponse($http);
- $result['printList'] = $response['data'];
- $this->render('useAddEdit', $result);
- }
- /**
- * ajax出库增加
- */
- public function actionAjaxUseAdd(){
- $result = array();
- $error = array();
- $itemId = Req::post('itemId');
- $outDate = Req::post('outDate');
- $outTitle = Req::post('outTitle');
- $outStockNum = Req::post('outStockNum');
- $useExplain= trim(Req::post('useExplain'));
- $outId = Req::post('outId');
- $itemType = Req::post('itemType');
- $orderId = Req::post('orderId');
- $fcId = Req::post('fcId');
- //品目名称
- $pmNameList = $this->getSalePmList($itemType);
- $pmNameArr = array();
- foreach($pmNameList as $value){
- if($value['itemId'] == $itemId){
- $pmNameArr = $value;
- }
- }
- if(!$pmNameArr){
- $error[] = '品目信息不正确!';
- }
- if(!$error){
- $params = array(
- 'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
- 'title' => $outTitle,
- 'outItemDetail' => array(
- 'itemId' => $itemId,
- 'num' => round($outStockNum,6),
- 'fcId'=>$fcId
- ),
- 'remark' => $useExplain,
- 'orderId'=>$orderId,
- );
- //编辑
- if($outId){
- $params['outId'] = $outId;
- $res = $this->getHttp('storage/coach/client/take/edit', 'post',$params);
- $this->imsLog("编辑领用出库单",'storage/coach/client/take/edit',$params,$res);
- }else{
- //新增
- $res = $this->getHttp('storage/coach/client/take/add', 'post',$params);
- $this->imsLog("新增领用出库单",'storage/coach/client/take/add',$params,$res);
- }
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1,'data' => $result));exit();
- }
- }
- /**
- * 关联正式订单
- */
- public function actionUseRelOrder(){
- $error = array();
- $result = array();
- $page = (int)Req::get('page');
- $doType = Req::get('doType');
- $outId = Req::get('outId');
- $allotNo = Req::get('allotNo');
- $page = $page ? $page : 1;
- if($doType=='relOrder'){
- $res = $this->getHttp('storage/coach/client/take/valid-num/'.$outId, 'get');
- if(isset($res['status']) && $res['status'] == 1){
- $result['validNum'] = isset($res['data']['validNum'])?$res['data']['validNum']:0;
- $result['confirmNum'] = isset($res['data']['confirmNum'])?$res['data']['confirmNum']:0;
- }else{
- $this->errorMsg($res['msg']);
- }
- $res = $this->getHttp('storage/coach/client/take/not-allot/orders/'.$page, 'get');
- if ($res['status'] == 1) {
- $result['pmDataList'] = $res['data'];
- } else {
- $this->errorMsg($res['msg']);
- }
- }else{
- $res = $this->getHttp('storage/coach/client/take/orders/'.$outId, 'get');
- if(isset($res['status']) && $res['status'] == 1){
- $result['validList'] = $res['data'];
- }else{
- $this->errorMsg($res['msg']);
- }
- $res = $this->getHttp('storage/coach/client/take/orders/students/'.$outId.'/'.$page, 'get');
- if ($res['status'] == 1) {
- $result['pmDataList'] = $res['data'];
- } else {
- $this->errorMsg($res['msg']);
- }
- }
- $result['outId'] = $outId;
- $result['allotNo'] = $allotNo;
- if($doType=='relOrder'){
- $this->render('useRelOrder', $result);
- }else{
- $this->render('useViewRelOrder', $result);
- }
- }
- /**
- * 获取可发放数量
- */
- public function actionAjaxValidNum(){
- $error = array();
- $result = array();
- $doType = Req::post('doType');
- $outId = Req::post('outId');
- if($doType == 'relOrder'){
- $res = $this->getHttp('storage/coach/client/take/valid-num/'.$outId, 'get');
- }else{
- $res = $this->getHttp('storage/coach/client/take/orders/'.$outId, 'get');
- }
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1,'data' => $result));exit();
- }
- }
- /**
- * 明细订单
- * @throws CException
- */
- public function actionAjaxAppointDetail(){
- $result = array();
- $error = array();
- $hasSelected = array();
- $orderId = trim(Req::post('orderId'));
- $outId = Req::post('outId')?Req::post('outId'):0;
- //可选学生
- $res = $this->getHttp('storage/coach/client/take/not-allot/students/'.$orderId, 'get');
- if($res['status'] == 1){
- $className = array();
- foreach ($res['data'] as $v){
- if(!isset($result[$v['clazzId']])){
- $result[$v['clazzId']] = array();
- }
- $result[$v['clazzId']][] = $v;
- $className[$v['clazzId']] = $v['clazzName'];
- }
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1,'data' => $this->renderPartial('_orderSelectStu',array('relStuList'=>$result,'className'=>$className,'outId'=>$outId), true)));exit();
- }
- }
- /**
- * 保存关联订单
- */
- public function actionAjaxSaveRelOrder(){
- $error = array();
- $result = array();
- $page = (int)Req::post('page');
- $studentIds = (array)Req::post('studentIds');
- $outId = Req::post('outId');
- if(!$studentIds){
- $error[] = '没有学生ID';
- }
- $params = array(
- 'osIdList' => $studentIds,
- 'outId' => $outId,
- );
- $res = $this->getHttp('storage/coach/client/take/allot/students', 'post',$params);
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1,'data' => $result));exit();
- }
- }
- /************** 退库 *****************/
- /**
- * 退库单增加
- */
- public function actionOutAddEdit()
- {
- $result = array();
- $outId = Req::get('outId');
- $itemType = Req::get('itemType')?Req::get('itemType'):0;
- $result['pmData'] = array();
- if($outId){
- $res = $this->getHttp('storage/coach/client/refound/detail/' . $outId, 'get');
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- if(!$itemType){
- $itemType = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:$itemType;
- }
- } else {
- $this->errorMsg($res['msg']);
- }
- }
- $itemType = $itemType?$itemType:2;
- $result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $result['schoolName'] = $this->getSchoolName($schoolId);
- $result['itemType'] = $itemType;
- //品目名称
- $pmNameList = $this->getPmList();
- $result['itemList'] = $pmNameList;
- //debug($result);
- $this->render('outAdd', $result);
- }
- /**
- * 退库选择品目
- */
- public function actionStockChioceItme(){
- $error = array();
- $result = array();
- $params = array();
- $page = Req::post('page');
- $itemOutIds = Req::post('itemOutIds');
- $itemType = Req::post('itemType');
- $outCode = Req::post('outCode');
- $itemId = Req::post('itemId');
- // $res = $this->getHttp('storage/coach/client/take/items', 'get');
- //筛选改成post
- if($itemType){
- $params['itemType'] = $itemType;
- }else{
- $params['itemType'] = 2;
- }
- if($outCode){
- $params['outCode'] = $outCode;
- }
- if($itemId){
- $params['itemId'] = $itemId;
- }
- // debug($params);exit;
- $res = $this->getHttp('storage/coach/client/take/items', 'post',$params);
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- exit();
- }
- /**
- * ajax退库增加
- */
- public function actionAjaxOutAdd(){
- $result = array();
- $error = array();
- $itemOutArr = (array)Req::post('itemOutArr');
- $outDate = Req::post('outDate');
- $outTitle = Req::post('outTitle');
- $useExplain= trim(Req::post('useExplain'));
- $outId = Req::post('outId');
- $itemOutInfo = array();
- if($itemOutArr){
- foreach ($itemOutArr as $v){
- $_arr = explode('_',$v);
- if(count($_arr) != 3){
- $error[] = '品目信息不正确!';
- break;
- }else{
- $_temp = array();
- $_temp['itemId'] = $_arr[0];
- $_temp['outId'] = $_arr[1];
- $_temp['num'] = round($_arr[2],6);
- $itemOutInfo[] = $_temp;
- }
- }
- }else{
- $error[] = '品目信息不正确!';
- }
- if(!$error){
- $params = array(
- 'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
- 'title' => $outTitle,
- 'outItemDetailList' => $itemOutInfo,
- 'remark' => $useExplain,
- 'title' => $outTitle,
- );
- //编辑
- if($outId){
- $params['outId'] = $outId;
- $res = $this->getHttp('storage/coach/client/refound/edit', 'post',$params);
- $this->imsLog("编辑退库单",'storage/coach/client/refound/edit',$params,$res);
- }else{
- //新增
- $res = $this->getHttp('storage/coach/client/refound/add', 'post',$params);
- $this->imsLog("新增退库单",'storage/coach/client/refound/add',$params,$res);
- }
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1,'data' => $result));exit();
- }
- }
- /**
- * 出库单出库
- */
- public function actionOutView()
- {
- $result = array();
- $outId = Req::get('outId');
- if (is_numeric($outId) && $outId > 0) {
- $res = $this->getHttp('storage/coach/client/refound/detail/' . $outId, 'get');
- // debug($res);
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- if(isset($res['data']['processLogs'])){
- $result['logList']=$res['data']['processLogs'];
- }else{
- $result['logList']=array();
- }
- $result['itemType'] = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:0;
- // $result['itemType'] = $res['data']['itemType'];
- // $result['orderNo'] = $res['data']['orderNo'];
- // $result['packageNo'] = $res['data']['packageNo'];
- // $result['quantity'] = $res['data']['quantity'];
- // $result['waitCheckNo'] = $res['data']['waitCheckNo'];
- // $result['saleNo'] = $res['data']['saleNo'];
- } else {
- $this->errorMsg($res['msg']);
- }
- } else {
- $this->errorMsg('退库单ID不正确!');
- }
- $result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $result['schoolName'] = $this->getSchoolName($schoolId);
- $this->render('outView', $result);
- }
- /**
- * 确认退库
- */
- public function actionAjaxConfirmOut()
- {
- $result = array();
- $error = array();
- $outId = Req::get('outId');
- if (is_numeric($outId) && $outId > 0) {
- $params = array();
- $res = $this->getHttp('storage/coach/client/refound/confirm/' . $outId, 'post',$params);
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- } else {
- $error[] = $res['msg'];
- }
- } else {
- $error[] = '退库单ID不正确!';
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1, 'data' => $result));
- exit();
- }
- }
- /**
- * 退库删除和中止
- */
- public function actionAjaxOutDelStop(){
- $result = array();
- $error = array();
- $businessKey = Req::get('businessKey');
- $doType = Req::get('doType');
- if ($businessKey) {
- if($doType == 'del'){
- $http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
- $response = formatResponse($http);
- $this->imsLog('出库或退库删除','activiti/coach/process-instances/'.$businessKey,array(),$response);
- }else{
- $http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
- $response = formatResponse($http);
- $this->imsLog('出库或退库中止','activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
- }
- if (!$response['status']){
- $error[] = $response['data'];
- }
- } else {
- $error[] = 'businessKey不正确!';
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));exit();
- } else {
- echo json_encode(array('status' => 1, 'data' => $result,'msg' => '提交成功!'));
- exit();
- }
- }
- /**
- * 获取学校名称
- */
- public function getSchoolName($schoolId){
- $schoolName = '';
- if($schoolId){
- $schoolInfo = BusinessSchool::model()->find('school_id=:school_id',array(':school_id'=>$schoolId));
- if(isset($schoolInfo->school_name)){
- $schoolName = $schoolInfo->school_name;
- }
- }
- return $schoolName;
- }
-
- /********新盘点计划*************/
- public function actionNewStock(){
- $result = array();
- $condition = array();
- $page = Req::get('page')?Req::get('page'):1;
- if(Req::get('planName')){
- $condition['title'] = Req::get('planName');
- }
- if(Req::get('startStockDate')){
- $condition['beginTime'] = date("Y-m-d H:i:s",strtotime(Req::get('startStockDate')));
- }
- if(Req::get('endStockDate')){
- $condition['endTime'] = date('Y-m-d H:i:s',strtotime(Req::get('endStockDate').' + 23 hours'));
- }
- $condition['pageNum'] = $page;
- $res = $this->getHttp('plan/coach/page', 'post', $condition);
- // debug($res);
- if(!$res || $res['status'] != 1){
- $this->errorMsg($res['msg']);
- }else{
- if(isset($res['data']) && isset($res['data']['list'])){
- $result['list'] = $res['data']['list'];
- }
- $result['page'] = $res['data'];
- }
- $this->render('newstock',$result);
- }
-
- public function actionCreatePlanList(){
- $result = array();
- $planId = Req::get('planId');
- if(isset($this->schoolInfo->school_name) && isset($this->coachInfo['coach_name'])){
- $result['title'] = $this->schoolInfo->school_name.'-'.$this->coachInfo['coach_name'].'的盘点单'.date("Ymd",time());
- }else{
- $result['title'] = '';
- }
- $res = $this->getHttp('plan/coach/item/'.$planId, 'get');
- // debug($res);
- if(!$res || $res['status'] != 1){
- $this->errorMsg($res['msg']);
- }else{
-
- if($res['data'] && isset($res['data']['fixedList'])){
- // debug($res['data']['fixedList']);
- if($res['data']['fixedList']){
- foreach($res['data']['fixedList'] as $k=>$v){
- $itemId = $v['itemId'];
- $http = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
- if($http['status']){
- if($http['data']){
- $res['data']['fixedList'][$k]['originIds'] = implode(",", $http['data']);
- }else{
- $res['data']['fixedList'][$k]['originIds'] = '';
- }
- }else{
- $res['data']['fixedList'][$k]['originIds'] = '';
- }
- }
- }
- }
- }
- $result['list'] = $res['data'];
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- $result['planId'] = $planId;
- //示例图片
- $result['result'] = array();
- $data = $this->getHttp('storage-stock/coach/example', 'get');
- if($data && isset($data['status']) && $data['status'] == 1){
- if(isset($data['data']) && $data['data']){
- // $list = $data['data'];
- $result['result'] = $data['data'];
- }
- }
- // debug($result);
- $this->render('createPlanList',$result);
-
- }
-
- //获取编号
- public function actionAjaxGetIdentifier() {
- $planId = Req::post('planId');
- $http = $this->getHttp('storage-inventory/coach/fixed/'.$planId, 'get');
- if($http['status']){
- if($http['data']){
- returnMsg(1,'success',$http['data']);
- }else{
- returnMsg(0,'暂无数据');
- }
- }else{
- returnMsg(0,$http['msg']);
- }
- }
-
- //提交盘点单
- public function actionAjaxNewStockAdd(){
- $params = array();
- $params['pId'] = Req::post('pId');
- $params['stockTitle'] = Req::post('stockTitle');
- $params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
- $params['images'] = (array)Req::post('imgArr');
- $params['remark'] = Req::post('remark');
- $params['details'] = Req::post('details');
- $response = $this->getHttp('storage-stock/coach/add','post',$params);
- $this->imsLog("销售盘点-新增",'storage-stock/coach/add',$params,$response);
- if ($response['status']){
- returnMsg(1,$response['msg']);
- }else{
- returnMsg(0,$response['msg']);
- }
- }
-
- //查看盘点单
- public function actionViewPlanList(){
- // echo 11;exit;
- $result = array();
- $planId = Req::get('planId');
- $statusId = Req::get('statusId');
- $res = $this->getHttp('storage-stock/coach/edit/'.$planId, 'get');
- // debug($res);
- if($res['status']){
-
- if($res['data']['stocktakingDate']){
- $res['data']['stocktakingDate'] = date("Y-m-d",strtotime($res['data']['stocktakingDate']));
- }
- $result['list'] = $res['data'];
- if(isset($res['data']['resDTOList'])){
- $result['logList']=$res['data']['resDTOList'];
- }else{
- $result['logList']=array();
- }
- }else{
- $this->errorMsg($res['msg']);
- }
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- $result['statusId'] = $statusId;
- // debug($result['list']);
- $this->render('viewPlanList',$result);
- }
-
- //编辑盘点单
- public function actionAjaxNewStockEdit(){
- $params = array();
- $params['pId'] = Req::post('pId');
- $params['stockTitle'] = Req::post('stockTitle');
- $params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
- $params['images'] = (array)Req::post('imgArr');
- $params['remark'] = Req::post('remark');
- $params['details'] = Req::post('details');
- $params['stockId'] = Req::post('stockId');
- $params['processInfo'] = Req::post('processInfo');
- // debug($params);
- $response = $this->getHttp('storage-stock/coach/edit','put',$params);
- $this->imsLog("销售盘点-新增",'storage-stock/coach/edit',$params,$response);
- if ($response['status']){
- returnMsg(1,$response['msg']);
- }else{
- returnMsg(0,$response['msg']);
- }
- }
- public function actionTransferList(){
- $result = array();
- $params = array();
- $page = Req::get('page') ? Req::get('page') : 1;
- if (Req::get('itemsType') && Req::get('itemsType')>0) {
- $params['itemType'] = intval(Req::get('itemsType'));
- }
- if (Req::get('itemId')) {
- $params['itemId'] = Req::get('itemId');
- }
- if(Req::get('transferType')){
- if(Req::get('transferType') == 2){
- $params['changeType'] = 0;
- }else{
- $params['changeType'] = intval(Req::get('transferType'));
- }
- }
- if(Req::get('endDate')){
- $params['endTime'] = Req::get('endDate');
- }
- //品目名称
- $pmNameList = $this->getPmList();
- $result['itemList'] = $pmNameList;
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $params['pageNo'] = $page;
- $params['storageId'] = $schoolId;
- $res = $this->getHttp('storage/change/coach/list', 'POST', $params);
- $result['list'] = array();
- if ($res['status'] == 1) {
- $result['list'] = $res['data']['list'];
- $result['page'] = $res['data'];
- } else {
- $result['list'] = array();
- $result['page'] = array();
- }
- $this->render('transferList', $result);
- }
- public function actionCreateTransfer(){
- $result = array();
- $outId = Req::get('outId');
- //品目名称
- $result['pmData'] = array();
- if($outId){
- $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- $result['itemName'] = $res['data']['itemList'][0]['itemName'];
- $result['itemId'] = $res['data']['itemList'][0]['itemId'];
- $result['stockNum'] = $res['data']['itemList'][0]['num'];
- } else {
- $this->errorMsg($res['msg']);
- }
- }
- // $pmNameList = $this->getSalePmList();
- // if (empty($pmNameList)){
- // $this->errorMsg('暂无品目,无法新建转移!');
- // }
- $http = $this->getHttp('storage-inventory/coach-item/2', 'get');
- $result['pmNameList'] = $http['data'];
- $result['coachName'] = isset(Yii::app()->session['coachInfo']['coach_name'])?Yii::app()->session['coachInfo']['coach_name']:'';
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $result['schoolName'] = $this->getSchoolName($schoolId);
- $this->render('createTransfer', $result);
- }
- public function actionAjaxGetItem(){
- $type = Req::post('type');
- $res = $this->getHttp('storage-inventory/coach-item/'.$type, 'get');
- $error = array();
- if ($res['status'] == 1) {
- $result = $res['data'];
- } else {
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>', $error)));
- } else {
- echo json_encode(array('status' => 1, 'data' => $result));
- }
- exit;
- }
- public function actionAjaxAddTransfer(){
- $itemId = Req::post('itemId');
- $title = Req::post('title');
- $transferType = intval(Req::post('transferType'));
- $outDate = Req::post('outDate');
- $outStockNum = Req::post('outStockNum');
- $itemsType = intval(Req::post('itemsType'));
- if(isset(Yii::app()->session['coachInfo']['school_id'])){
- $schoolId = Yii::app()->session['coachInfo']['school_id'];
- }else{
- $schoolId = 0;
- }
- $params = array(
- 'changeDate' => $outDate.' 00:00:00',
- 'changeType' => $transferType,
- 'icTitle' => $title,
- 'itemType' => $itemsType,
- 'storageId'=>intval($schoolId),
- 'details' => array(
- array(
- 'changeNo'=>round($outStockNum,6),
- 'itemId'=>$itemId
- )
- ),
- );
- $response = $this->getHttp('storage/change/coach/add','POST',$params);
- if ($response['status']){
- returnMsg(1,$response['msg']);
- }else{
- returnMsg(0,$response['msg']);
- }
- }
- /*****************新建退库单*********************/
- //新建退库单
- public function actionDeliveryOutAdd()
- {
- $result = array();
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- //品目名称
- $pmNameList = $this->getSalePmList();
- if (empty($pmNameList)){
- $this->errorMsg('暂无出库品目,无法新增出库单!');
- }
- $result['pmNameList'] = $pmNameList;
- $result['pmData'] = array();
- $this->render('deliveryOutAdd', $result);
- }
- /**
- * 关联正式订单
- */
- public function actionAjaxOutputOrder(){
- $error = array();
- $result = array();
- $page = (int)Req::post('page');
- $orderId = Req::post('orderId');
- $doType = Req::post('doType');
- $page = $page ? $page : 1;
- $res = $this->getHttp('storage-output/coach/order/list/'.$page, 'get');
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- die;
- }
- /**
- * 销售出库编辑学生
- * @throws CException
- */
- public function actionAjaxAddOutputStu(){
- $result = array();
- $error = array();
- $hasSelected = array();
- $params = array();
- $orderId = trim(Req::post('orderId'));
- $inId = Req::post('inId')?Req::post('inId'):0;
- if(empty($orderId)){
- echo json_encode(array('status' => 0, 'error' => '请选择订单'));
- }
- $params['orderId'] = $orderId;
- $res = $this->getHttp('storage-output/coach/order/students/'.$orderId, 'get');
- $gradeInfo = '';
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'notice'=>$gradeInfo,'data' => $this->renderPartial('_selectOutStu',array('relStuList'=>$result,'hasSelected'=>$hasSelected,'inId'=>$inId), true)));
- }
- exit;
- }
- /**
- * ajax销售出库增加
- */
- public function actionAjaxDeliveryOutAdd(){
- $result = array();
- $error = array();
- $orderId = Req::post('orderId');
- $outDate = Req::post('outDate');
- $stuIds= (array)Req::post('stuSeledArr');
- if(empty($stuIds)){
- $error[] = '请选择学生!';
- }
- // //品目名称
- // $pmNameList = $this->getSalePmList();
- // $pmNameArr = array();
- // foreach($pmNameList as $value){
- // if($value['itemId'] == $itemId){
- // $pmNameArr = $value;
- // }
- // }
- //
- // if(!$pmNameArr){
- // $error[] = '品目信息不正确!';
- // }
- if(!$error){
- $params = array(
- 'osIdList' => $stuIds
- );
- //编辑
- // if(Req::post('inId')){
- // $res = $this->getHttp('storage-input/coach/sale/edit/'.Req::post('inId'), 'post',$params);
- // $this->imsLog("销售退库-编辑出库单",'storage-output/coach/edit',$params,$res);
- // }else{
- // //新增
- // }
- $res = $this->getHttp('storage-input/coach/sale/insert', 'post',$params);
- $this->imsLog("取消分配",'storage-input/coach/sale/insert',$params,$res);
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = $res['msg'];
- }
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'error' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- exit;
- }
- /**
- * 查看销售退库
- */
- public function actionDeliveryOutView()
- {
- $result = array();
- $inId = Req::get('inId');
- $result['basic'] = $this->setToken();
- if (is_numeric($inId) && $inId > 0) {
- $res = $this->getHttp('storage-input/coach/sale/' . $inId, 'get');
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- $result['pmStudent'] = $res['data']['students'];
- } else {
- $this->errorMsg($res['msg']);
- }
- } else {
- $this->errorMsg('取消分配单ID不正确!');
- }
- $this->render('deliveryOutView', $result);
- }
- /**
- * 删除退库
- */
- public function actionAjaxDelIn()
- {
- $inId = Req::post('inId');
- if(empty($inId)){
- returnMsg(0, '参数错误');
- }
- $http = http('storage-input/coach/sale/'.$inId, 'delete', $this->authUsername);
- print_r($http);die;
- $response = formatResponse($http);
- $this->imsLog("销售退库-删除退库",'storage-input/coach/sale/'.$inId,array(),$response);
- if ($response['status']){
- returnMsg(1, '提交成功!');
- }else{
- returnMsg(0, $response['data']);
- }
- }
- /**
- * 销售出库编辑
- */
- public function actionDeliveryOutEdit()
- {
- $result = array();
- $inId = Req::get('inId');
- //品目名称
- $pmNameList = $this->getSalePmList();
- if (empty($pmNameList)){
- $this->errorMsg('暂无出库品目,无法新增出库单!');
- }
- $result['pmNameList'] = $pmNameList;
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- if (is_numeric($inId) && $inId > 0) {
- $res = $this->getHttp('storage-input/coach/sale/' . $inId, 'get');
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- $result['itemId'] = $res['data']['inputDetails'][0]['itemId'];
- $result['pmStudent'] = $res['data']['students'];
- $result['pmData']['outDate'] = $res['data']['inDate'];
- } else {
- $this->errorMsg($res['msg']);
- }
- } else {
- $this->errorMsg('退库单ID不正确!');
- }
- $this->render('deliveryOutEdit', $result);
- }
-
- /**
- * 查看盘点示例
- */
- public function actionPlanExamples(){
- // $this->errorMsg('暂无出库品目,无法新增出库单!');
- $list = array();
- $planId = Req::get('planId');
- $data = $this->getHttp('storage-stock/coach/example', 'get');
- if($data && isset($data['status']) && $data['status'] == 1){
- if(isset($data['data']) && $data['data']){
- $list = $data['data'];
- }else{
- $this->errorMsg('暂无示例图片!');
- }
- }else{
- $this->errorMsg('暂无示例!');
- }
- // debug($data);
- $this->render('planExamples', array('result'=>$list,'planId'=>$planId));
-
-
- }
- //取消凭据
- public function actionSuspended(){
- $businessKey= Req::post('businessKey');
- if(empty($businessKey)){
- returnMsg(0, '参数错误');
- }
- $http = http("activiti/coach/process-instances/{$businessKey}/suspended", 'put', $this->authUsername);
- $response = formatResponse($http);
- if ($response['status']){
- returnMsg(1, '提交成功!');
- }else{
- returnMsg(0, $response['data']);
- }
- }
- //重新确认收货
- public function actionRepeatReceipt(){
- $imgArr= Req::post('imgArr');
- $atoId= Req::post('atoId');
- if(empty($imgArr) || empty($atoId)){
- returnMsg(0, '参数错误');
- }
- $params = array(
- 'atoId' => $atoId,
- 'images' => $imgArr,
- );
- $res = $this->getHttp('storage-allocate/coach/fixed-receipt/'.$atoId, 'put', $params);
- if ($res['status']){
- returnMsg(1, '提交成功!');
- }else{
- returnMsg(0, $res['data']);
- }
- }
- //领用,发放订单
- public function actionGrant(){
- $outId = Req::get('outId');
- $num = 0;
- $dataList=array();
- if (is_numeric($outId) && $outId > 0) {
- //搜索销售订单
- $orderNo=Req::get('orderNo');
- $grade=Req::get('grade');
- $semester=Req::get('semester');
- $schoolYearId=Req::get('schoolYearId');
- $page=Req::get('page');
- if(!$page) $page=1;
- $params=array();
- $params['pageNum']=$page;
- $params['outId']=$outId;
- if($orderNo){
- $params['orderNo']=$orderNo;
- }
- if($grade){
- $params['grade']=$grade;
- }
- if($semester){
- $params['semester']=$semester-1;
- }
- if($schoolYearId){
- $params['schoolYearId']=$schoolYearId;
- }
- $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post',$params);
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['pmData'] = $res['data'];
- if(isset($res['data']['itemList']) && $res['data']['itemList'][0]){
- $result['num']= $res['data']['itemList'][0]['num'];
- $result['typeId']= $res['data']['itemList'][0]['typeId'];
- }else{
- $this->errorMsg('数据为空');
- }
- if(isset($res['data']['sendNo'])){
- $result['sendNo']=$res['data']['sendNo'];
- }else{
- $result['sendNo']=0;
- }
- if(isset($res['data']['refoundNo'])){
- $result['refoundNo']=$res['data']['refoundNo'];
- }else{
- $result['refoundNo']=0;
- }
- } else {
- $this->errorMsg($res['msg']);
- }
- }
- $params = array();
- //获取学年
- $http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
- $response = formatResponse($http);
- $result['schoolYear'] = $response['data'];
- $result['outId']=$outId;
- //debug($result);
- $this->render('grant',$result);
- }
- //查看发放记录
- public function actionViewGrant(){
- $outId = Req::get('outId');
- $num = 0;
- $dataList=array();
- if (is_numeric($outId) && $outId > 0) {
- //搜索销售订单
- $orderNo=Req::get('orderNo');
- $grade=Req::get('grade');
- $semester=Req::get('semester');
- $schoolYearId=Req::get('schoolYearId');
- $page=Req::get('page');
- if(!$page) $page=1;
- $params=array();
- $params['pageNum']=$page;
- $params['outId']=$outId;
- if($orderNo){
- $params['orderNo']=$orderNo;
- }
- if($grade){
- $params['grade']=$grade;
- }
- if($semester){
- $params['semester']=$semester-1;
- }
- if($schoolYearId){
- $params['schoolYearId']=$schoolYearId;
- }
- $res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post',$params);
- $result['pmData'] = array();
- if ($res['status'] == 1) {
- $result['itemType']=$res['data']['itemType'];
- $result['pmData'] = $res['data']['coachSaleOrders'];
- } else {
- $this->errorMsg($res['msg']);
- }
- }
- //获取学年
- $http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
- $response = formatResponse($http);
- $result['schoolYear'] = $response['data'];
- //学期
- $http = http('sys/school/year/semester/list', 'get', $this->authUsername);
- $response = formatResponse($http);
- $result['seasonList'] = $response['data'];
- $result['outId']=$outId;
- $result['orderNo']=$orderNo;
- $result['grade']=$grade;
- $result['semester']=$semester;
- $result['schoolYearId']=$schoolYearId;
- $this->render('view_grant',$result);
- }
- //选择销售订单
- public function actionAjaxGetOrderList(){
- $orderNo=Req::post('orderNo');
- $grade=Req::post('grade');
- $semester=Req::post('semester');
- $schoolYear=Req::post('schoolYearId');
- $page=Req::post('page');
- $typeId=Req::post('typeId');
- $error=array();
- if(!$page) $page=1;
- $params=array();
- $params['pageNum']=$page;
- if($grade){
- $params['grade']=$grade;
- }
- if($orderNo){
- $params['orderNo']=$orderNo;
- }
- if($semester){
- $params['semester']=$semester;
- }
- if($schoolYear){
- $params['schoolYearId']=$schoolYear;
- }
- if($typeId){
- $params['itemType']=$typeId;
- }
- $res = $this->getHttp('storage/coach/client/take/order/list', 'post', $params);
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- exit();
- }
- /**
- * @return array
- * 获取商品
- */
- public function getGood()
- {
- $result = array();
- $http = http('goods/up/list', 'get', $this->authUsername);
- $response = formatResponse($http);
- if($response['status']){
- $result = $response['data'];
- }
- return $result;
- }
- //保存发放订单
- public function actionSaveGrant(){
- $outId=Req::post('outId');
- $orders=Req::post('orders');
- if(!$outId || !$orders){
- returnMsg(0, '参数错误');
- }
- $error=array();
- $param['outId']=$outId;
- $param['orders']=$orders;
- $res = $this->getHttp('storage/coach/client/take/allot/order', 'post', $param);
- if($res['status'] == 1){
- $result = $res['data'];
- }else{
- $error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
- }
- if ($error) {
- echo json_encode(array('status' => 0, 'msg' => implode('<br/>',$error)));
- } else {
- echo json_encode(array('status' => 1,'data' => $result));
- }
- exit();
- }
- //发货
- public function actionDeliverGoods(){
- $result = array();
- $atId = trim(Req::get('atId'));
- $result['sendData'] = array();
- if ($atId) {
- //发货记录
- $sendRes = $this->getHttp('storage-allocate/coach/deliver-record/' . $atId, 'get');
- if ($sendRes['status'] == 1) {
- $result['sendData'] = $sendRes['data'];
- }
- $res1 = $this->getHttp('storage-allocate/coach/details/' . $atId, 'GET');
- if ($res1['status'] == 1) {
- $result['atType']=$res1['data']['atType'];
- $result['images']=$res1['data']['images'];
- if($res1['data']['details']){
- foreach ($res1['data']['details'] as $val){
- $result['allocateDetail'][]=array(
- 'atDetailId'=>$val['atDetailId'],
- 'itemId'=>$val['itemId'],
- 'itemName'=>$val['itemName'],
- 'applyNo'=>$val['applyNo'],
- 'invNo'=>$val['invNo'],
- 'unitName'=>$val['unitName'],
- 'typeName'=>$val['typeName'],
- 'itemSpec'=>$val['itemSpec'],
- 'deliveryStatusName'=>$val['deliveryStatusName'],
- );
- }
- }
- }
- //快递
- $express = $this->getHttp('dictionary/list/type-code/express', 'get');
- if ($express['status'] == 1) {
- $result['express'] = $express['data'];
- }
- $url = Yii::app()->params['ims']['url'].'api/upload/image';
- $result['uploadUrl'] = $url;
- $result['basic'] = $this->setToken();
- }
- $this->render('deliverGoods',$result);
- }
- //读取固定资产编号
- public function actionGetFixedAssetsNo(){
- $itemId = trim(Req::post('itemId'));
- $result['status']=1;
- $Fixed = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
- if ($Fixed['status'] == 1) {
- $result['data'] = $Fixed['data'];
- }
- exit(json_encode($result));
- }
- //确认发货
- public function actionConfirmDeliver(){
- $atDetailId= Req::post('atDetailId');
- $logisticsCode= Req::post('logisticsCode');
- $logisticsName= Req::post('logisticsName');
- $fixedCodes= Req::post('fixedCodes');
- $no= Req::post('no');
- $imgUrls= Req::post('imgUrls');
- $result['status']=0;
- $params=array(
- 'atDetailId'=>$atDetailId,
- 'logisticsCode'=>$logisticsCode,
- 'logisticsName'=>$logisticsName,
- 'fixedCodes'=>$fixedCodes,
- 'no'=>$no,
- 'imgUrls'=>$imgUrls
- );
- $rs = $this->getHttp('storage-allocate/coach/deliver', 'post',$params);
-
- if($rs['status']==1){
- $result['status']=1;
- }else{
- if($rs['data']){
- $result['msg']=$rs['data'];
- }else{
- $result['msg']='发货失败';
- }
- }
- exit(json_encode($result));
- }
- //取消调拨
- public function actionCancelAllocation(){
- $atId= Req::post('atId');
- $rs = $this->getHttp('storage-allocate/coach/status/'.$atId, 'put');
- $result['status']=0;
- if($rs['status']==1){
- $result['status']=1;
- }else{
- if($rs['data']){
- $result['msg']=$rs['msg'];
- }else{
- $result['msg']='操作失败';
- }
- }
- exit(json_encode($result));
- }
- //加载设备编号(添加零件)
- public function actionGetDevice(){
- $storageId= Req::post('storageId');
- $rs = $this->getHttp('storage-inventory/greater-zero/0/'.$storageId, 'get');
- exit(json_encode($rs));
- }
- //加载设备编号(添加零件)
- public function actionGetPart(){
- $fixedId= Req::post('fixedId');
- $rs = $this->getHttp('fixed/part/list/'.$fixedId, 'get');
- exit(json_encode($rs));
- }
- //根据零配件类型加载设备
- public function actionGetDeviceByPart(){
- $partType= Req::post('partType');
- $storageId= Req::post('storageId');
- $rs = $this->getHttp('storage-inventory/query-fixed/list/'.$partType.'/ '.$storageId, 'get');
- exit(json_encode($rs));
- }
- }
|