Report.php 105 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\Db;
  4. use think\facade\Validate;
  5. //报表处理类
  6. class Report extends Base
  7. {
  8. //商品表部分字段的中英文对照
  9. private $good_field_title = [
  10. 'spuCode' => '商品成本编号',
  11. 'good_code' => '商品编码',
  12. 'good_name' => '商品名称',
  13. 'cat_id' => '分类',
  14. 'brand_id' => '品牌',
  15. 'good_unit' => '商品单位',
  16. 'good_type' => '',
  17. 'companyNo' => '业务企业',
  18. 'moq' => '起订量',
  19. 'customized' => '定制工期',
  20. 'tax' => '税点',
  21. 'supplierNo' => '供应商',
  22. 'is_auth' => '是否有销售权限',
  23. 'is_stock' => '是否库存品',
  24. 'auth_img' => '销售授权图片',
  25. 'after_sales' => '售后说明',
  26. 'craft_desc' => '工艺说明',
  27. 'good_remark' => '商品备注',
  28. 'good_size' => '商品尺寸',
  29. 'weight' => '商品重量',
  30. 'packing_way' => '包装方式',
  31. 'packing_size' => '装箱尺寸',
  32. 'packing_spec' => '装箱规格',
  33. 'packing_list' => '包装清单',
  34. 'packing_weight' => '装箱重量',
  35. 'good_bar' => '商品条形码',
  36. 'supply_area' => '供货区域',
  37. 'delivery_place' => '发货地',
  38. 'origin_place' => '产地',
  39. 'delivery_day' => '物流时间',
  40. 'lead_time' => '供货周期',
  41. 'sample_day' => '调样周期',
  42. 'sample_fee' => '调样费用',
  43. 'good_img' => '商品详情主图 ',
  44. 'good_thumb_img' => '商品缩略图',
  45. 'good_info_img' => '商品详情图',
  46. 'cert_fee' => '证书费',
  47. 'packing_fee' => '包装费',
  48. 'cost_fee' => '工艺费',
  49. 'mark_fee' => '加标费',
  50. 'demo_fee' => '打样费',
  51. 'open_fee' => '开模费',
  52. 'noble_metal' => '贵金属种类',
  53. 'noble_weight' => '贵金属重量',
  54. 'is_gold_price' => '是否使用实时金价',
  55. 'cgd_gold_price' => '供应商采购金价',
  56. 'market_price' => '市场价',
  57. 'nake_price' => '含税成本价',
  58. 'is_step' => '阶梯价是否启用',
  59. 'is_online' => '是否上线',
  60. 'status' => '状态',
  61. 'createrid' => '创建人id',
  62. 'creater' => '创建人',
  63. 'is_del' => '是否删除',
  64. 'addtime' => '创建时间',
  65. 'updatetime' => '修改时间',
  66. 'is_exclusive' => '是否专属类型',
  67. 'is_diff' => '是否有工差',
  68. 'config' => '配置',
  69. 'other_config' => '其他配置',
  70. ];
  71. //产品价格和产品导出
  72. public function exportGood()
  73. {
  74. $param = $this->request->only(['start_date', 'end_date', 'platform_id', 'status'], 'post', 'trim');
  75. $val = Validate::rule([
  76. 'start_date|筛选开始时间' => 'require|date|elt:end_date',
  77. 'end_date|筛选结束时间' => 'require|date',
  78. 'platform_id|筛选平台ID' => 'require|number|gt:0',
  79. 'status|状态' => 'require|number|in:5,6,8',
  80. ]);
  81. if (!$val->check($param)) return error_show(1004, $val->getError());
  82. $where_ladder = [['gl.is_del', '=', 0]];
  83. $where_good = [['g.is_del', '=', 0]];
  84. if (!empty($param['start_date']) && !empty($param['end_date'])) {
  85. $where_ladder[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  86. $where_good[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  87. }
  88. if (!empty($param['platform_id'])) {
  89. $where_ladder[] = ['gp.platform_code', '=', $param['platform_id']];
  90. $where_good[] = ['gp.platform_code', '=', $param['platform_id']];
  91. }
  92. if (!empty($param['status'])) {
  93. $where_ladder[] = ['gp.exam_status', '=', $param['status']];
  94. $where_good[] = ['gp.exam_status', '=', $param['status']];
  95. }
  96. $data = [];
  97. //产品价格
  98. $rs_ladder = Db::name('good_ladder')
  99. ->alias('gl')
  100. ->field('g.good_name 商品名称,gl.market_price 市场价,g.tax 税率,gl.min_num 起订量,gl.sale_price 售价,gl.skuCode 商品编码,gl.cost_fee 工艺费,gl.market_platform 对比平台')
  101. ->where($where_ladder)
  102. ->leftJoin('good_platform gp', 'gp.skuCode=gl.skuCode')
  103. ->leftJoin('good g', 'g.spuCode=gp.spuCode')
  104. ->order('g.id')
  105. ->select()
  106. ->toArray();
  107. if (!empty($rs_ladder)) {
  108. $data[] = [
  109. 'head' => array_keys($rs_ladder[0]),
  110. 'list' => $rs_ladder,
  111. 'filename' => '产品价格' . date('YmdHis'),
  112. ];
  113. }
  114. //产品
  115. $rs_temp_good = Db::name('good')
  116. ->alias('g')
  117. ->field('"" 一级分类,"" 二级分类, g.cat_id 三级分类,g.good_name 商品名称,g.good_type 商品类型,g.brand_id 商品品牌,\'\' 型号,g.origin_place 产地,g.good_unit 计量单位,g.weight 重量g,\'\' 响应时间,g.lead_time 供货周期,g.good_size 商品尺寸,g.packing_size 装箱尺寸,g.packing_way 包装方式,g.packing_spec 装箱规格,g.packing_list 包装清单,g.delivery_place 发货地,g.delivery_day 物流时间,gp.skuCode 商品编码,s.name 供应商名称,g.creater 采购员,g.spuCode')
  118. ->where($where_good)
  119. ->leftJoin('good_platform gp', 'gp.spuCode=g.spuCode')
  120. ->leftJoin('supplier s', 's.code=g.supplierNo')
  121. ->order('g.id')
  122. ->select()
  123. ->toArray();
  124. $all_good_type = [0 => '非定制商品', 1 => '定制商品'];
  125. $all_brand = Db::name('brand')->whereIn('id', array_column($rs_temp_good, '商品品牌'))->where('is_del', 0)->column('brand_name', 'id');
  126. $all_cat = Db::name('cat')
  127. ->alias('c3')
  128. ->whereIn('c3.id', array_column($rs_temp_good, '三级分类'))
  129. ->where('c3.is_del', 0)
  130. ->leftJoin('cat c2', 'c2.id=c3.pid')
  131. ->leftJoin('cat c1', 'c1.id=c2.pid')
  132. ->column('c3.cat_name cat_name_3,c2.cat_name cat_name_2,c1.cat_name cat_name_1', 'c3.id');
  133. $all_unit = Db::name('unit')->whereIn('id', array_column($rs_temp_good, '计量单位'))->where('is_del', 0)->column('unit', 'id');
  134. foreach ($rs_temp_good as &$value) {
  135. $value['商品品牌'] = isset($all_brand[$value['商品品牌']]) ? $all_brand[$value['商品品牌']] : '';
  136. $value['商品类型'] = isset($all_good_type[$value['商品类型']]) ? $all_good_type[$value['商品类型']] : '';
  137. $value['一级分类'] = isset($all_cat[$value['三级分类']]['cat_name_1']) ? $all_cat[$value['三级分类']]['cat_name_1'] : '';
  138. $value['二级分类'] = isset($all_cat[$value['三级分类']]['cat_name_2']) ? $all_cat[$value['三级分类']]['cat_name_2'] : '';
  139. $value['三级分类'] = isset($all_cat[$value['三级分类']]['cat_name_3']) ? $all_cat[$value['三级分类']]['cat_name_3'] : '';
  140. $temp = explode(',', $value['产地']);
  141. $value['产地'] = GetAddr(json_encode(['provice_code' => isset($temp[0]) ? $temp[0] : '', 'city_code' => isset($temp[1]) ? $temp[1] : '', 'area_code' => isset($temp[2]) ? $temp[2] : '']));
  142. $value['计量单位'] = isset($all_unit[$value['计量单位']]) ? $all_unit[$value['计量单位']] : '';
  143. $temp_2 = explode(',', $value['发货地']);
  144. $value['发货地'] = GetAddr(json_encode(['provice_code' => isset($temp_2[0]) ? $temp_2[0] : '', 'city_code' => isset($temp_2[1]) ? $temp_2[1] : '', 'area_code' => isset($temp_2[2]) ? $temp_2[2] : '']));
  145. $value['型号'] = Db::name('good_spec')
  146. ->alias('gp')
  147. ->field('')
  148. ->leftJoin('specs s', 's.id=gp.spec_id')
  149. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  150. ->where([
  151. 'gp.spuCode' => $value['spuCode'],
  152. 'gp.is_del' => 0,
  153. 's.spec_name' => '型号',
  154. ])
  155. ->value('sv.spec_value', '');
  156. $value['响应时间'] = Db::name('good_spec')
  157. ->alias('gp')
  158. ->field('')
  159. ->leftJoin('specs s', 's.id=gp.spec_id')
  160. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  161. ->where([
  162. 'gp.spuCode' => $value['spuCode'],
  163. 'gp.is_del' => 0,
  164. 's.spec_name' => '响应时间',
  165. ])
  166. ->value('sv.spec_value', '');
  167. unset($value['spuCode']);
  168. }
  169. if (!empty($rs_temp_good)) {
  170. $data[] = [
  171. 'head' => array_keys($rs_temp_good[0]),
  172. 'list' => $rs_temp_good,
  173. 'filename' => '产品' . date('YmdHis'),
  174. ];
  175. }
  176. if (empty($data)) {
  177. $data[] = [
  178. 'head' => ['没有可供导出的数据'],
  179. 'list' => [],
  180. 'filename' => date('YmdHis'),
  181. ];
  182. }
  183. excelSaveBatch($data);
  184. }
  185. //【一、采购日报表】1.竞价单总数
  186. public function zixunTotal()
  187. {
  188. $param = $this->request->only([
  189. 'token',
  190. 'start_date' => '',
  191. 'end_date' => '',
  192. 'page' => 1,
  193. 'size' => 15,
  194. ], 'post', 'trim');
  195. $val_params = Validate::rule([
  196. 'start_date' => 'date|elt:end_date',
  197. 'end_date' => 'date',
  198. ]);
  199. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  200. $where = [['a.is_del', '=', 0]];
  201. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['a.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  202. $count = Db::name('consult_info')
  203. ->alias('a')
  204. ->field('DATE_FORMAT(a.addtime,"%Y-%m-%d") addtime,cii.name,count(a.id) total')
  205. ->leftJoin('consult_order b', 'b.zxNo=a.zxNo')
  206. ->leftJoin('depart_user u', 'u.uid=b.saleid AND u.is_del=0')
  207. ->leftJoin('company_item cii', 'cii.id=u.itemid')
  208. ->where($where)
  209. ->group('addtime,u.itemid')
  210. ->order('addtime')
  211. ->count();
  212. $list = Db::name('consult_info')
  213. ->alias('a')
  214. ->field('DATE_FORMAT(a.addtime,"%Y-%m-%d") addtime,cii.name,count(a.id) total')
  215. ->leftJoin('consult_order b', 'b.zxNo=a.zxNo')
  216. ->leftJoin('depart_user u', 'u.uid=b.saleid AND u.is_del=0')
  217. ->leftJoin('company_item cii', 'cii.id=u.itemid')
  218. ->where($where)
  219. ->group('addtime,u.itemid')
  220. ->order('addtime', 'desc')
  221. ->page($param['page'], $param['size'])
  222. ->select()
  223. ->toArray();
  224. return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
  225. }
  226. //【一、采购日报表】2.采购订单总金额
  227. public function purcheaseOrderSum()
  228. {
  229. $param = $this->request->only([
  230. 'token',
  231. 'start_date' => '',
  232. 'end_date' => '',
  233. // 'page' => 1,
  234. // 'size' => 15,
  235. ], 'post', 'trim');
  236. $val_params = Validate::rule([
  237. 'start_date|创建开始日期' => 'date|elt:end_date',
  238. 'end_date|创建结束日期' => 'date|egt:start_date',
  239. ]);
  240. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  241. $where = [['po.is_del', '=', 0]];
  242. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['po.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  243. //统计条数的时候,不能按照status分组,否则下方列表不准
  244. // $count = Db::name('purchease_order')
  245. // ->alias('po')
  246. // ->leftJoin('depart_user du', 'du.uid=po.cgder_id AND du.is_del=0')
  247. // ->leftJoin('company_item ci', 'ci.id=du.itemid')
  248. // ->where($where)
  249. // ->order('addtime,itemid')
  250. // ->field('DATE_FORMAT(po.addtime,"%Y-%m-%d") addtime,SUM(po.total_fee) total_fee,COUNT(po.id) total_num,du.itemid,ci.name,"" wait_total_fee,"" wait_total_num')
  251. // ->group('addtime,du.itemid')
  252. // ->count();
  253. // $list = Db::name('purchease_order')
  254. // ->alias('po')
  255. // ->field('DATE_FORMAT(po.addtime,"%Y-%m-%d") addtime,SUM(po.total_fee) total_fee,COUNT(po.id) total_num,po.status,du.itemid,ci.name,"" wait_total_fee,"" wait_total_num')
  256. // ->leftJoin('depart_user du', 'du.uid=po.cgder_id AND du.is_del=0')
  257. // ->leftJoin('company_item ci', 'ci.id=du.itemid')
  258. // ->where($where)
  259. // ->order(['addtime'=>'desc','itemid'=>'asc'])
  260. // ->page($param['page'], $param['size'])
  261. // ->group('addtime,du.itemid,po.status')
  262. // ->cursor();
  263. $list = Db::name('purchease_order')
  264. ->alias('po')
  265. ->field('po.id,DATE_FORMAT(po.addtime,"%Y%m%d") addtime,po.cgder_id,IF(ISNULL(`du`.`itemid`),0,`du`.`itemid`) itemid,IF(ISNULL(`ci`.`name`),"供应商端",`ci`.`name`) name,po.total_fee,po.good_num,po.status,po.supplierNo')
  266. ->leftJoin('depart_user du', 'du.uid=po.cgder_id AND du.is_del=0 AND du.nickname = po.cgder')
  267. ->leftJoin('company_item ci', 'ci.id=du.itemid')
  268. ->where($where)
  269. ->order(['addtime' => 'desc', 'itemid' => 'asc'])
  270. // ->cursor();
  271. ->select()
  272. ->toArray();
  273. $all_supplier_no = array_column($list, 'supplierNo');
  274. $all_supplier = checkHasAccountBySupplierNos($all_supplier_no);//检查这些供应商账号是否开通账户
  275. $all_supplier = array_keys($all_supplier);
  276. $data = [];
  277. foreach ($list as $value) {
  278. //把供应商端的数据单列出来
  279. if (in_array($value['supplierNo'], $all_supplier)) {
  280. $value['itemid'] = -1;
  281. $value['name'] = '供应商端';
  282. }
  283. if (!isset($data[$value['addtime']][$value['itemid']])) {
  284. $data[$value['addtime']][$value['itemid']] = [
  285. 'addtime' => date('Y-m-d', strtotime($value['addtime'])),
  286. // 'itemid' => $value['itemid'],
  287. 'name' => $value['name'],
  288. 'total_fee' => '0',
  289. 'total_num' => '0',
  290. 'good_num' => '0',
  291. 'wait_confirm_total_fee' => '0',//待与供应商确认-总金额
  292. 'wait_confirm_total_num' => '0',//待与供应商确认-总单数
  293. 'wait_in_total_fee' => '0',//待入库-总金额
  294. 'wait_in_total_num' => '0',//待入库-总单数
  295. ];
  296. }
  297. $data[$value['addtime']][$value['itemid']]['total_fee'] = bcadd($data[$value['addtime']][$value['itemid']]['total_fee'], $value['total_fee'], 2);
  298. $data[$value['addtime']][$value['itemid']]['total_num'] = bcadd($data[$value['addtime']][$value['itemid']]['total_num'], 1);
  299. $data[$value['addtime']][$value['itemid']]['good_num'] = bcadd($data[$value['addtime']][$value['itemid']]['good_num'], $value['good_num']);
  300. switch ($value['status']) {
  301. case 0:
  302. $data[$value['addtime']][$value['itemid']]['wait_confirm_total_fee'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_confirm_total_fee'], $value['total_fee'], 2);
  303. $data[$value['addtime']][$value['itemid']]['wait_confirm_total_num'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_confirm_total_num'], '1');
  304. break;
  305. case 1:
  306. $data[$value['addtime']][$value['itemid']]['wait_in_total_fee'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_in_total_fee'], $value['total_fee'], 2);
  307. $data[$value['addtime']][$value['itemid']]['wait_in_total_num'] = bcadd($data[$value['addtime']][$value['itemid']]['wait_in_total_num'], 1);
  308. break;
  309. }
  310. // if ($value['status'] == 0) {
  311. // $data[$value['addtime']][$value['itemid']]['wait_total_fee'] += $value['total_fee'];
  312. // $data[$value['addtime']][$value['itemid']]['wait_total_num'] += $value['total_num'];
  313. // } else {
  314. // $data[$value['addtime']][$value['itemid']]['total_fee'] += $value['total_fee'];
  315. // $data[$value['addtime']][$value['itemid']]['total_num'] += $value['total_num'];
  316. // }
  317. }
  318. //去除下标
  319. $da = [];
  320. foreach ($data as $v) {
  321. foreach ($v as $vvv) {
  322. $da[] = $vvv;
  323. }
  324. }
  325. return app_show(0, '请求成功', $da);
  326. }
  327. //【一、采购日报表】3.采购员回复竞价单数
  328. public function consultBidsSum()
  329. {
  330. $param = $this->request->only([
  331. 'token',
  332. 'start_date' => '',
  333. 'end_date' => '',
  334. // 'page' => 1,
  335. // 'size' => 15,
  336. // 'supplier' => ''
  337. ], 'post', 'trim');
  338. $val_params = Validate::rule([
  339. 'start_date' => 'date|elt:end_date',
  340. 'end_date' => 'date',
  341. ]);
  342. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  343. $where = [['cb.is_del', '=', 0]];
  344. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cb.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  345. // if ($param['supplier'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier'] . '%'];
  346. // $count = Db::name('consult_bids')
  347. // ->alias('cb')
  348. //// ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,du.itemid,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,du.nickname,ci.name')
  349. // ->leftJoin('consult_info c', 'c.infoNo=cb.infoNo')
  350. // ->leftJoin('depart_user du', 'du.uid=cb.createrid AND du.is_del=0')
  351. // ->leftJoin('company_item ci', 'ci.id=du.itemid')
  352. //// ->leftJoin('supplier s', 's.code=cb.supplierNo')
  353. // ->where($where)
  354. // ->group('addtime,du.itemid,ci.name ,cb.createrid,du.nickname')
  355. // ->order('addtime,du.itemid,ci.name ,cb.createrid,du.nickname')
  356. // ->count();
  357. $list = Db::name('consult_bids')
  358. ->alias('cb')
  359. ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,du.itemid,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,IF(ISNULL(`du`.`nickname`),`s`.`name`,`du`.`nickname`) nickname,IF(ISNULL(`ci`.`name`),"供应商",`ci`.`name`) name,s.name supplierName')
  360. ->leftJoin('consult_info c', 'c.infoNo=cb.infoNo')
  361. ->leftJoin('depart_user du', 'du.uid=cb.createrid AND du.is_del=0')
  362. ->leftJoin('company_item ci', 'ci.id=du.itemid')
  363. ->leftJoin('supplier s', 's.code=cb.supplierNo')
  364. ->where($where)
  365. ->group('addtime,du.itemid,ci.name ,cb.createrid,du.nickname,s.name')
  366. ->order('addtime desc,du.itemid,ci.name ,cb.createrid,du.nickname')
  367. // ->page($param['page'], $param['size'])
  368. ->cursor();
  369. $data = [];
  370. foreach ($list as $value) {
  371. if ($value['name'] == '供应商') {
  372. $data[] = $value;
  373. continue;
  374. }
  375. if (!isset($data[$value['addtime']][$value['name']][$value['nickname']])) {
  376. $data[$value['addtime']][$value['name']][$value['nickname']] = [
  377. 'addtime' => $value['addtime'],
  378. 'name' => $value['name'],
  379. 'nickname' => $value['nickname'],
  380. 'num' => '0',
  381. 'total' => '0',
  382. ];
  383. }
  384. $data[$value['addtime']][$value['name']][$value['nickname']]['num'] = bcadd($data[$value['addtime']][$value['name']][$value['nickname']]['num'], $value['num']);
  385. $data[$value['addtime']][$value['name']][$value['nickname']]['total'] = bcadd($data[$value['addtime']][$value['name']][$value['nickname']]['total'], $value['total']);
  386. }
  387. //去除下标
  388. $da = [];
  389. foreach ($data as $key => $val) {
  390. if (is_numeric($key)) $da[] = $val;
  391. else {
  392. foreach ($val as $val2) {
  393. foreach ($val2 as $val3) {
  394. $da[] = $val3;
  395. }
  396. }
  397. }
  398. }
  399. $da[] = ['addtime' => '汇总', 'itemid' => 0, 'createrid' => 0, 'num' => array_sum(array_column($da, 'num')), 'total' => array_sum(array_column($da, 'total')), 'nickname' => '', 'name' => ''];
  400. return app_show(0, '请求成功', $da);
  401. }
  402. //【一、采购日报表】4.采购员订单金额
  403. public function purcheaseOrderSumByUser()
  404. {
  405. $param = $this->request->only([
  406. 'token',
  407. 'start_date' => '',
  408. 'end_date' => '',
  409. // 'page' => 1,
  410. // 'size' => 15
  411. ], 'post', 'trim');
  412. $val_params = Validate::rule([
  413. 'start_date' => 'date|elt:end_date',
  414. 'end_date' => 'date',
  415. ]);
  416. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  417. $where = [['is_del', '=', 0]];
  418. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  419. //先组织子查询
  420. $rs = Db::name('purchease_order')
  421. ->field('id,DATE_FORMAT(addtime, "%Y-%m-%d") addtime,cgder_id,cgder,total_fee,status,good_num,supplierNo,0 wait_total_fee,0 wait_good_num,0 count_num')
  422. ->where($where)
  423. ->order('addtime desc,cgder_id')
  424. ->select()
  425. ->toArray();
  426. // ->buildSql();
  427. // $count = Db::table($children_query)
  428. // ->alias('a')
  429. // ->group('addtime,cgder_id,cgder')
  430. // ->count();
  431. // $rs = Db::table($children_query)
  432. // ->alias('a')
  433. // ->field('a.addtime,a.cgder_id,a.cgder,SUM(a.total_fee) total_fee,SUM(a.good_num) good_num,COUNT(a.id) count_num,a.status,0 wait_total_fee,0 wait_good_num,supplierNo')
  434. // ->group('a.addtime,a.cgder_id,a.cgder,a.status')
  435. // ->order('a.addtime desc,a.cgder_id')
  436. // ->page($param['page'], $param['size'])
  437. // ->cursor();
  438. $all_supplier = array_column($rs, 'supplierNo');
  439. $has_account = checkHasAccountBySupplierNos($all_supplier);//检查供应商是否开通账号
  440. $supplier = Db::name('supplier')->whereIn('code', array_keys($has_account))->column('name', 'code');
  441. $data = [];
  442. foreach ($rs as $value) {
  443. $key = $value['cgder_id'];
  444. if (isset($has_account[$value['supplierNo']])) $key = $value['supplierNo'];//如果开通了供应商账号,更改下标
  445. if (!isset($data[$value['addtime']][$key])) {
  446. $data[$value['addtime']][$key] = [
  447. 'addtime' => $value['addtime'],
  448. 'cgder' => isset($has_account[$value['supplierNo']]) ? $supplier[$value['supplierNo']] ?? '' : $value['cgder'],
  449. 'name' => isset($has_account[$value['supplierNo']]) ? '供应商' : get_company_name_by_uid($key),
  450. 'count_num' => '0',
  451. 'total_fee' => '0',
  452. 'good_num' => '0',
  453. 'wait_total_fee' => '0',
  454. 'wait_good_num' => '0',
  455. ];
  456. }
  457. if ($value['status'] == 0) {
  458. $data[$value['addtime']][$key]['wait_total_fee'] = bcadd($data[$value['addtime']][$key]['wait_total_fee'], $value['total_fee'], 2);
  459. $data[$value['addtime']][$key]['wait_good_num'] = bcadd($data[$value['addtime']][$key]['wait_good_num'], $value['good_num']);
  460. } else {
  461. $data[$value['addtime']][$key]['total_fee'] = bcadd($data[$value['addtime']][$key]['total_fee'], $value['total_fee'], 2);
  462. $data[$value['addtime']][$key]['good_num'] = bcadd($data[$value['addtime']][$key]['good_num'], $value['good_num']);
  463. }
  464. $data[$value['addtime']][$key]['count_num'] = bcadd($data[$value['addtime']][$key]['count_num'], 1);
  465. }
  466. $da = [];
  467. //去除下标
  468. foreach ($data as $v) {
  469. foreach ($v as $vv) {
  470. $da[] = $vv;
  471. }
  472. }
  473. return app_show(0, '请求成功', $da);
  474. }
  475. //【二、咨询单报表】1.已采反报价信息_列表
  476. public function consultInfoBidsSum()
  477. {
  478. $param = $this->request->only([
  479. 'token',
  480. 'zxNo' => [],
  481. 'start_date' => '',
  482. 'end_date' => '',
  483. 'cbaddtime_start_date' => '',
  484. 'cbaddtime_end_date' => '',
  485. 'supplier' => '',
  486. 'creater' => '',
  487. 'page' => 1,
  488. 'size' => 15,
  489. ], 'post', 'trim');
  490. $val_params = Validate::rule([
  491. 'start_date|竞价开始时间' => 'date|elt:end_date',
  492. 'end_date|竞价开始时间' => 'date|egt:start_date',
  493. 'cbaddtime_start_date|采购回复开始时间' => 'date|elt:cbaddtime_end_date',
  494. 'cbaddtime_end_date|采购回复开始时间' => 'date|egt:cbaddtime_start_date',
  495. ]);
  496. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  497. $where = [['cb.is_del', '=', 0]];
  498. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  499. if ($param['cbaddtime_start_date'] != '' && $param['cbaddtime_end_date'] != '') $where[] = ['cb.addtime', 'between', [$param['cbaddtime_start_date'] . ' 00:00:00', $param['cbaddtime_end_date'] . ' 23:59:59']];
  500. if ($param['supplier'] != '') $where[] = ['cb.supplierNo|s.name', 'like', '%' . $param['supplier'] . '%'];
  501. if ($param['creater'] != '') $where[] = ['cb.creater', 'like', '%' . $param['creater'] . '%'];
  502. if ($param['zxNo'] != '') $where[] = ['cb.infoNo', 'like', '%' . $param['zxNo'] . '%'];
  503. $count = Db::name('consult_bids')
  504. ->alias('cb')
  505. ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo')
  506. ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
  507. ->leftJoin('supplier s', 's.code=cb.supplierNo')
  508. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
  509. ->where($where)
  510. ->count('cb.id');
  511. $data = Db::name('consult_bids')
  512. ->alias('cb')
  513. ->field('cb.id,ci.addtime,cb.bidNo,cb.infoNo zxNo,cb.addtime cbaddtime,cb.good_name,s.name supplier,cb.total_fee,cb.delivery_day,cb.work_day,cb.expire_day,cb.creater,cb.createrid,"" name,ci.num,ci.arrival_time,co.saleid,co.salesman,"" salesman_name,csi.companyName')
  514. ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo')
  515. ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
  516. ->leftJoin('supplier s', 's.code=cb.supplierNo')
  517. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
  518. ->withAttr('name', function ($val, $data) {
  519. return get_company_name_by_uid($data['createrid']);
  520. })
  521. ->withAttr('salesman_name', function ($val, $data) {
  522. return get_company_name_by_uid($data['saleid']);
  523. })
  524. ->where($where)
  525. ->page($param['page'], $param['size'])
  526. ->order('ci.addtime', 'desc')
  527. ->select()
  528. ->toArray();
  529. //汇总
  530. $data[] = [
  531. 'id' => 0,
  532. 'addtime' => '汇总',
  533. 'bidNo' => '',
  534. 'zxNo' => '',
  535. 'cbaddtime' => '',
  536. 'good_name' => '',
  537. 'supplier' => '',
  538. 'total_fee' => array_sum(array_column($data, 'total_fee')),
  539. 'delivery_day' => '',
  540. 'work_day' => '',
  541. 'expire_day' => '',
  542. 'creater' => '',
  543. 'num' => array_sum(array_column($data, 'num')),
  544. 'arrival_time' => '',
  545. 'salesman' => '',
  546. 'companyName' => '',
  547. ];
  548. return app_show(0, '请求成功', ['count' => $count, 'list' => $data]);
  549. }
  550. //【二、咨询单报表】1.已采反报价信息_导出
  551. public function consultInfoBidsSumExport()
  552. {
  553. $param = $this->request->only([
  554. 'token',
  555. 'zxNo' => [],
  556. 'start_date' => '',
  557. 'end_date' => '',
  558. 'cbaddtime_start_date' => '',
  559. 'cbaddtime_end_date' => '',
  560. 'supplier' => '',
  561. 'creater' => '',
  562. 'page' => 1,
  563. 'size' => 15,
  564. ], 'post', 'trim');
  565. $val_params = Validate::rule([
  566. 'start_date|竞价开始时间' => 'date|elt:end_date',
  567. 'end_date|竞价开始时间' => 'date|egt:start_date',
  568. 'cbaddtime_start_date|采购回复开始时间' => 'date|elt:cbaddtime_end_date',
  569. 'cbaddtime_end_date|采购回复开始时间' => 'date|egt:cbaddtime_start_date',
  570. ]);
  571. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  572. $rs = Db::name('consult_bids')
  573. ->alias('cb')
  574. ->where('cb.is_del', 0);
  575. if ($param['start_date'] != '' && $param['end_date'] != '') $rs->whereBetween('ci.addtime', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']);
  576. if ($param['zxNo'] != '') $rs->whereIn('cb.infoNo', $param['zxNo']);
  577. if ($param['cbaddtime_start_date'] != '' && $param['cbaddtime_end_date'] != '') $rs->whereBetween('cb.addtime', [$param['cbaddtime_start_date'] . ' 00:00:00', $param['cbaddtime_end_date'] . ' 23:59:59']);
  578. if ($param['supplier'] != '') $rs->whereLike('cb.supplierNo|s.name', '%' . $param['supplier'] . '%');
  579. if ($param['creater'] != '') $rs->whereLike('cb.creater', '%' . $param['creater'] . '%');
  580. $data = $rs
  581. ->field('ci.addtime as 咨询时间,cb.bidNo as 采购单反馈单号,cb.infoNo as 咨询订单号,cb.addtime as 回复时间,cb.good_name as 产品名称,s.name as 供应商名称,cb.total_fee 成本合计,cb.delivery_day 物流时间,cb.work_day 产品工期,cb.expire_day 信息有效期,cb.creater 采购员,"" 采购员所属部门,ci.num 需求数量,ci.arrival_time 要求到货日期,co.salesman 业务人员,"" 业务人员所属部门,csi.companyName 客户名称,cb.createrid,co.saleid')
  582. ->leftJoin('consult_info ci', 'ci.infoNo=cb.infoNo')
  583. ->leftJoin('consult_order co', 'co.zxNo=cb.zxNo')
  584. ->leftJoin('supplier s', 's.code=cb.supplierNo')
  585. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
  586. ->cursor();
  587. $list = [];
  588. foreach ($data as $value) {
  589. $value['采购员所属部门'] = get_company_name_by_uid($value['createrid']);
  590. $value['业务人员所属部门'] = get_company_name_by_uid($value['saleid']);
  591. unset($value['createrid']);
  592. unset($value['saleid']);
  593. $list[] = $value;
  594. }
  595. if (empty($list)) $list[] = '没有可供导出的数据';
  596. $headerArr = array_keys($list[0]);
  597. excelSave('咨询单报表-已采反报价信息' . date('YmdHis'), $headerArr, $list);
  598. }
  599. //【二、咨询单报表】2.未采反信息_列表
  600. public function consultInfoBidsSumNot()
  601. {
  602. $param = $this->request->only([
  603. 'token',
  604. 'companyName' => '',
  605. 'start_date' => '',
  606. 'end_date' => '',
  607. 'start_updatetime' => '',
  608. 'end_updatetime' => '',
  609. 'page' => 1,
  610. 'size' => 15,
  611. ], 'post', 'trim');
  612. $val_params = Validate::rule([
  613. 'start_date' => 'date|elt:end_date',
  614. 'end_date' => 'date',
  615. 'start_updatetime' => 'date|elt:end_updatetime',
  616. 'end_updatetime' => 'date',
  617. ]);
  618. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  619. $where = [['ci.is_del', '=', 0]];
  620. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  621. if ($param['companyName'] != '') $where[] = ['csi.companyName', 'like', '%' . $param['companyName'] . '%'];
  622. if ($param['start_updatetime'] != '' && $param['end_updatetime'] != '') $where[] = ['ci.updatetime', 'between', [$param['start_updatetime'] . ' 00:00:00', $param['end_updatetime'] . ' 23:59:59']];
  623. $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '取消转单', 7 => '招标已暂停'];
  624. $count = Db::name('consult_info')
  625. ->alias('ci')
  626. ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo')
  627. ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo')
  628. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
  629. ->where($where)
  630. ->whereNull('cb.id')
  631. ->order('ci.arrival_time', 'desc')
  632. ->count('ci.id');
  633. $data = Db::name('consult_info')
  634. ->alias('ci')
  635. ->field('ci.infoNo zxNo,ci.good_name,ci.num,csi.companyName,ci.addtime,co.endtime,ci.updatetime,ci.status')
  636. ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo')
  637. ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo')
  638. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
  639. ->where($where)
  640. ->whereNull('cb.id')//未采反,即咨询单没有对应的反馈单,所以反馈单id应该是null
  641. ->order('ci.arrival_time', 'desc')
  642. ->page($param['page'], $param['size'])
  643. ->withAttr('status', function ($val) use ($status) {
  644. return isset($status[$val]) ? $status[$val] : '';
  645. })
  646. ->select()
  647. ->toArray();
  648. return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
  649. }
  650. //【二、咨询单报表】2.未采反信息_导出
  651. public function consultInfoBidsSumNotExport()
  652. {
  653. $param = $this->request->only([
  654. 'token',
  655. 'companyName' => '',
  656. 'start_date' => '',
  657. 'end_date' => '',
  658. 'start_updatetime' => '',
  659. 'end_updatetime' => '',
  660. ], 'post', 'trim');
  661. $val_params = Validate::rule([
  662. 'start_date' => 'date|elt:end_date',
  663. 'end_date' => 'date',
  664. 'start_updatetime' => 'date|elt:end_updatetime',
  665. 'end_updatetime' => 'date',
  666. ]);
  667. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  668. $where = [['ci.is_del', '=', 0]];
  669. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['ci.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  670. if ($param['companyName'] != '') $where[] = ['csi.companyName', 'like', '%' . $param['companyName'] . '%'];
  671. if ($param['start_updatetime'] != '' && $param['end_updatetime'] != '') $where[] = ['ci.updatetime', 'between', [$param['start_updatetime'] . ' 00:00:00', $param['end_updatetime'] . ' 23:59:59']];
  672. $status = [1 => '招标进行中', 2 => '招标已结束', 3 => '等待议价结果', 4 => '确认商品', 5 => '成功转单', 6 => '取消转单', 7 => '招标已暂停'];
  673. $data = Db::name('consult_info')
  674. ->alias('ci')
  675. ->field('ci.infoNo 竞价订单号,ci.good_name 商品名称,ci.num 需求数量,csi.companyName 客户名称,ci.addtime 创建时间,co.endtime 截止时间,ci.updatetime 结束时间,ci.status 状态')
  676. ->leftJoin('consult_bids cb', 'cb.infoNo=ci.infoNo')
  677. ->leftJoin('consult_order co', 'co.zxNo=ci.zxNo')
  678. ->leftJoin('customer_info csi', 'csi.companyNo=co.khNo')
  679. ->where($where)
  680. ->whereNull('cb.id')
  681. ->order('ci.arrival_time', 'desc')
  682. ->withAttr('状态', function ($val) use ($status) {
  683. return isset($status[$val]) ? $status[$val] : '';
  684. })
  685. ->select()
  686. ->toArray();
  687. if (empty($data)) $data[] = '没有可供导出的数据';
  688. $headerArr = array_keys($data[0]);
  689. excelSave('咨询单报表-未采反信息' . date('YmdHis'), $headerArr, $data);
  690. }
  691. //【三、订单明细报表】列表
  692. public function orderListDetailed()
  693. {
  694. $param = $this->request->only([
  695. 'token',
  696. 'start_date' => '',
  697. 'end_date' => '',
  698. 'status' => '',
  699. 'page' => 1,
  700. 'size' => 15,
  701. ], 'post', 'trim');
  702. $val_params = Validate::rule([
  703. 'start_date' => 'date|elt:end_date',
  704. 'end_date' => 'date',
  705. ]);
  706. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  707. $where = [['po.is_del', '=', 0], ["po.order_type", "<>", 1]];
  708. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['po.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  709. if ($param['status'] != '') $where[] = ['po.status', '=', $param['status']];
  710. $all_status = ['待与供应商确认', '待入库', '部分入库', '入库完成', '已取消订单'];
  711. $all_send_status = [1 => '未发货', 2 => '部分发货', 3 => '已发货'];
  712. $all_is_stock = [0 => '非库存品', 1 => '库存品'];
  713. $count = Db::name('purchease_order')
  714. ->alias('po')
  715. ->leftJoin('business b', 'b.companyNo=po.companyNo')
  716. ->where($where)
  717. ->count('po.id');
  718. $data = Db::name('purchease_order')
  719. ->alias('po')
  720. ->field('po.cgdNo,po.addtime,po.supplierNo,po.supplier_name,po.good_name,gb.is_stock,po.good_num,po.nake_fee,po.total_fee,po.status,po.send_status,po.wsend_num,"" creater,"" creater_name,b.company,po.cgder_id,po.cgder,"" name,"" send_time,on.orderCode,po.order_type,po.bkcode,po.spuCode')
  721. ->leftJoin('business b', 'b.companyNo=po.companyNo')
  722. ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
  723. ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0')
  724. ->where($where)
  725. ->page($param['page'], $param['size'])
  726. ->order('po.addtime', 'desc')
  727. ->cursor();
  728. $list = [];
  729. foreach ($data as $v) {
  730. //单据状态
  731. $v['status'] = isset($all_status[$v['status']]) ? $all_status[$v['status']] : '';
  732. //发货状态
  733. $v['send_status'] = isset($all_send_status[$v['send_status']]) ? $all_send_status[$v['send_status']] : '';
  734. //商品库存性质
  735. $v['is_stock'] = isset($all_is_stock[$v['is_stock']]) ? $all_is_stock[$v['is_stock']] : '';
  736. //创建人//order_type==1备库单
  737. if ($v['order_type'] == 1) $temp = Db::name('purchease')->where(['bk_code' => $v['bkcode'], 'spuCode' => $v['spuCode'], 'is_del' => 0])->field('id,apply_name,apply_id')->find();
  738. else $temp = Db::name('sale')->where(['orderCode' => $v['orderCode'], 'is_del' => 0])->field('id,apply_id,apply_name')->find();
  739. $v['creater'] = isset($temp['apply_name']) ? $temp['apply_name'] : '';
  740. $v['creater_name'] = get_company_name_by_uid($temp['apply_id'] ?? 0);
  741. //创建时间
  742. $v['send_time'] = Db::name('order_out')
  743. ->where(['orderCode' => $v['orderCode']])
  744. ->order('addtime', 'desc')
  745. ->value('addtime');
  746. $v['name'] = get_company_name_by_uid($v['cgder_id'] ?? 0);
  747. $list[] = $v;
  748. }
  749. return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
  750. }
  751. //【三、订单明细报表】导出
  752. public function orderListDetailedExport()
  753. {
  754. $param = $this->request->only([
  755. 'token',
  756. 'start_date' => '',
  757. 'end_date' => '',
  758. 'status' => '',
  759. ], 'post', 'trim');
  760. $val_params = Validate::rule([
  761. 'start_date' => 'date|elt:end_date',
  762. 'end_date' => 'date',
  763. ]);
  764. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  765. $where = [['po.is_del', '=', 0], ["po.order_type", "<>", 1]];
  766. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['po.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  767. if ($param['status'] != '') $where[] = ['po.status', '=', $param['status']];
  768. $all_status = ['待与供应商确认', '待入库', '部分入库', '入库完成', '已取消订单'];
  769. $all_send_status = [1 => '未发货', 2 => '部分发货', 3 => '已发货'];
  770. $all_is_stock = [0 => '非库存品', 1 => '库存品'];
  771. $data = Db::name('purchease_order')
  772. ->alias('po')
  773. ->field('po.cgdNo 采购单编号,po.addtime 创建时间,po.supplierNo 供应商编号,po.supplier_name 供应商名称,po.good_name 商品名称,gb.is_stock 商品库存性质,po.good_num 购买数量,po.nake_fee 裸价,po.total_fee 成本合计,po.status 单据状态,po.send_status 发货状态,po.wsend_num 未发货数量,"" 创建人,"" 创建人所属部门,b.company 客户名称,po.cgder 采购员,"" 采购员所属部门,"" 发货时间,on.orderCode,po.order_type,po.bkcode,po.spuCode,po.cgder_id')
  774. ->leftJoin('business b', 'b.companyNo=po.companyNo')
  775. ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
  776. ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0')
  777. ->where($where)
  778. ->order('po.addtime', 'desc')
  779. ->cursor();
  780. $list = [];
  781. $tmp = [];
  782. foreach ($data as $v) {
  783. //单据状态
  784. $v['单据状态'] = isset($all_status[$v['单据状态']]) ? $all_status[$v['单据状态']] : '';
  785. //发货状态
  786. $v['发货状态'] = isset($all_send_status[$v['发货状态']]) ? $all_send_status[$v['发货状态']] : '';
  787. //商品库存性质
  788. $v['商品库存性质'] = isset($all_is_stock[$v['商品库存性质']]) ? $all_is_stock[$v['商品库存性质']] : '';
  789. //创建人//order_type==1备库单
  790. if ($v['order_type'] == 1) $temp = Db::name('purchease')->where(['bk_code' => $v['bkcode'], 'spuCode' => $v['spuCode'], 'is_del' => 0])->field('id,apply_name,apply_id')->find();
  791. else $temp = Db::name('sale')->where(['orderCode' => $v['orderCode'], 'is_del' => 0])->field('id,apply_id,apply_name')->find();
  792. $v['创建人'] = isset($temp['apply_name']) ? $temp['apply_name'] : '';
  793. if (!isset($tmp[$temp['apply_id'] ?? 0])) {
  794. $tmp[$temp['apply_id'] ?? 0] = get_company_name_by_uid($temp['apply_id'] ?? 0);
  795. }
  796. $v['创建人所属部门'] = $tmp[$temp['apply_id'] ?? 0];//get_company_name_by_uid($temp['apply_id'] ?? 0);
  797. //创建时间
  798. $v['发货时间'] = Db::name('order_out')
  799. ->where(['is_del' => 0, 'orderCode' => $v['orderCode']])
  800. ->order('addtime', 'desc')
  801. ->value('addtime');
  802. if (!isset($tmp[$v['cgder_id'] ?? 0])) {
  803. $tmp[$v['cgder_id'] ?? 0] = get_company_name_by_uid($v['cgder_id'] ?? 0);
  804. }
  805. $v['采购员所属部门'] = $tmp[$v['cgder_id'] ?? 0];//get_company_name_by_uid($v['cgder_id'] ?? 0);
  806. unset($v['orderCode']);
  807. unset($v['order_type']);
  808. unset($v['bkcode']);
  809. unset($v['spuCode']);
  810. unset($v['cgder_id']);
  811. $list[] = $v;
  812. }
  813. if (empty($list)) $list[] = '没有可供导出的数据';
  814. $headerArr = array_keys($list[0]);
  815. excelSave('订单明细报表' . date('YmdHis'), $headerArr, $list);
  816. }
  817. //【四、售后明细报表】列表
  818. public function orderReturnList()
  819. {
  820. $param = $this->request->only([
  821. 'token',
  822. 'start_date' => '',
  823. 'end_date' => '',
  824. 'page' => 1,
  825. 'size' => 15,
  826. ], 'post', 'trim');
  827. $val_params = Validate::rule([
  828. 'start_date' => 'date|elt:end_date',
  829. 'end_date' => 'date',
  830. ]);
  831. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  832. $where = [['or.is_del', '=', 0]];
  833. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['or.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  834. $all_status = [1 => '待业务审核', 2 => '待采购审核', 3 => '待设置仓库', 4 => '待客户退货', 5 => '售后已完成', 6 => '业务已驳回', 7 => '采购已驳回', 8 => '申请已取消'];
  835. //总数
  836. $count = Db::name('order_return')
  837. ->alias('or')
  838. ->leftJoin('order_num on', 'on.orderCode=or.orderCode')
  839. ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo')
  840. ->leftJoin('order_out oo', 'oo.outCode=or.outCode AND oo.status=3 AND oo.is_del=0')
  841. ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
  842. ->where($where)
  843. ->count('or.id');
  844. $list = Db::name('order_return')
  845. ->alias('or')
  846. ->field('or.id,or.returnCode,or.addtime,on.cgdNo,po.supplierNo,po.supplier_name,or.good_name,or.total_num, oo.updatetime receipttime ,or.error_num,or.error_remark,ri.result error_reason,or.status,po.cgder,ci.name')
  847. ->leftJoin('order_num on', 'on.orderCode=or.orderCode')
  848. ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo')
  849. ->leftJoin('order_out oo', 'oo.outCode=or.outCode AND oo.status=3 AND oo.is_del=0')
  850. ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
  851. ->leftJoin('depart_user u', 'u.uid=po.cgder_id AND u.is_del=0')
  852. ->leftJoin('company_item ci', 'ci.id=u.itemid')
  853. ->where($where)
  854. ->withAttr('status', function ($val) use ($all_status) {
  855. return isset($all_status[$val]) ? $all_status[$val] : $val;
  856. })
  857. ->page($param['page'], $param['size'])
  858. ->order('or.addtime desc')
  859. ->select()
  860. ->toArray();
  861. return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
  862. }
  863. //【四、售后明细报表】导出
  864. public function orderReturnListExport()
  865. {
  866. $param = $this->request->only([
  867. 'token',
  868. 'start_date' => '',
  869. 'end_date' => '',
  870. ], 'post', 'trim');
  871. $val_params = Validate::rule([
  872. 'start_date' => 'date|elt:end_date',
  873. 'end_date' => 'date',
  874. ]);
  875. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  876. $where = [['or.is_del', '=', 0]];
  877. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['or.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  878. $all_status = [2 => '业务主管审核', 3 => '采购主管审核', 6 => '业务驳回', 7 => '采购驳回', 8 => '取消'];
  879. $list = Db::name('order_return')
  880. ->alias('or')
  881. ->field('or.returnCode 售后单编号,or.addtime 创建时间,on.cgdNo 采购单编号,po.supplier_name 供应商名称,or.good_name 产品名称,or.total_num 购买数量, oo.updatetime 签收日期,or.error_num 售后数量,or.error_remark 问题描述,ri.result 异常原因,or.status 售后状态,po.cgder 采购员,ci.name 采购员所属部门')
  882. ->leftJoin('order_num on', 'on.orderCode=or.orderCode')
  883. ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo')
  884. ->leftJoin('order_out oo', 'oo.outCode=or.outCode AND oo.status=3 AND oo.is_del=0')
  885. ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
  886. ->leftJoin('depart_user u', 'u.uid=po.cgder_id AND u.is_del=0')
  887. ->leftJoin('company_item ci', 'ci.id=u.itemid')
  888. ->where($where)
  889. ->withAttr('售后状态', function ($val) use ($all_status) {
  890. return isset($all_status[$val]) ? $all_status[$val] : $val;
  891. })
  892. ->order('or.addtime desc')
  893. ->select()
  894. ->toArray();
  895. if (empty($list)) $list[] = '没有可供导出的数据';
  896. $headerArr = array_keys($list[0]);
  897. excelSave('售后明细报表' . date('YmdHis'), $headerArr, $list);
  898. }
  899. //【五、供应商报表】列表
  900. public function supplierList()
  901. {
  902. $param = $this->request->only([
  903. 'token',
  904. 'start_date' => '',
  905. 'end_date' => '',
  906. 'update_start_date' => '',
  907. 'update_end_date' => '',
  908. 'page' => 1,
  909. 'size' => 15,
  910. ], 'post', 'trim');
  911. $val_params = Validate::rule([
  912. 'start_date' => 'date|elt:end_date',
  913. 'end_date' => 'date',
  914. 'update_start_date' => 'date|elt:update_end_date',
  915. 'update_end_date' => 'date',
  916. ]);
  917. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  918. $where = [];
  919. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  920. if ($param['update_start_date'] != '' && $param['update_end_date'] != '') $where[] = ['s.updatetime', 'between', [$param['update_start_date'] . ' 00:00:00', $param['update_end_date'] . ' 23:59:59']];
  921. $all_source = [0 => '客户提供', 1 => '供应商', 2 => '公司开发'];
  922. $all_pay_type = [0 => '现结', 1 => '月清', 2 => '双月清'];
  923. $all_delivery_way = [0 => '供应商发货', 1 => '公司自提'];
  924. //总数
  925. $count = Db::name('supplier')
  926. ->alias('s')
  927. ->where($where)
  928. ->count('s.id');
  929. $list = Db::name('supplier')
  930. ->alias('s')
  931. ->field('s.id,s.addtime,s.name,s.creater,s.createrid,"" company_name,s.nature,s.source,s.pay_type,s.delivery_way,s.updatetime')
  932. ->where($where)
  933. ->page($param['page'], $param['size'])
  934. ->withAttr('source', function ($val) use ($all_source) {
  935. return is_numeric($val) ? (isset($all_source[$val]) ? $all_source[$val] : '') : $val;
  936. })
  937. ->withAttr('pay_type', function ($val) use ($all_pay_type) {
  938. return is_numeric($val) ? (isset($all_pay_type[$val]) ? $all_pay_type[$val] : '') : $val;
  939. })
  940. ->withAttr('delivery_way', function ($val) use ($all_delivery_way) {
  941. return is_numeric($val) ? (isset($all_delivery_way[$val]) ? $all_delivery_way[$val] : '') : $val;
  942. })
  943. ->withAttr('company_name', function ($val, $data) {
  944. return get_company_name_by_uid($data['createrid']);
  945. })
  946. ->order('s.addtime desc')
  947. ->select()
  948. ->toArray();
  949. return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
  950. }
  951. //【五、供应商报表】导出
  952. public function supplierListExport()
  953. {
  954. $param = $this->request->only([
  955. 'token',
  956. 'start_date' => '',
  957. 'end_date' => '',
  958. 'update_start_date' => '',
  959. 'update_end_date' => '',
  960. ], 'post', 'trim');
  961. $val_params = Validate::rule([
  962. 'start_date' => 'date|elt:end_date',
  963. 'end_date' => 'date',
  964. 'update_start_date' => 'date|elt:update_end_date',
  965. 'update_end_date' => 'date',
  966. ]);
  967. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  968. $where = [];
  969. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  970. if ($param['update_start_date'] != '' && $param['update_end_date'] != '') $where[] = ['s.updatetime', 'between', [$param['update_start_date'] . ' 00:00:00', $param['update_end_date'] . ' 23:59:59']];
  971. $all_source = [0 => '客户提供', 1 => '供应商', 2 => '公司开发'];
  972. $all_pay_type = [0 => '现结', 1 => '月清', 2 => '双月清'];
  973. $all_delivery_way = [0 => '供应商发货', 1 => '公司自提'];
  974. $list = Db::name('supplier')
  975. ->alias('s')
  976. ->field('s.addtime 录入供应商时间,s.name 供应商名称,s.creater 采购维护人,"" 采购维护人所属部门,s.nature 供应商性质,s.source 供应商来源,s.pay_type 付款方式,s.delivery_way 发货方式,s.updatetime 修改供应商时间,s.createrid')
  977. ->where($where)
  978. ->order('s.addtime desc')
  979. ->cursor();
  980. $data = [];
  981. foreach ($list as $value) {
  982. $value['供应商来源'] = is_numeric($value['供应商来源']) ? (isset($all_source[$value['供应商来源']]) ? $all_source[$value['供应商来源']] : '') : $value['供应商来源'];
  983. $value['付款方式'] = is_numeric($value['付款方式']) ? (isset($all_pay_type[$value['付款方式']]) ? $all_pay_type[$value['付款方式']] : '') : $value['付款方式'];
  984. $value['发货方式'] = is_numeric($value['发货方式']) ? (isset($all_delivery_way[$value['发货方式']]) ? $all_delivery_way[$value['发货方式']] : '') : $value['发货方式'];
  985. $value['采购维护人所属部门'] = get_company_name_by_uid($value['createrid']);
  986. unset($value['createrid']);
  987. $data[] = $value;
  988. }
  989. if (empty($data)) $data[] = '没有可供导出的数据';
  990. $headerArr = array_keys($data[0]);
  991. excelSave('供应商报表' . date('YmdHis'), $headerArr, $data);
  992. }
  993. //【六、退货流水报表】列表
  994. public function SaleReturnList()
  995. {
  996. $param = $this->request->only([
  997. 'token',
  998. 'start_date' => '',
  999. 'end_date' => '',
  1000. 'page' => 1,
  1001. 'size' => 15,
  1002. ], 'post', 'trim');
  1003. $val_params = Validate::rule([
  1004. 'start_date' => 'date|elt:end_date',
  1005. 'end_date' => 'date'
  1006. ]);
  1007. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1008. $where = [['s.is_del', '=', 0]];
  1009. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1010. $count = Db::name('sale_return')
  1011. ->alias('s')
  1012. ->where($where)
  1013. ->leftJoin('sale ss', 'ss.orderCode=s.orderCode AND ss.is_del=0')
  1014. ->leftJoin('order_num on', 'on.orderCode=s.orderCode')
  1015. ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo')
  1016. ->leftJoin('good_basic gb', 'gb.spuCode=s.good_code AND gb.is_del=0')
  1017. ->leftJoin('result_info ri', 'ri.result_code=s.error_code AND ri.is_del=0')
  1018. ->leftJoin('supplier sp', 'sp.code=gb.supplierNo')
  1019. ->count('s.id');
  1020. $list = Db::name('sale_return')
  1021. ->alias('s')
  1022. ->field('s.id,s.returnCode,s.addtime,po.cgdNo,sp.name supplier_name,s.good_name,gb.is_stock,ss.good_num,po.cgder_id,po.cgder,"" name,s.num,on.send_num,ri.result,s.is_th')
  1023. ->where($where)
  1024. ->leftJoin('sale ss', 'ss.orderCode=s.orderCode AND ss.is_del=0')
  1025. ->leftJoin('order_num on', 'on.orderCode=s.orderCode')
  1026. ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo')
  1027. ->leftJoin('good_basic gb', 'gb.spuCode=s.good_code AND gb.is_del=0')
  1028. ->leftJoin('result_info ri', 'ri.result_code=s.error_code AND ri.is_del=0')
  1029. ->leftJoin('supplier sp', 'sp.code=gb.supplierNo')
  1030. ->page($param['page'], $param['size'])
  1031. ->order('s.addtime desc')
  1032. ->cursor();
  1033. $data = [];
  1034. foreach ($list as $value) {
  1035. $value['name'] = get_company_name_by_uid($value['cgder_id'] ?? 0);
  1036. $data[] = $value;
  1037. }
  1038. return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
  1039. }
  1040. //【六、退货流水报表】导出
  1041. public function SaleReturnExport()
  1042. {
  1043. $param = $this->request->only([
  1044. 'token',
  1045. 'start_date' => '',
  1046. 'end_date' => ''
  1047. ], 'post', 'trim');
  1048. $val_params = Validate::rule([
  1049. 'start_date' => 'date|elt:end_date',
  1050. 'end_date' => 'date'
  1051. ]);
  1052. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1053. $where = [['s.is_del', '=', 0]];
  1054. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['s.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1055. $all_is_th = [0 => '不可以', 1 => '可以'];
  1056. $all_is_stock = [0 => '非库存品', 1 => '库存品'];
  1057. $list = Db::name('sale_return')
  1058. ->alias('s')
  1059. ->field('s.returnCode 退货单号,s.addtime 退货时间,po.cgdNo 采购单编号,po.supplier_name 供应商名称,po.good_name 产品名称,gb.is_stock 商品库存性质,po.good_num 购买数量,po.cgder 采购员,"" 采购员所属部门,s.num 退货数量,on.send_num 已发货数量,ri.result 退货原因,s.is_th 供应商是否可以退货,po.cgder_id')
  1060. ->where($where)
  1061. ->leftJoin('order_num on', 'on.orderCode=s.orderCode')
  1062. ->leftJoin('purchease_order po', 'po.cgdNo=on.cgdNo')
  1063. ->leftJoin('good_basic gb', 'gb.spuCode=po.spuCode AND gb.is_del=0')
  1064. ->leftJoin('result_info ri', 'ri.result_code=s.error_code AND ri.is_del=0')
  1065. ->order('s.addtime desc')
  1066. ->cursor();
  1067. $data = [];
  1068. foreach ($list as $value) {
  1069. $value['供应商是否可以退货'] = isset($all_is_th[$value['供应商是否可以退货']]) ? $all_is_th[$value['供应商是否可以退货']] : '';
  1070. $value['商品库存性质'] = isset($all_is_stock[$value['商品库存性质']]) ? $all_is_stock[$value['商品库存性质']] : '';
  1071. $value['采购员所属部门'] = get_company_name_by_uid($value['cgder_id'] ?? 0);
  1072. unset($value['cgder_id']);
  1073. $data[] = $value;
  1074. }
  1075. if (empty($data)) $data[] = '没有可供导出的数据';
  1076. $headerArr = array_keys($data[0]);
  1077. excelSave('退货流水报表' . date('YmdHis'), $headerArr, $data);
  1078. }
  1079. //【七、商品报表】1.商品上线报表_列表
  1080. public function GoodOnlineList()
  1081. {
  1082. $param = $this->request->only([
  1083. 'token',
  1084. 'creater' => '',
  1085. 'supplier_name' => '',
  1086. 'start_date' => '',
  1087. 'end_date' => '',
  1088. 'page' => 1,
  1089. 'size' => 15,
  1090. ], 'post', 'trim');
  1091. $val_params = Validate::rule([
  1092. 'start_date' => 'date|elt:end_date',
  1093. 'end_date' => 'date'
  1094. ]);
  1095. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1096. $where = [['s.is_del', '=', 0], ['gp.exam_status', '=', 6]]; //exam_status==6 上线成功
  1097. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.online_time', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];//当上面状态确定为exam_status==6时,上线时间也可以取 updatetime
  1098. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1099. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1100. $count = Db::name('good_platform')
  1101. ->alias('gp')
  1102. ->where($where)
  1103. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1104. ->leftJoin('brand b', 'b.id=gb.brand_id')
  1105. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1106. ->count('gp.id');
  1107. $list = Db::name('good_platform')
  1108. ->alias('gp')
  1109. ->field('gb.createrid,gb.creater,"" company_name,gp.skuCode,gp.spuCode,gb.good_name,b.brand_name,"" good_model,s.name,gb.tax,gb.nake_price,gp.online_time')
  1110. ->where($where)
  1111. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1112. ->leftJoin('brand b', 'b.id=gb.brand_id')
  1113. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1114. ->order('gp.updatetime desc')
  1115. ->page($param['page'], $param['size'])
  1116. ->cursor();
  1117. $data = [];
  1118. foreach ($list as $value) {
  1119. $value['company_name'] = get_company_name_by_uid($value['createrid']);
  1120. $value['good_model'] = Db::name('good_spec')
  1121. ->alias('gp')
  1122. ->field('')
  1123. ->leftJoin('specs s', 's.id=gp.spec_id')
  1124. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  1125. ->where([
  1126. 'gp.spuCode' => $value['spuCode'],
  1127. 'gp.is_del' => 0,
  1128. 's.spec_name' => '型号',
  1129. ])
  1130. ->value('sv.spec_value', '');
  1131. $data[] = $value;
  1132. }
  1133. return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
  1134. }
  1135. //【七、商品报表】1.商品上线报表_导出
  1136. public function GoodOnlineExport()
  1137. {
  1138. $param = $this->request->only([
  1139. 'token',
  1140. 'creater' => '',
  1141. 'supplier_name' => '',
  1142. 'start_date' => '',
  1143. 'end_date' => ''
  1144. ], 'post', 'trim');
  1145. $val_params = Validate::rule([
  1146. 'start_date' => 'date|elt:end_date',
  1147. 'end_date' => 'date'
  1148. ]);
  1149. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1150. $where = [['s.is_del', '=', 0], ['gp.exam_status', '=', 6]]; //exam_status==6 上线成功
  1151. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.online_time', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1152. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1153. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1154. $list = Db::name('good_platform')
  1155. ->alias('gp')
  1156. ->field('gb.creater 采购维护人,"" 采购维护人所属部门,gp.skuCode 商品上线编号,gp.spuCode 商品成本编号,gb.good_name 商品名称,b.brand_name 品牌名称,"" 商品型号,s.name 供应商名称,gb.tax 税点,gb.nake_price 成本价合计,gp.online_time 上线时间,gb.createrid')
  1157. ->where($where)
  1158. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1159. ->leftJoin('brand b', 'b.id=gb.brand_id')
  1160. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1161. ->order('gp.updatetime desc')
  1162. ->cursor();
  1163. $data = [];
  1164. foreach ($list as $value) {
  1165. $value['采购维护人所属部门'] = get_company_name_by_uid($value['createrid']);;
  1166. $value['商品型号'] = Db::name('good_spec')
  1167. ->alias('gp')
  1168. ->field('')
  1169. ->leftJoin('specs s', 's.id=gp.spec_id')
  1170. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  1171. ->where([
  1172. 'gp.spuCode' => $value['商品成本编号'],
  1173. 'gp.is_del' => 0,
  1174. 's.spec_name' => '型号',
  1175. ])
  1176. ->value('sv.spec_value', '');
  1177. unset($value['createrid']);
  1178. $data[] = $value;
  1179. }
  1180. if (empty($data)) $data[] = '没有可供导出的数据';
  1181. $headerArr = array_keys($data[0]);
  1182. excelSave('商品上线报表' . date('YmdHis'), $headerArr, $data);
  1183. }
  1184. //【七、商品报表】2.商品下线报表_列表
  1185. public function GoodOfflineList()
  1186. {
  1187. $param = $this->request->only([
  1188. 'token',
  1189. 'creater' => '',
  1190. 'supplier_name' => '',
  1191. 'start_date' => '',
  1192. 'end_date' => '',
  1193. 'page' => 1,
  1194. 'size' => 15,
  1195. ], 'post', 'trim');
  1196. $val_params = Validate::rule([
  1197. 'start_date' => 'date|elt:end_date',
  1198. 'end_date' => 'date'
  1199. ]);
  1200. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1201. $where = [['s.is_del', '=', 0], ['gp.exam_status', '=', 8]]; //exam_status==8 下线成功
  1202. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.updatetime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1203. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1204. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1205. $count = Db::name('good_platform')
  1206. ->alias('gp')
  1207. ->where($where)
  1208. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1209. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1210. ->count('gp.id');
  1211. $list = Db::name('good_platform')
  1212. ->alias('gp')
  1213. ->field('gp.updatetime,gb.createrid,gb.creater,"" company_name,gb.creater,gp.skuCode,gp.spuCode,gb.good_name,s.name')
  1214. ->where($where)
  1215. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1216. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1217. ->withAttr('company_name', function ($val, $data) {
  1218. return get_company_name_by_uid($data['createrid']);
  1219. })
  1220. ->page($param['page'], $param['size'])
  1221. ->select()
  1222. ->toArray();
  1223. return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
  1224. }
  1225. //【七、商品报表】2.商品下线报表_导出
  1226. public function GoodOfflineExport()
  1227. {
  1228. $param = $this->request->only([
  1229. 'token',
  1230. 'creater' => '',
  1231. 'supplier_name' => '',
  1232. 'start_date' => '',
  1233. 'end_date' => ''
  1234. ], 'post', 'trim');
  1235. $val_params = Validate::rule([
  1236. 'start_date' => 'date|elt:end_date',
  1237. 'end_date' => 'date'
  1238. ]);
  1239. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1240. $where = [['s.is_del', '=', 0], ['gp.exam_status', '=', 8]]; //exam_status==8 下线成功
  1241. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.updatetime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1242. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1243. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1244. $list = Db::name('good_platform')
  1245. ->alias('gp')
  1246. ->field('gp.updatetime 商品下线时间,gb.creater 采购维护人,"" 采购维护人所属部门,gp.skuCode 商品上线编号,gp.spuCode 商品成本编号,gb.good_name 商品名称,s.name 供应商名称,gb.createrid')
  1247. ->where($where)
  1248. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1249. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1250. ->cursor();
  1251. $data = [];
  1252. foreach ($list as $value) {
  1253. $value['采购维护人所属部门'] = get_company_name_by_uid($value['createrid']);
  1254. unset($value['createrid']);
  1255. $data[] = $value;
  1256. }
  1257. if (empty($data)) $data[] = '没有可供导出的数据';
  1258. $headerArr = array_keys($data[0]);
  1259. excelSave('商品下线报表' . date('YmdHis'), $headerArr, $data);
  1260. }
  1261. //【七、商品报表】3.商品修改报表_列表
  1262. public function ChangeLogList()
  1263. {
  1264. $param = $this->request->only([
  1265. 'token',
  1266. 'creater' => '',
  1267. 'supplier_name' => '',
  1268. 'start_date' => '',
  1269. 'end_date' => '',
  1270. 'page' => 1,
  1271. 'size' => 15,
  1272. ], 'post', 'trim');
  1273. $val_params = Validate::rule([
  1274. 'start_date' => 'date|elt:end_date',
  1275. 'end_date' => 'date'
  1276. ]);
  1277. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1278. $where = [['cl.type', '=', 3]]; //type==3 商品成本变化记录
  1279. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cl.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1280. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1281. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1282. $count = Db::name('change_log')
  1283. ->alias('cl')
  1284. ->leftJoin('good_basic gb', 'gb.spuCode=cl.code AND gb.is_del=0')
  1285. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1286. ->where($where)
  1287. ->count('cl.id');
  1288. $data = Db::name('change_log')
  1289. ->alias('cl')
  1290. ->field('cl.addtime,gb.createrid,gb.creater,"" company_name,cl.code,gb.good_name,s.name,cl.before_info,cl.after_info')
  1291. ->leftJoin('good_basic gb', 'gb.spuCode=cl.code AND gb.is_del=0')
  1292. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1293. ->where($where)
  1294. ->order('cl.addtime', 'desc')
  1295. ->page($param['page'], $param['size'])
  1296. ->cursor();
  1297. $list = [];
  1298. foreach ($data as $value) {
  1299. $before_info = json_decode($value['before_info'], true);
  1300. $after_info = json_decode($value['after_info'], true);
  1301. if (isset($after_info['field_change'])) unset($after_info['field_change']);
  1302. $value['before_info'] = [];
  1303. foreach ($after_info as $kk => $vv) {
  1304. //特殊字段处理
  1305. switch ($kk) {
  1306. //品牌
  1307. case 'brand_id':
  1308. $all_brand = Db::name('brand')
  1309. ->whereIn('id', [$before_info[$kk], $vv])
  1310. ->where('is_del', 0)
  1311. ->column('brand_name', 'id');
  1312. $value['before_info'][$kk] = isset($all_brand[$before_info[$kk]]) ? $all_brand[$before_info[$kk]] : '';
  1313. $after_info[$kk] = isset($all_brand[$vv]) ? $all_brand[$vv] : '';
  1314. break;
  1315. //分类
  1316. case 'cat_id':
  1317. $value['before_info'][$kk] = implode('/', array_column(made($before_info[$kk]), 'name'));
  1318. $after_info[$kk] = implode('/', array_column(made($vv), 'name'));
  1319. break;
  1320. //发货地
  1321. case 'delivery_place':
  1322. $delivery_place = explode(',', $before_info[$kk]);
  1323. $value['before_info'][$kk] = empty($delivery_place) ? $before_info[$kk] : GetAddr(json_encode(['provice_code' => $delivery_place[0] ?? '', 'city_code' => $delivery_place[1] ?? '', 'area_code' => $delivery_place[2] ?? '']));
  1324. $delivery_place_2 = explode(',', $vv);
  1325. $after_info[$kk] = empty($delivery_place_2) ? $vv : GetAddr(json_encode(['provice_code' => $delivery_place_2[0] ?? '', 'city_code' => $delivery_place_2[1] ?? '', 'area_code' => $delivery_place_2[2] ?? '']));
  1326. break;
  1327. //产地
  1328. case 'origin_place':
  1329. $origin_place = explode(',', $before_info[$kk]);
  1330. $value['before_info'][$kk] = empty($origin_place) ? $before_info[$kk] : GetAddr(json_encode(['provice_code' => $origin_place[0] ?? '', 'city_code' => $origin_place[1] ?? '', 'area_code' => $origin_place[2] ?? '']));
  1331. $origin_place_2 = explode(',', $vv);
  1332. $after_info[$kk] = empty($vv) ? $vv : GetAddr(json_encode(['provice_code' => $origin_place_2[0] ?? '', 'city_code' => $origin_place_2[1] ?? '', 'area_code' => $origin_place_2[2] ?? '']));
  1333. break;
  1334. //商品单位
  1335. case 'good_unit':
  1336. $all_unit = Db::name('unit')
  1337. ->whereIn('id', [$before_info[$kk], $vv])
  1338. ->where(['is_del' => 0])
  1339. ->column('unit', 'id');
  1340. $value['before_info'][$kk] = isset($all_unit[$before_info[$kk]]) ? $all_unit[$before_info[$kk]] : '';
  1341. $after_info[$kk] = isset($all_unit[$vv]) ? $all_unit[$vv] : '';
  1342. break;
  1343. //业务企业
  1344. case 'companyNo':
  1345. $all_business = Db::name('business')
  1346. ->whereIn('companyNo', [$before_info[$kk], $vv])
  1347. ->where(['is_del' => 0])
  1348. ->column('company', 'companyNo');
  1349. $value['before_info'][$kk] = isset($all_business[$before_info[$kk]]) ? $all_business[$before_info[$kk]] : '';
  1350. $after_info[$kk] = isset($all_business[$vv]) ? $all_business[$vv] : '';
  1351. break;
  1352. //供应商
  1353. case 'supplierNo':
  1354. $all_supplier = Db::name('supplier')
  1355. ->whereIn('code', [$before_info[$kk], $vv])
  1356. ->where(['is_del' => 0])
  1357. ->column('name', 'code');
  1358. $value['before_info'][$kk] = isset($all_supplier[$before_info[$kk]]) ? $all_supplier[$before_info[$kk]] : '';
  1359. $after_info[$kk] = isset($all_supplier[$vv]) ? $all_supplier[$vv] : '';
  1360. break;
  1361. //供货区域
  1362. case 'supply_area':
  1363. if ($before_info[$kk] == 1) $value['before_info'][$kk] = '全国';
  1364. elseif ($before_info[$kk] == 2) $value['before_info'][$kk] = '全国除偏远';
  1365. else $value['before_info'][$kk] = '';
  1366. if ($vv == 1) $after_info[$kk] = '全国';
  1367. elseif ($vv == 2) $after_info[$kk] = '全国除偏远';
  1368. else $after_info[$kk] = '';
  1369. break;
  1370. //贵金属种类
  1371. case 'noble_metal':
  1372. if ($before_info[$kk] == 1) $value['before_info'][$kk] = '18K';
  1373. elseif ($before_info[$kk] == 2) $value['before_info'][$kk] = '24K';
  1374. elseif ($before_info[$kk] == 3) $value['before_info'][$kk] = '白银';
  1375. else $value['before_info'][$kk] = '';
  1376. if ($vv == 1) $after_info[$kk] = '18K';
  1377. elseif ($vv == 2) $after_info[$kk] = '24K';
  1378. elseif ($vv == 3) $after_info[$kk] = '白银';
  1379. else $after_info[$kk] = '';
  1380. break;
  1381. //专属类型
  1382. case 'is_exclusive':
  1383. $value['before_info'][$kk] = implode('/', array_column(mai($before_info[$kk]), 'rname'));
  1384. $after_info[$kk] = implode('/', array_column(mai($vv), 'rname'));
  1385. break;
  1386. default:
  1387. $value['before_info'][$kk] = $before_info[$kk];
  1388. break;
  1389. }
  1390. }
  1391. $value['after_info'] = $after_info;
  1392. $value['company_name'] = get_company_name_by_uid($value['createrid']);
  1393. $list[] = $value;
  1394. }
  1395. return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
  1396. }
  1397. //【七、商品报表】3.商品修改报表_导出
  1398. public function ChangeLogExport()
  1399. {
  1400. $param = $this->request->only([
  1401. 'token',
  1402. 'creater' => '',
  1403. 'supplier_name' => '',
  1404. 'start_date' => '',
  1405. 'end_date' => ''
  1406. ], 'post', 'trim');
  1407. $val_params = Validate::rule([
  1408. 'start_date' => 'date|elt:end_date',
  1409. 'end_date' => 'date'
  1410. ]);
  1411. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1412. $where = [['cl.type', '=', 3]]; //type==3 商品成本变化记录
  1413. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cl.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1414. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1415. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1416. $data = Db::name('change_log')
  1417. ->alias('cl')
  1418. ->field('cl.addtime 商品操作时间,gb.creater 采购维护人,"" 采购维护人所在部门,cl.code 商品成本编号,gb.good_name 商品名称,s.name 供应商名称,cl.before_info 修改前的内容,cl.after_info 修改后的内容,gb.createrid')
  1419. ->leftJoin('good_basic gb', 'gb.spuCode=cl.code AND gb.is_del=0')
  1420. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1421. ->where($where)
  1422. ->cursor();
  1423. $list = [];
  1424. foreach ($data as $value) {
  1425. $before_info = json_decode($value['修改前的内容'], true);
  1426. $after_info = json_decode($value['修改后的内容'], true);
  1427. if (isset($after_info['field_change'])) {
  1428. $field_change = json_decode($after_info['field_change'], true);
  1429. $before_new = $after_new = [];
  1430. foreach ($field_change as $v) {
  1431. //特殊字段处理
  1432. switch ($v) {
  1433. //品牌
  1434. case 'brand_id':
  1435. $all_brand = Db::name('brand')
  1436. ->whereIn('id', [$before_info[$v] ?? 0, $after_info[$v] ?? 0])
  1437. ->where('is_del', 0)
  1438. ->column('brand_name', 'id');
  1439. if (isset($before_info[$v])) $before_info[$v] = isset($all_brand[$before_info[$v]]) ? $all_brand[$before_info[$v]] : '';
  1440. if (isset($after_info[$v])) $after_info[$v] = isset($all_brand[$after_info[$v]]) ? $all_brand[$after_info[$v]] : '';
  1441. break;
  1442. //分类
  1443. case 'cat_id':
  1444. if (isset($before_info[$v])) $before_info[$v] = implode('/', array_column(made($before_info[$v]), 'name'));
  1445. if (isset($after_info[$v])) $after_info[$v] = implode('/', array_column(made($after_info[$v]), 'name'));
  1446. break;
  1447. //发货地
  1448. case 'delivery_place':
  1449. $delivery_place = explode(',', $before_info[$v]);
  1450. $before_info[$v] = empty($delivery_place) ? $before_info[$v] : GetAddr(json_encode(['provice_code' => $delivery_place[0] ?? '', 'city_code' => $delivery_place[1] ?? '', 'area_code' => $delivery_place[2] ?? '']));
  1451. $delivery_place_2 = explode(',', $after_info[$v]);
  1452. $after_info[$v] = empty($delivery_place_2) ? $after_info[$v] : GetAddr(json_encode(['provice_code' => $delivery_place_2[0] ?? '', 'city_code' => $delivery_place_2[1] ?? '', 'area_code' => $delivery_place_2[2] ?? '']));
  1453. break;
  1454. //产地
  1455. case 'origin_place':
  1456. $origin_place = explode(',', $before_info[$v]);
  1457. $before_info[$v] = empty($origin_place) ? $before_info[$v] : GetAddr(json_encode(['provice_code' => $origin_place[0] ?? '', 'city_code' => $origin_place[1] ?? '', 'area_code' => $origin_place[2] ?? '']));
  1458. $origin_place_2 = explode(',', $after_info[$v]);
  1459. $after_info[$v] = empty($origin_place_2) ? $after_info[$v] : GetAddr(json_encode(['provice_code' => $origin_place_2[0] ?? '', 'city_code' => $origin_place_2[1] ?? '', 'area_code' => $origin_place_2[2] ?? '']));
  1460. break;
  1461. //商品单位
  1462. case 'good_unit':
  1463. $all_unit = Db::name('unit')
  1464. ->whereIn('id', [$before_info[$v] ?? 0, $after_info[$v] ?? 0])
  1465. ->where(['is_del' => 0])
  1466. ->column('unit', 'id');
  1467. if (isset($before_info[$v])) $before_info[$v] = isset($all_unit[$before_info[$v]]) ? $all_unit[$before_info[$v]] : '';
  1468. if (isset($after_info[$v])) $after_info[$v] = isset($all_unit[$after_info[$v]]) ? $all_unit[$after_info[$v]] : '';
  1469. break;
  1470. //业务企业
  1471. case 'companyNo':
  1472. $all_business = Db::name('business')
  1473. ->whereIn('companyNo', [$before_info[$v] ?? '', $after_info[$v] ?? ''])
  1474. ->where(['is_del' => 0])
  1475. ->column('company', 'companyNo');
  1476. if (isset($before_info[$v])) $before_info[$v] = isset($all_business[$before_info[$v]]) ? $all_business[$before_info[$v]] : '';
  1477. if (isset($after_info[$v])) $after_info[$v] = isset($all_business[$after_info[$v]]) ? $all_business[$after_info[$v]] : '';
  1478. break;
  1479. //供应商
  1480. case 'supplierNo':
  1481. $all_supplier = Db::name('supplier')
  1482. ->whereIn('code', [$before_info[$v], $after_info[$v]])
  1483. ->where(['is_del' => 0])
  1484. ->column('name', 'code');
  1485. $before_info[$v] = isset($all_supplier[$before_info[$v]]) ? $all_supplier[$before_info[$v]] : '';
  1486. $after_info[$v] = isset($all_supplier[$after_info[$v]]) ? $all_supplier[$after_info[$v]] : '';
  1487. break;
  1488. //供货区域
  1489. case 'supply_area':
  1490. if (isset($before_info[$v])) {
  1491. if ($before_info[$v] == 1) $before_info[$v] = '全国';
  1492. elseif ($before_info[$v] == 2) $before_info[$v] = '全国除偏远';
  1493. else $before_info[$v] = '';
  1494. }
  1495. if (isset($after_info[$v])) {
  1496. if ($after_info[$v] == 1) $after_info[$v] = '全国';
  1497. elseif ($after_info[$v] == 2) $after_info[$v] = '全国除偏远';
  1498. else $after_info[$v] = '';
  1499. }
  1500. break;
  1501. //贵金属种类
  1502. case 'noble_metal':
  1503. if (isset($before_info[$v])) {
  1504. if ($before_info[$v] == 1) $before_info[$v] = '18K';
  1505. elseif ($before_info[$v] == 2) $before_info[$v] = '24K';
  1506. elseif ($before_info[$v] == 3) $before_info[$v] = '白银';
  1507. else $before_info[$v] = '';
  1508. }
  1509. if (isset($after_info[$v])) {
  1510. if ($after_info[$v] == 1) $after_info[$v] = '18K';
  1511. elseif ($after_info[$v] == 2) $after_info[$v] = '24K';
  1512. elseif ($after_info[$v] == 3) $after_info[$v] = '白银';
  1513. else $after_info[$v] = '';
  1514. }
  1515. break;
  1516. //专属类型
  1517. case 'is_exclusive':
  1518. if (isset($before_info[$v])) $before_info[$v] = implode('/', array_column(mai($before_info[$v]), 'rname'));
  1519. if (isset($after_info[$v])) $after_info[$v] = implode('/', array_column(mai($after_info[$v]), 'rname'));
  1520. break;
  1521. //状态
  1522. case 'status':
  1523. $all_status = [1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线'];
  1524. if (isset($before_info[$v])) $before_info[$v] = isset($all_status[$before_info[$v]]) ? $all_status[$before_info[$v]] : '';
  1525. if (isset($after_info[$v])) $after_info[$v] = isset($all_status[$after_info[$v]]) ? $all_status[$after_info[$v]] : '';
  1526. }
  1527. $key = isset($this->good_field_title[$v]) ? $this->good_field_title[$v] : $v;
  1528. if (isset($before_info[$v])) $before_new[$key] = $before_info[$v];
  1529. if (isset($after_info[$v])) $after_new[$key] = $after_info[$v];
  1530. }
  1531. $value['修改前的内容'] = json_encode($before_new, JSON_UNESCAPED_UNICODE);
  1532. $value['修改后的内容'] = json_encode($after_new, JSON_UNESCAPED_UNICODE);
  1533. $value['采购维护人所在部门'] = get_company_name_by_uid($value['createrid']);
  1534. unset($value['createrid']);
  1535. }
  1536. $list[] = $value;
  1537. }
  1538. if (empty($list)) $list[] = '没有可供导出的数据';
  1539. $headerArr = array_keys($list[0]);
  1540. excelSave('商品修改报表' . date('YmdHis'), $headerArr, $list);
  1541. }
  1542. //【八、结算报表】_列表(暂不做)
  1543. //【八、结算报表】_导出(暂不做)
  1544. //【九、出入库明细报表】_列表
  1545. public function GoodLogList()
  1546. {
  1547. /**
  1548. * $param = $this->request->only([
  1549. * 'token',
  1550. * 'creater' => '',
  1551. * 'supplier_name' => '',
  1552. * 'start_date' => '',
  1553. * 'end_date' => '',
  1554. * 'page' => 1,
  1555. * 'size' => 15
  1556. * ], 'post', 'trim');
  1557. * **/
  1558. }
  1559. //【九、出入库明细报表】_导出
  1560. public function GoodLogExport()
  1561. {
  1562. /**
  1563. * $param = $this->request->only([
  1564. * 'token',
  1565. * // 'creater' => '',
  1566. * // 'supplier_name' => '',
  1567. * // 'start_date' => '',
  1568. * // 'end_date' => ''
  1569. * ], 'post', 'trim');
  1570. *
  1571. * $val_params = Validate::rule([
  1572. * 'start_date' => 'date|elt:end_date',
  1573. * 'end_date' => 'date'
  1574. * ]);
  1575. *
  1576. * if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1577. *
  1578. * // $where = [['gl.action_type', '=', 'CGD']];
  1579. * // if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.updatetime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1580. * // if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1581. * // if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1582. *
  1583. *
  1584. * $list = Db::name('good_log')
  1585. * ->alias('gl')
  1586. * ->field('"" 创建人,"" 创建人公司,"" 创建人部门,"" 创建时间,"" 单据状态,"" 采购单号,gl.type 出入库类型,gb.good_name 商品名称,gb.spuCode 产品编码,gl.stock 出入库数量,gl.addtime 出入库日期,"" 维护人员,"" 发起人,wi.wsm_type 库房性质,s.name 库房公司,wi.name 库房名称')
  1587. * // ->where($where)
  1588. * ->leftJoin('good_stock gs', 'gs.id=gl.stock_id')
  1589. * ->leftJoin('good_basic gb', 'gb.spuCode=gs.spuCode AND gb.is_del=0')
  1590. * ->leftJoin('warehouse_info wi', 'wi.wsm_code=gs.wsm_code')
  1591. * ->leftJoin('supplier s', 's.code=wi.supplierNo')
  1592. * // ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1593. * ->select()
  1594. * ->toArray();
  1595. * halt($list);
  1596. * if (empty($list)) $list[] = '没有可供导出的数据';
  1597. *
  1598. * $headerArr = array_keys($list[0]);
  1599. * excelSave('出入库明细报表' . date('YmdHis'), $headerArr, $list);
  1600. **/
  1601. }
  1602. //【商品信息】基本信息(赵丹要的)_列表
  1603. public function goodSimpleZhao()
  1604. {
  1605. $param = $this->request->only([
  1606. 'token',
  1607. 'creater' => '',
  1608. 'supplier_name' => '',
  1609. 'start_date' => '',
  1610. 'end_date' => '',
  1611. 'page' => 1,
  1612. 'size' => 15
  1613. ], 'post', 'trim');
  1614. $val_params = Validate::rule([
  1615. 'start_date' => 'date|elt:end_date',
  1616. 'end_date' => 'date'
  1617. ]);
  1618. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1619. $where = [['s.is_del', '=', 0]];
  1620. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1621. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1622. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1623. $count = Db::name('good_platform')
  1624. ->alias('gp')
  1625. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1626. ->leftJoin('brand b', 'b.id=gb.brand_id')
  1627. ->leftJoin('unit u', 'u.id=gb.good_unit')
  1628. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1629. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1630. ->where($where)
  1631. ->count('gp.id');
  1632. $list = Db::name('good_platform')
  1633. ->alias('gp')
  1634. ->field('gp.skuCode,gp.spuCode,gp.plat_code,gb.good_name,b.brand_name,gb.cat_id,bi.company,gb.creater,p.platform_name,gp.online_time,gp.exam_status,gb.is_stock,gb.good_type,u.unit,gb.good_remark,gb.craft_desc,gb.noble_metal,gb.cgd_gold_price,gb.demo_fee,gb.open_fee,gb.sample_fee,gb.tax,gb.supply_area,s.name,gp.addtime')
  1635. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1636. ->leftJoin('brand b', 'b.id=gb.brand_id')
  1637. ->leftJoin('unit u', 'u.id=gb.good_unit')
  1638. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1639. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1640. ->leftJoin('business bi', 'bi.companyNo=gb.companyNo')
  1641. ->where($where)
  1642. ->order('gp.id', 'desc')
  1643. ->page($param['page'], $param['size'])
  1644. ->cursor();
  1645. $exam_status = [0 => '待提交', 1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线'];
  1646. $is_stock = [0 => '不是', 1 => '是'];
  1647. $good_type = [0 => '不是', 1 => '是'];
  1648. $noble_metal = [1 => '18K', 2 => '24K', 3 => '白银'];
  1649. $supply_area = [1 => '全国', 2 => '全国除偏远'];
  1650. $data = [];
  1651. foreach ($list as $value) {
  1652. $value['catinfo'] = made($value['cat_id']);
  1653. $value['exam_status'] = isset($exam_status[$value['exam_status']]) ? $exam_status[$value['exam_status']] : '';
  1654. $value['is_stock'] = isset($is_stock[$value['is_stock']]) ? $is_stock[$value['is_stock']] : '';
  1655. $value['good_type'] = isset($good_type[$value['good_type']]) ? $good_type[$value['good_type']] : '';
  1656. $value['specifications'] = Db::name('good_spec')
  1657. ->alias('gp')
  1658. ->leftJoin('specs s', 's.id=gp.spec_id')
  1659. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  1660. ->where([
  1661. 'gp.spuCode' => $value['spuCode'],
  1662. 'gp.is_del' => 0,
  1663. 's.spec_name' => '规格',
  1664. ])->value('sv.spec_value', '');
  1665. $value['model'] = Db::name('good_spec')
  1666. ->alias('gp')
  1667. ->leftJoin('specs s', 's.id=gp.spec_id')
  1668. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  1669. ->where([
  1670. 'gp.spuCode' => $value['spuCode'],
  1671. 'gp.is_del' => 0,
  1672. 's.spec_name' => '型号',
  1673. ])->value('sv.spec_value', '');
  1674. $value['noble_metal'] = isset($noble_metal[$value['noble_metal']]) ? $noble_metal[$value['noble_metal']] : '';
  1675. $value['supply_area'] = isset($supply_area[$value['supply_area']]) ? $supply_area[$value['supply_area']] : '';
  1676. $data[] = $value;
  1677. }
  1678. return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
  1679. }
  1680. //【商品信息】基本信息(赵丹要的)_导出
  1681. public function goodSimpleZhaoExport()
  1682. {
  1683. $param = $this->request->only([
  1684. 'token',
  1685. 'creater' => '',
  1686. 'supplier_name' => '',
  1687. 'start_date' => '',
  1688. 'end_date' => ''
  1689. ], 'post', 'trim');
  1690. $val_params = Validate::rule([
  1691. 'start_date' => 'date|elt:end_date',
  1692. 'end_date' => 'date'
  1693. ]);
  1694. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1695. $where = [['s.is_del', '=', 0]]; //exam_status==6 上线成功
  1696. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1697. if ($param['creater'] != '') $where[] = ['gb.creater', 'like', '%' . $param['creater'] . '%'];
  1698. if ($param['supplier_name'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier_name'] . '%'];
  1699. $list = Db::name('good_platform')
  1700. ->alias('gp')
  1701. ->field('gp.skuCode as 商品上线编号,gp.spuCode as 商品成本编号,gp.plat_code as 平台商品编码,gb.good_name as 商品名称,b.brand_name as 品牌名称,gb.cat_id as 分类,bi.company as 业务企业名称,gb.creater as 采购员,p.platform_name as 上线平台,gp.online_time as 上线完成时间,gp.exam_status as 上下线状态,gb.is_stock as 是否库存品,gb.good_type as 是否定制,"" as 规格,"" as 型号,u.unit as 单位,gb.good_remark as 商品备注,gb.craft_desc as 工艺说明,gb.noble_metal as 贵金属信息,gb.cgd_gold_price as 供应商采购金价,gb.demo_fee as 打样费,gb.open_fee as 开模费,gb.sample_fee as 调样费,gb.tax as 税点,gb.supply_area as 供货区域,s.name as 供应商名称,gp.addtime 申请上线时间')
  1702. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1703. ->leftJoin('brand b', 'b.id=gb.brand_id')
  1704. ->leftJoin('unit u', 'u.id=gb.good_unit')
  1705. ->leftJoin('supplier s', 's.code=gb.supplierNo')
  1706. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1707. ->leftJoin('business bi', 'bi.companyNo=gb.companyNo')
  1708. ->where($where)
  1709. ->order('gp.id', 'desc')
  1710. ->cursor();
  1711. $exam_status = [0 => '待提交', 1 => '待完善成本', 2 => '待产品审核', 3 => '待财务定价', 4 => '待财务审核定价', 5 => '待上线', 6 => '上线成功', 7 => '审核失败', 8 => '已下线'];
  1712. $is_stock = [0 => '不是', 1 => '是'];
  1713. $good_type = [0 => '不是', 1 => '是'];
  1714. $noble_metal = [1 => '18K', 2 => '24K', 3 => '白银'];
  1715. $supply_area = [1 => '全国', 2 => '全国除偏远'];
  1716. $data = [];
  1717. foreach ($list as $value) {
  1718. $value['分类'] = implode('/', array_column(made($value['分类']), 'name'));
  1719. $value['上下线状态'] = isset($exam_status[$value['上下线状态']]) ? $exam_status[$value['上下线状态']] : '';
  1720. $value['是否库存品'] = isset($is_stock[$value['是否库存品']]) ? $is_stock[$value['是否库存品']] : '';
  1721. $value['是否定制'] = isset($good_type[$value['是否定制']]) ? $good_type[$value['是否定制']] : '';
  1722. $value['规格'] = Db::name('good_spec')
  1723. ->alias('gp')
  1724. ->leftJoin('specs s', 's.id=gp.spec_id')
  1725. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  1726. ->where([
  1727. 'gp.spuCode' => $value['商品成本编号'],
  1728. 'gp.is_del' => 0,
  1729. 's.spec_name' => '规格',
  1730. ])->value('sv.spec_value', '');
  1731. $value['型号'] = Db::name('good_spec')
  1732. ->alias('gp')
  1733. ->leftJoin('specs s', 's.id=gp.spec_id')
  1734. ->leftJoin('spec_value sv', 'sv.id=gp.spec_value_id')
  1735. ->where([
  1736. 'gp.spuCode' => $value['商品成本编号'],
  1737. 'gp.is_del' => 0,
  1738. 's.spec_name' => '型号',
  1739. ])->value('sv.spec_value', '');
  1740. $value['贵金属信息'] = isset($noble_metal[$value['贵金属信息']]) ? $noble_metal[$value['贵金属信息']] : '';
  1741. $value['供货区域'] = isset($supply_area[$value['供货区域']]) ? $supply_area[$value['供货区域']] : '';
  1742. $data[] = $value;
  1743. }
  1744. if (empty($data)) $data[] = '没有可供导出的数据';
  1745. $headerArr = array_keys($data[0]);
  1746. excelSave('商品信息导出表(基本信息)' . date('YmdHis'), $headerArr, $data);
  1747. }
  1748. //【商品信息】成本(赵丹要的)_列表
  1749. public function goodCostZhao()
  1750. {
  1751. $param = $this->request->only([
  1752. 'token',
  1753. 'start_date' => '',
  1754. 'end_date' => '',
  1755. 'spuCode' => '',
  1756. 'page' => 1,
  1757. 'size' => 15
  1758. ], 'post', 'trim');
  1759. $val_params = Validate::rule([
  1760. 'start_date' => 'date|elt:end_date',
  1761. 'end_date' => 'date'
  1762. ]);
  1763. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1764. $where = [];
  1765. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1766. if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%'];
  1767. $count = Db::name('good_platform')
  1768. ->alias('gp')
  1769. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1770. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1771. ->leftJoin('good_nake gn', 'gn.spuCode=gb.spuCode')
  1772. ->leftJoin('good_ladder c', 'c.skuCode=gp.skuCode AND c.is_del=0')
  1773. ->where($where)
  1774. ->count('gp.id');
  1775. $data = Db::name('good_platform')
  1776. ->alias('gp')
  1777. ->field('gp.skuCode,gp.spuCode,gp.plat_code,gb.good_name,p.platform_name,gp.online_time,c.min_num moq,gn.nake_fee,gb.cost_fee,gn.delivery_fee,gb.cert_fee,gb.mark_fee,gb.packing_fee,gn.other_fee,gn.nake_total,gp.addtime')
  1778. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1779. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1780. ->leftJoin('good_nake gn', 'gn.spuCode=gb.spuCode')
  1781. ->leftJoin('good_ladder c', 'c.skuCode=gp.skuCode AND c.is_del=0')//加入c.is_del可以命中索引
  1782. ->where($where)
  1783. ->order('gp.id', 'desc')
  1784. ->page($param['page'], $param['size'])
  1785. ->select()
  1786. ->toArray();
  1787. return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
  1788. }
  1789. //【商品信息】成本(赵丹要的)_导出
  1790. public function goodCostZhaoExport()
  1791. {
  1792. $param = $this->request->only([
  1793. 'token',
  1794. 'start_date' => '',
  1795. 'end_date' => '',
  1796. 'spuCode' => '',
  1797. ], 'post', 'trim');
  1798. $val_params = Validate::rule([
  1799. 'start_date' => 'date|elt:end_date',
  1800. 'end_date' => 'date'
  1801. ]);
  1802. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1803. $where = [];
  1804. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1805. if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%'];
  1806. $data = Db::name('good_platform')
  1807. ->alias('gp')
  1808. ->field('gp.skuCode as 商品上线编号,gp.spuCode as 商品成本编号,gp.plat_code as 平台商品编码,gb.good_name as 商品名称,p.platform_name as 上线平台,gp.online_time as 上线完成时间,c.min_num 起订量,gn.nake_fee 成本单价,gb.cost_fee 工艺费,gn.delivery_fee 物流费,gb.cert_fee 证书费,gb.mark_fee 加标费,gb.packing_fee 包装费,gn.other_fee 其他费用,gn.nake_total 成本合计,gp.addtime 申请上线时间')
  1809. ->where($where)
  1810. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1811. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1812. ->leftJoin('good_nake gn', 'gn.spuCode=gb.spuCode')
  1813. ->leftJoin('good_ladder c', 'c.skuCode=gp.skuCode AND c.is_del=0')
  1814. ->order('gp.id', 'desc')
  1815. ->select()
  1816. ->toArray();
  1817. if (empty($data)) $data[] = '没有可供导出的数据';
  1818. $headerArr = array_keys($data[0]);
  1819. excelSave('商品信息导出表(成本)' . date('YmdHis'), $headerArr, $data);
  1820. }
  1821. //【商品信息】售价(赵丹要的)_列表
  1822. public function goodPriceZhao()
  1823. {
  1824. $param = $this->request->only([
  1825. 'token',
  1826. 'start_date' => '',
  1827. 'end_date' => '',
  1828. 'spuCode' => '',
  1829. 'page' => 1,
  1830. 'size' => 15
  1831. ], 'post', 'trim');
  1832. $val_params = Validate::rule([
  1833. 'start_date' => 'date|elt:end_date',
  1834. 'end_date' => 'date'
  1835. ]);
  1836. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1837. $where = [];
  1838. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1839. if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%'];
  1840. $count = Db::name('good_platform')
  1841. ->alias('gp')
  1842. ->where($where)
  1843. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1844. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1845. ->leftJoin('good_ladder gl', 'gl.skuCode=gp.skuCode')
  1846. ->count('gp.id');
  1847. $data = Db::name('good_platform')
  1848. ->alias('gp')
  1849. ->field('gp.skuCode,gp.spuCode,gp.plat_code,gb.good_name,p.platform_name,gp.online_time,gl.min_num moq,gl.sale_price,gl.cost_fee,gl.market_price,gl.market_platform,gp.addtime')
  1850. ->where($where)
  1851. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1852. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1853. ->leftJoin('good_ladder gl', 'gl.skuCode=gp.skuCode AND gl.is_del=0')//加入is_del可以命中索引
  1854. ->order('gp.id', 'desc')
  1855. ->page($param['page'], $param['size'])
  1856. ->select()
  1857. ->toArray();
  1858. return app_show(0, '请求成功', ['list' => $data, 'count' => $count]);
  1859. }
  1860. //【商品信息】售价(赵丹要的)_导出
  1861. public function goodPriceZhaoExport()
  1862. {
  1863. $param = $this->request->only([
  1864. 'token',
  1865. 'start_date' => '',
  1866. 'end_date' => '',
  1867. 'spuCode' => ''
  1868. ], 'post', 'trim');
  1869. $val_params = Validate::rule([
  1870. 'start_date' => 'date|elt:end_date',
  1871. 'end_date' => 'date'
  1872. ]);
  1873. if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
  1874. $where = [];
  1875. if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['gp.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
  1876. if ($param['spuCode'] != '') $where[] = ['gp.spuCode', 'like', '%' . $param['spuCode'] . '%'];
  1877. $data = Db::name('good_platform')
  1878. ->alias('gp')
  1879. ->field('gp.skuCode as 商品上线编号,gp.spuCode as 商品成本编号,gp.plat_code as 平台商品编码,gb.good_name as 商品名称,p.platform_name as 上线平台,gp.online_time as 上线完成时间,gl.min_num 起订量,gl.sale_price 售价,gl.cost_fee 工艺费,gl.market_price 市场价,gl.market_platform 对比平台,gp.addtime 申请上线时间')
  1880. ->where($where)
  1881. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1882. ->leftJoin('platform p', 'p.id=gp.platform_code')
  1883. ->leftJoin('good_ladder gl', 'gl.skuCode=gp.skuCode AND gl.is_del=0')
  1884. ->order('gp.id', 'desc')
  1885. ->select()
  1886. ->toArray();
  1887. if (empty($data)) $data[] = '没有可供导出的数据';
  1888. $headerArr = array_keys($data[0]);
  1889. excelSave('商品信息导出表(售价)' . date('YmdHis'), $headerArr, $data);
  1890. }
  1891. }