ESinit.Class.php 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. <?php
  2. /**
  3. * ES初始化类 创建映射
  4. * Created by PhpStorm.
  5. * User: wxj
  6. * Date: 2019/11/8
  7. * Time: 14:47
  8. */
  9. namespace Jindouyun\Controller\Common;
  10. use Mall\Framework\Core\Config;
  11. use Mall\Framework\Core\ErrorCode;
  12. use Mall\Framework\Factory;
  13. use Mall\Framework\Core\Request;
  14. class ESInit
  15. {
  16. private $request;
  17. public function __construct()
  18. {
  19. $this->request = Request::getInstance();
  20. }
  21. public function search($s = 0)
  22. {
  23. if ($s) {
  24. $c = intval($s);
  25. } else {
  26. $data = Request::params();
  27. $c = $data['b'] ?: 1;
  28. }
  29. switch ($c) {
  30. //添加商品索引库
  31. case 1:
  32. $mappings = array(
  33. 'mappings' => array(
  34. "_default_" => [
  35. "properties" => [
  36. 'basicGoodsId' => ["type" => "integer"],//关联商品基本资料id,
  37. 'id' => ["type" => "integer"],//商品id,
  38. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  39. 'shopId' => ["type" => "integer"],//'商铺id',
  40. 'warehouseId' => ["type" => "integer"],//'仓库id',
  41. 'images' => [
  42. 'type' => 'text'
  43. ],
  44. 'serviceInfo' => ["type" => "integer"],//'服务保证',
  45. 'salesNum' => [
  46. "properties" => [
  47. "skuId" => ["type" => "integer",],
  48. "salesNum" => ["type" => "integer",],
  49. ]
  50. ],//销量
  51. 'content' => [
  52. 'type' => 'text',
  53. "analyzer" => "ik_max_word",
  54. "search_analyzer" => "ik_max_word"
  55. ],//'商品详情',
  56. 'extend' => [
  57. 'type' => 'text',
  58. "analyzer" => "ik_max_word",
  59. "search_analyzer" => "ik_max_word"
  60. ],// '扩展字段',
  61. 'sort' => ["type" => "integer"],//'排序',
  62. 'isRecommend' => ["type" => "integer"],//是否推荐(5是 4否)',
  63. 'deleteStatus' => ["type" => "integer"],//删除状态(5未删除 4已删除)',
  64. 'enableStatus' => ["type" => "integer"],//上下架(5上架 4下架)',
  65. 'createTime' => [
  66. 'type' => 'integer',
  67. ],//'创建时间'
  68. 'updateTime' => [
  69. 'type' => 'integer',
  70. ],//'修改时间',
  71. ]
  72. ]
  73. )
  74. );
  75. $searchServer = Factory::search('goods_search');
  76. $result = $searchServer->createBase('online_goods_search', $mappings);
  77. if ($result && !isset($result['error'])) {
  78. echo 'online_goods_search init done.';
  79. return true;
  80. } else {
  81. print_r($result['error']);
  82. return false;
  83. }
  84. break;
  85. //删除商品索引库
  86. case 2:
  87. $searchServer = Factory::search('goods_search');
  88. $searchServer->setIndex('online_goods_search');
  89. $a = $searchServer->deleteBase('online_goods_search');
  90. print_r($a);
  91. break;
  92. //添加客户索引库
  93. case 3:
  94. $mappings = array(
  95. 'mappings' => array(
  96. "_default_" => [
  97. "properties" => [
  98. 'id' => ['type' => 'integer'],//customerId,
  99. 'userCenterId' => ['type' => 'integer'],//userCenterId,
  100. 'mobile' => ['type' => 'keyword'],
  101. 'source' => ['type' => 'integer'],//客户来源
  102. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  103. 'status' => ['type' => 'integer'],//'账号状态(1已审核 2待审核)',
  104. 'statusName' => ['type' => 'keyword'],//状态名称,
  105. 'name' => [
  106. 'type' => 'text',
  107. "analyzer" => "ik_max_word",
  108. "search_analyzer" => "ik_max_word"
  109. ],//'客户名称',
  110. 'code' => ['type' => 'keyword'],//'客户编码',
  111. 'type' => ['type' => 'integer'],//'客户类型',
  112. 'provinceCode' => ['type' => 'keyword'],//varchar(20) NOT NULL COMMENT '客户地址省编码',
  113. 'cityCode' => ['type' => 'keyword'],//varchar(20) NOT NULL COMMENT '客户地址市编码',
  114. 'districtCode' => ['type' => 'keyword'],//varchar(20) NOT NULL COMMENT '客户地址区编码',
  115. 'provinceName' => ['type' => 'keyword'],//省名称
  116. 'cityName' => ['type' => 'keyword'],//市名称
  117. 'districtName' => ['type' => 'keyword'],//区名称
  118. "address" => [
  119. "type" => "text",
  120. "analyzer" => "ik_max_word",
  121. "search_analyzer" => "ik_max_word"
  122. ],
  123. 'managerMobile' => ['type' => 'keyword'],//'负责人电话',
  124. 'shopId' => ['type' => 'integer'],//商铺id,
  125. 'shopName' => ['type' => 'keyword'],//商铺名称,
  126. 'departmentId' => ['type' => 'integer'],//销售部Id,
  127. 'departmentName' => ['type' => 'keyword'],//部门名称,
  128. 'salesManId' => ['type' => 'integer'],//int(10) DEFAULT NULL COMMENT '业务员id',
  129. 'salesManCode' => ['type' => 'keyword'],//'业务员编码',
  130. 'salesManName' => [
  131. 'type' => 'text',
  132. "analyzer" => "ik_max_word",
  133. "search_analyzer" => "ik_max_word"
  134. ],//'业务员名称',
  135. 'birthday' => [
  136. 'type' => 'integer'
  137. ],//'客户生日',
  138. 'enableStatus' => ['type' => 'integer'],//'启用状态(5启用 4禁用)',
  139. 'deleteStatus' => ['type' => 'integer'],//'删除状态(5未删除 4已删除)',
  140. 'createTime' => ['type' => 'integer'],//'创建时间'
  141. 'updateTime' => ['type' => 'integer'],//'修改时间',
  142. 'extend' => [
  143. 'type' => 'text',
  144. "analyzer" => "ik_max_word",
  145. "search_analyzer" => "ik_max_word"
  146. ],// '扩展字段',
  147. 'tag' => [// '客户标签',
  148. 'type' => 'text',
  149. "analyzer" => "ik_max_word",
  150. "search_analyzer" => "ik_max_word"
  151. ],
  152. 'remark' => [
  153. "type" => "text",
  154. "analyzer" => "ik_max_word",
  155. "search_analyzer" => "ik_max_word",
  156. ],// '备注'
  157. 'location' => [
  158. "type" => "geo_point",
  159. ],//经纬度
  160. 'contact' => [
  161. "properties" => [
  162. "name" => ["type" => "keyword",],
  163. "mobile" => ["type" => "keyword",],
  164. ]
  165. ],// '联系人'
  166. ]
  167. ]
  168. )
  169. );
  170. $searchServer = Factory::search('customer_search');
  171. $result = $searchServer->createBase('online_customer_search', $mappings);
  172. if ($result && !isset($result['error'])) {
  173. echo 'online_customer_search init done.';
  174. return true;
  175. } else {
  176. print_r($result['error']);
  177. return false;
  178. }
  179. break;
  180. //删除客户索引库
  181. case 4:
  182. $searchServer = Factory::search('customer_search');
  183. $searchServer->setIndex('online_customer_search');
  184. $a = $searchServer->deleteBase('online_customer_search');
  185. print_r($a);
  186. break;
  187. //添加商品基本资料
  188. case 5:
  189. //创建映射
  190. $mappings = array(
  191. "settings" => [
  192. "analysis" => [
  193. "analyzer" => [
  194. "comma"=>[
  195. "type" => "pattern",
  196. "pattern" => ","
  197. ]
  198. ]
  199. ]
  200. ],
  201. 'mappings' => array(
  202. "_default_" => [
  203. "properties" => [
  204. 'id' => ["type" => "integer"],//商品基本资料id,
  205. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  206. 'images' => ['type' => 'text'],
  207. 'title' => [
  208. 'type' => 'text',
  209. "analyzer" => "ik_max_word",
  210. "search_analyzer" => "ik_max_word"
  211. ],//商品名称,
  212. 'code' => ["type" => "keyword"],
  213. 'barCode' => ["type" => "keyword"],
  214. 'categoryId' => ["type" => "integer"],//'商品分类id',
  215. 'expireTime' => ["type" => "integer"],//'过期时间',
  216. 'brandId' => ["type" => "integer"],//'品牌id',
  217. 'tag' => [
  218. 'type' => 'text',
  219. "analyzer" => "ik_max_word",
  220. "search_analyzer" => "ik_max_word"
  221. ],//'关键词',
  222. 'description' => [
  223. 'type' => 'text',
  224. "analyzer" => "ik_max_word",
  225. "search_analyzer" => "ik_max_word"
  226. ],//'商品详情',
  227. 'noSalesShop' => ['type' => 'text'],//'禁止销售店铺',
  228. 'extends' => [
  229. 'type' => 'text',
  230. "analyzer" => "ik_max_word",
  231. "search_analyzer" => "ik_max_word"
  232. ],//'拓展字段',
  233. 'enableStatus' => ["type" => "integer"],//'商品状态 默认5 上线 6下线',
  234. 'deleteStatus' => ["type" => "integer"],//'是否删除 4 删除 5正常',
  235. 'createTime' => [
  236. 'type' => 'integer',
  237. ],//'创建时间'
  238. 'updateTime' => [
  239. 'type' => 'integer',
  240. ],//'修改时间',
  241. 'categoryPath' => [
  242. "type" => "text",
  243. "analyzer" => "comma",
  244. "search_analyzer" => "comma"
  245. ],//'分类路径',
  246. 'skuData' => [
  247. "properties" => [
  248. "masterUnit" => [
  249. "properties" => [
  250. "id" => ["type" => "integer",],
  251. "unitName" => ["type" => "keyword",],
  252. "unitId" => ["type" => "integer",],
  253. "isMaster" => ["type" => "integer",],
  254. "deleteStatus" => ["type" => "integer",],
  255. ]
  256. ],
  257. "branchUnit" => [
  258. "properties" => [
  259. "id" => ["type" => "integer",],
  260. "unitName" => ["type" => "keyword",],
  261. "unitId" => ["type" => "integer",],
  262. "isMaster" => ["type" => "integer",],
  263. "deleteStatus" => ["type" => "integer",],
  264. ]
  265. ]
  266. ]
  267. ],//sku
  268. ],
  269. ]
  270. )
  271. );
  272. $searchServer = Factory::search('goods_basic_search');
  273. $result = $searchServer->createBase('goods_basic_search', $mappings);
  274. if ($result && !isset($result['error'])) {
  275. echo 'online_goods_basic_search init done.';
  276. return true;
  277. } else {
  278. print_r($result['error']);
  279. return false;
  280. }
  281. break;
  282. //删除商品基本资料索引库
  283. case 6:
  284. $searchServer = Factory::search('goods_basic_search');
  285. $searchServer->setIndex('goods_basic_search');
  286. $a = $searchServer->deleteBase('online_goods_basic_search');
  287. print_r($a);
  288. break;
  289. //创建订单索引库
  290. case 7:
  291. $mappings = array(
  292. 'mappings' => array(
  293. "order" => [
  294. "properties" => [
  295. /*订单表信息*/
  296. 'id' => ["type" => "integer"],//订单id,
  297. 'no' => ["type" => "keyword"],//订单编号,
  298. 'outerTradeNo' => ['type' => 'keyword'],//'外部流水号(支付宝/微信返回的流水号)'
  299. 'shopId' => ['type' => 'integer'],//商铺id
  300. 'userCenterId' => ['type' => 'integer'],//用户id
  301. 'enterpriseId' => ['type' => 'integer'],//企业id
  302. 'customerType' => ['type' => 'integer'],//客户类型
  303. 'totalMoney' => [
  304. 'type' => 'scaled_float',
  305. 'scaling_factor' => 100
  306. ],//'总金额',
  307. 'payAmount' => [
  308. 'type' => 'scaled_float',
  309. 'scaling_factor' => 100
  310. ],//实付金额
  311. 'buyTotal' => ["type" => "integer"],//购买总数
  312. 'customerName' => ["type" => "keyword"],//客户姓名
  313. 'customerId' => ["type" => "integer"],//客户id
  314. 'payStatus' => ["type" => "integer"],//'支付状态 默认1 未支付 2已支付'
  315. 'orderStatus' => ["type" => "integer"],//订单状态 默认1 创建 2待支付 3代发货 4待收货 5已完成 6已关闭
  316. 'payType' => ["type" => "integer"],//'支付方式 1微信 2支付宝 3货到付款 4上门自提'
  317. 'deliveryType' => ["type" => "integer"],//'配送方式 1商品配送 2上门自提'
  318. 'source' => ["type" => "integer"],//订单来源 默认1 ios 2android 3小程序 4后台创建
  319. 'remark' => [
  320. 'type' => 'text',
  321. "analyzer" => "ik_max_word",
  322. "search_analyzer" => "ik_max_word"
  323. ],//订单备注
  324. 'auditStatus' => ["type" => "integer"],// '审核状态 默认1 待审 2审核通过 3 审核未通过 4 审核中'
  325. 'payTime' => [
  326. 'type' => 'integer',
  327. /**/
  328. ],//'付款时间'
  329. 'createTime' => [
  330. 'type' => 'integer',
  331. ],//'创建时间'
  332. 'updateTime' => [
  333. 'type' => 'integer',
  334. ],//'修改时间',
  335. 'salesManId' => ["type" => "integer"],//业务员id
  336. 'salesManName' => ["type" => "keyword"],//业务员名称
  337. /*收货人信息*/
  338. 'realName' => ["type" => "keyword"],//收货人姓名
  339. 'mobile' => ["type" => "keyword"],//收货人电话
  340. 'address' => [
  341. 'type' => 'text',
  342. "analyzer" => "ik_max_word",
  343. "search_analyzer" => "ik_max_word"
  344. ],//收货详细地址
  345. 'provinceCode' => ["type" => "integer"],//收货人省份编码
  346. 'cityCode' => ["type" => "integer"],//收货人城市编码
  347. 'districtCode' => ["type" => "integer"],//收货人区编码
  348. 'goodsName' => [
  349. 'type' => 'text',
  350. "analyzer" => "ik_max_word",
  351. "search_analyzer" => "ik_max_word"
  352. ],
  353. ]
  354. ]
  355. )
  356. );
  357. $searchServer = Factory::search('order_search');
  358. $result = $searchServer->createBase('online_order_search', $mappings);
  359. if ($result && !isset($result['error'])) {
  360. echo 'online_order_search init done.';
  361. return true;
  362. } else {
  363. print_r($result['error']);
  364. return false;
  365. }
  366. break;
  367. //删除订单索引库
  368. case 8:
  369. $searchServer = Factory::search('order_search');
  370. $searchServer->setIndex('online_order_search');
  371. $a = $searchServer->deleteBase('online_order_search');
  372. print_r($a);
  373. break;
  374. //添加商铺索引库
  375. case 9:
  376. //创建映射
  377. $mappings = array(
  378. "settings" => [
  379. "analysis" => [
  380. "analyzer" => [
  381. "comma"=>[
  382. "type" => "pattern",
  383. "pattern" => ","
  384. ]
  385. ]
  386. ]
  387. ],
  388. 'mappings' => array(
  389. "_default_" => [
  390. "properties" => [
  391. 'id' => ["type" => "integer"],//商铺id,
  392. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  393. 'name' => [
  394. 'type' => 'text',
  395. "analyzer" => "ik_max_word",
  396. "search_analyzer" => "ik_max_word"
  397. ],//商铺名称,
  398. 'logo' => ['type' => 'text'],//商铺logo,
  399. 'shopCode' => ['type' => 'text'],//商铺仓库编码,
  400. 'shopType' => ['type' => 'integer'],//商铺类型,
  401. 'openTime' => [
  402. "properties" => [
  403. "start" => ["type" => "text",],
  404. "end" => ["type" => "text",],
  405. "isAllDay" => ["type" => "integer",],
  406. ]
  407. ],//营业时间
  408. 'contactName' => ['type' => 'keyword'],//联系人,
  409. 'mobile' => ['type' => 'keyword'],//联系电话,
  410. 'deleteStatus' => ["type" => "integer"],//删除状态(5未删除 4已删除)',
  411. 'enableStatus' => ["type" => "integer"],//启用状态(4未启用 5已启用)
  412. 'createTime' => [
  413. 'type' => 'integer',
  414. ],//'创建时间'
  415. 'updateTime' => [
  416. 'type' => 'integer',
  417. ],//'修改时间',
  418. 'provinceCode' => ['type' => 'keyword'],//varchar(20) NOT NULL COMMENT '商铺地址省编码',
  419. 'cityCode' => ['type' => 'keyword'],//varchar(20) NOT NULL COMMENT '商铺地址市编码',
  420. 'districtCode' => ['type' => 'keyword'],//varchar(20) NOT NULL COMMENT '商铺地址区编码',
  421. 'provinceName' => ['type' => 'keyword'],//商铺省名称
  422. 'cityName' => ['type' => 'keyword'],//商铺市名称
  423. 'districtName' => ['type' => 'keyword'],//商铺区名称
  424. "address" => [
  425. "type" => "text",
  426. "analyzer" => "ik_max_word",
  427. "search_analyzer" => "ik_max_word"
  428. ],
  429. 'location' => [
  430. "type" => "geo_point",
  431. ],//经纬度
  432. 'salesArea' => [
  433. "type" => "text",
  434. "analyzer" => "comma",
  435. "search_analyzer" => "comma"
  436. ],//'销售区域',
  437. ],
  438. ]
  439. )
  440. );
  441. $searchServer = Factory::search('shop_search');
  442. $result = $searchServer->createBase('online_shop_search', $mappings);
  443. if ($result && !isset($result['error'])) {
  444. echo 'online_shop_search init done.';
  445. return true;
  446. } else {
  447. print_r($result['error']);
  448. return false;
  449. }
  450. break;
  451. //删除商铺索引库
  452. case 10:
  453. $searchServer = Factory::search('shop_search');
  454. $searchServer->setIndex('online_shop_search');
  455. $a = $searchServer->deleteBase('online_shop_search');
  456. print_r($a);
  457. break;
  458. //添加登录日志索引库
  459. case 11:
  460. //创建映射
  461. $mappings = array(
  462. 'mappings' => array(
  463. "_default_" => [
  464. "properties" => [
  465. 'id' => ["type" => "integer"],
  466. 'userCenterId' => ['type' => 'integer'],
  467. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  468. 'mobile' => ['type' => 'keyword'],//联系电话,
  469. 'createTime' => [
  470. 'type' => 'integer',
  471. ],//'创建时间'
  472. 'source' => [
  473. 'type' => 'keyword',
  474. ],
  475. 'actionType' => [
  476. 'type' => 'keyword',
  477. ]
  478. ]
  479. ]
  480. )
  481. );
  482. $searchServer = Factory::search('login_log');
  483. $result = $searchServer->createBase('online_login_log', $mappings);
  484. if ($result && !isset($result['error'])) {
  485. echo 'online_login_log init done.';
  486. return true;
  487. } else {
  488. print_r($result['error']);
  489. return false;
  490. }
  491. break;
  492. //删除登录日志
  493. case 12:
  494. $searchServer = Factory::search('login_log');
  495. $searchServer->setIndex('online_login_log');
  496. $a = $searchServer->deleteBase('online_login_log');
  497. print_r($a);
  498. break;
  499. //添加日志索引库
  500. case 13:
  501. //创建映射
  502. $mappings = array(
  503. 'mappings' => array(
  504. "_default_" => [
  505. "properties" => [
  506. 'id' => ["type" => "integer"],
  507. 'userCenterId' => ['type' => 'integer'],
  508. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  509. 'createTime' => [
  510. 'type' => 'integer',
  511. ],//'创建时间'
  512. 'no' => [
  513. 'type' => 'text',
  514. "analyzer" => "ik_max_word",
  515. "search_analyzer" => "ik_max_word"
  516. ],
  517. 'actionType' => [
  518. 'type' => 'keyword',
  519. ]
  520. ]
  521. ]
  522. )
  523. );
  524. $searchServer = Factory::search('logs');
  525. $result = $searchServer->createBase('online_logs', $mappings);
  526. if ($result && !isset($result['error'])) {
  527. echo 'online_logs init done.';
  528. return true;
  529. } else {
  530. print_r($result['error']);
  531. return false;
  532. }
  533. break;
  534. //删除日志
  535. case 14:
  536. $searchServer = Factory::search('logs');
  537. $searchServer->setIndex('online_logs');
  538. $a = $searchServer->deleteBase('online_logs');
  539. print_r($a);
  540. break;
  541. //入库列表
  542. case 15:
  543. $mappings = array(
  544. 'mappings' => array(
  545. "inventory_in" => [
  546. "properties" => [
  547. //入库表信息
  548. 'id' => ["type" => "integer"],//入库id
  549. 'no' => ["type" => "keyword"],//入库编号
  550. 'sourceNo' => ['type' => 'keyword'],//来源单号
  551. 'materielNum' => ['type' => 'integer'],//商品数量
  552. 'amount' => ['type' => 'scaled_float', 'scaling_factor' => 100],//总金额
  553. 'warehouseId' => ['type' => 'integer'],//仓库id
  554. 'warehouseName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//仓库名称
  555. 'operatorId' => ['type' => 'integer'],//操作人id
  556. 'operatorName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//操作人name
  557. 'auditId' => ['type' => 'integer'],//审核人id
  558. 'auditName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"], //审核人name
  559. 'remark' => ['type' => 'text'],//备注
  560. 'deleteStatus' => ['type' => 'integer'],//删除状态
  561. 'source' => ['type' => 'integer'],//来源
  562. 'type' => ['type' => 'integer'],
  563. 'auditStatus' => ['type' => 'integer'],//审核状态
  564. 'auditTime' => ['type' => 'integer'],//审核日期
  565. 'createTime' => ['type' => 'integer'],//创建时间
  566. 'updateTime' => ['type' => 'integer'],//更新时间
  567. ],
  568. ]
  569. )
  570. );
  571. $searchServer = Factory::search('inventory_in_search');
  572. $result = $searchServer->createBase('online_inventory_in_search', $mappings);
  573. if ($result && !isset($result['error'])) {
  574. echo 'online_inventory_in_search init done.';
  575. return true;
  576. } else {
  577. print_r($result['error']);
  578. return false;
  579. }
  580. break;
  581. //删除入库
  582. case 16:
  583. $searchServer = Factory::search('inventory_in_search');
  584. $searchServer->setIndex('online_inventory_in_search');
  585. $a = $searchServer->deleteBase('online_inventory_in_search');
  586. print_r($a);
  587. break;
  588. //出库列表
  589. case 17:
  590. $mappings = array(
  591. 'mappings' => array(
  592. "inventory_out" => [
  593. "properties" => [
  594. //入库表信息
  595. 'id' => ["type" => "integer"],//入库id
  596. 'no' => ["type" => "keyword"],//入库编号
  597. 'sourceNo' => ['type' => 'keyword'],//来源单号
  598. 'materielNum' => ['type' => 'integer'],//商品数量
  599. 'amount' => ['type' => 'scaled_float', 'scaling_factor' => 100],//总金额
  600. 'warehouseId' => ['type' => 'integer'],//仓库id
  601. 'warehouseName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//仓库名称
  602. 'operatorId' => ['type' => 'integer'],//操作人id
  603. 'operatorName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//操作人name
  604. 'auditId' => ['type' => 'integer'],//审核人id
  605. 'auditName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"], //审核人name
  606. 'customerId' => ['type' => 'integer'],
  607. 'customerName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  608. 'customerCode' => ['type' => 'text'],
  609. 'customerMobile' => ['type' => 'keyword'],
  610. 'remark' => ['type' => 'text'],//备注
  611. 'deleteStatus' => ['type' => 'integer'],//删除状态
  612. 'source' => ['type' => 'integer'],//来源
  613. 'type' => ['type' => 'integer'],
  614. 'auditStatus' => ['type' => 'integer'],//审核状态
  615. 'auditTime' => ['type' => 'integer'],//审核日期
  616. 'createTime' => ['type' => 'integer'],//创建时间
  617. 'updateTime' => ['type' => 'integer'],//更新时间
  618. ]
  619. ]
  620. )
  621. );
  622. $searchServer = Factory::search('inventory_out_search');
  623. $result = $searchServer->createBase('online_inventory_out_search', $mappings);
  624. if ($result && !isset($result['error'])) {
  625. echo 'online_inventory_out_search init done.';
  626. return true;
  627. } else {
  628. print_r($result['error']);
  629. return false;
  630. }
  631. break;
  632. //删除出库
  633. case 18:
  634. $searchServer = Factory::search('inventory_out_search');
  635. $searchServer->setIndex('online_inventory_out_search');
  636. $a = $searchServer->deleteBase('online_inventory_out_search');
  637. print_r($a);
  638. break;
  639. //商品调价单
  640. case 19:
  641. $mappings = array(
  642. 'mappings' => array(
  643. "priceAdjustmentSheet" => [
  644. "properties" => [
  645. /*订单表信息*/
  646. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  647. 'id' => ["type" => "integer"],//自增id,
  648. 'no' => ["type" => "keyword"],//调价单号,
  649. 'goodsCode' => ['type' => 'keyword'],//商品编号
  650. 'goodsName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//商品名称
  651. 'goodsId' => ['type' => 'integer'],//商品id
  652. 'saleType' => ['type' => 'integer'],//销售类型 1实物销售 2虚库销售
  653. 'salePriceAreaType' => ['type' => 'integer'],//销售价格生效区域类型 1全国统一价 2大区价
  654. 'salePriceType' => ['type' => 'integer'],//销售价格类型 1销售价格 2秒杀活动价
  655. 'shopId' => ['type' => 'integer'],//店铺id
  656. 'shopName' => ['type' => 'keyword'],//店铺名称
  657. 'cargoOwnerCode' => ['type' => 'keyword'],//货主编码
  658. 'createUserId' => ['type' => 'integer'],//创建人id
  659. 'createUserName' => ['type' => 'keyword'],//创建人姓名
  660. 'effectiveUserName' => ['type' => 'keyword'],//生效人姓名
  661. 'effectiveUserId' => ['type' => 'integer'],//生效人id
  662. 'deleteStatus' => ['type' => 'integer'],//删除状态 4删除 5正常
  663. 'effectiveStatus' => ['type' => 'integer'],//生效状态 1.待审 2审核通过 3未通过 4审核中
  664. 'createTime' => ['type' => 'integer',],//创建时间
  665. 'updateTime' => ['type' => 'integer',],//修改时间
  666. 'salePrice' => [
  667. "properties" => [
  668. ]
  669. ],//销售价格
  670. ]
  671. ]
  672. )
  673. );
  674. $searchServer = Factory::search('priceAdjustmentSheet_search');
  675. $result = $searchServer->createBase('online_priceadjustmentsheet_search', $mappings);
  676. if ($result && !isset($result['error'])) {
  677. echo 'online_priceadjustmentsheet_search init done.';
  678. } else {
  679. print_r($result['error']);
  680. return false;
  681. }
  682. break;
  683. //删除商品调价单
  684. case 20:
  685. $searchServer = Factory::search('priceAdjustmentSheet_search');
  686. $searchServer->setIndex('online_priceadjustmentsheet_search');
  687. $a = $searchServer->deleteBase('online_priceadjustmentsheet_search');
  688. print_r($a);
  689. break;
  690. //调拨列表
  691. case 21:
  692. $mappings = array(
  693. 'mappings' => array(
  694. "allocate" => [
  695. "properties" => [
  696. //入库表信息
  697. 'id' => ["type" => "integer"],//入库id
  698. 'no' => ["type" => "keyword"],//入库编号
  699. 'warehouseId' => ['type' => 'integer'],//仓库id
  700. 'inWarehouseId' => ['type' => 'integer'],//in仓库id
  701. 'warehouseName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//仓库名称
  702. 'operatorId' => ['type' => 'integer'],//操作人id
  703. 'operatorName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//操作人name
  704. 'auditId' => ['type' => 'integer'],//审核人id
  705. 'auditName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"], //审核人name
  706. 'remark' => ['type' => 'text'],//备注
  707. 'deleteStatus' => ['type' => 'integer'],//删除状态
  708. 'auditStatus' => ['type' => 'integer'],//审核状态
  709. 'auditTime' => ['type' => 'integer'],//审核日期
  710. 'createTime' => ['type' => 'integer'],//创建时间
  711. 'updateTime' => ['type' => 'integer'],//更新时间
  712. 'linkId' => ["type" => "integer"],
  713. 'materielId' => ["type" => "integer"],
  714. 'materielName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  715. 'materielCode' => ["type" => "text"],
  716. 'skuId' => ["type" => "integer"],
  717. 'num' => ["type" => "double"],
  718. 'costUnitPrice' => ["type" => "double"],
  719. 'batch' => ["type" => "object"],
  720. ]
  721. ]
  722. )
  723. );
  724. $searchServer = Factory::search('allocate_search');
  725. $result = $searchServer->createBase('dev_allocate_search', $mappings);
  726. if ($result && !isset($result['error'])) {
  727. echo 'dev_allocate_search init done.';
  728. return true;
  729. } else {
  730. print_r($result['error']);
  731. return false;
  732. }
  733. break;
  734. //调拨删除
  735. case 22:
  736. $searchServer = Factory::search('allocate_search');
  737. $searchServer->setIndex('dev_allocate_search');
  738. $a = $searchServer->deleteBase('dev_allocate_search');
  739. print_r($a);
  740. break;
  741. //盘点
  742. case 23:
  743. $mappings = array(
  744. 'mappings' => array(
  745. "stocktaking" => [
  746. "properties" => [
  747. 'id' => ["type" => "integer"],
  748. 'no' => ["type" => "keyword"],
  749. 'warehouseId' => ['type' => 'integer'],
  750. 'operatorId' => ['type' => 'integer'],
  751. 'operatorName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  752. 'auditId' => ['type' => 'integer'],
  753. 'auditName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  754. 'remark' => ['type' => 'text'],
  755. 'deleteStatus' => ['type' => 'integer'],
  756. 'stocktakingTime' => ['type' => 'integer'],
  757. 'saleOutTime' => ['type' => 'integer'],
  758. 'createTime' => ['type' => 'integer'],
  759. 'updateTime' => ['type' => 'integer'],
  760. 'auditStatus' => ["type" => "integer"],
  761. 'auditTime' => ["type" => "integer"],
  762. ]
  763. ]
  764. )
  765. );
  766. $searchServer = Factory::search('stocktaking_search');
  767. $result = $searchServer->createBase('dev_stocktaking_search', $mappings);
  768. if ($result && !isset($result['error'])) {
  769. echo 'dev_stocktaking_search init done.';
  770. return true;
  771. } else {
  772. print_r($result['error']);
  773. return false;
  774. }
  775. break;
  776. //盘点删除
  777. case 24:
  778. $searchServer = Factory::search('stocktaking_search');
  779. $searchServer->setIndex('dev_stocktaking_search');
  780. $a = $searchServer->deleteBase('dev_stocktaking_search');
  781. print_r($a);
  782. break;
  783. //库存流水
  784. case 25:
  785. $mappings = array(
  786. 'mappings' => array(
  787. "inventory_details" => [
  788. "properties" => [
  789. 'id' => ["type" => "integer"],
  790. 'sourceNo' => ["type" => "keyword"],
  791. 'warehouseId' => ['type' => 'integer'],
  792. 'materielId' => ['type' => 'integer'],
  793. 'materielName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  794. 'operatorId' => ['type' => 'integer'],
  795. 'operatorName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  796. 'inventoryNum' => ['type' => 'double'],
  797. 'inventoryChangeNum' => ['type' => 'double'],
  798. 'skuId' => ['type' => 'integer'],
  799. 'source' => ['type' => 'integer'],
  800. 'batch' => ['type' => 'object'],
  801. 'costType' => ['type' => 'integer'],
  802. 'averageCost' => ['type' => 'double'],
  803. 'batchCost' => ['type' => 'double'],
  804. 'actionType' => ["type" => "integer"],
  805. 'createTime' => ['type' => 'integer'],
  806. 'updateTime' => ['type' => 'integer'],
  807. ]
  808. ]
  809. )
  810. );
  811. $searchServer = Factory::search('inventory_details_search');
  812. $result = $searchServer->createBase('online_inventory_details_search', $mappings);
  813. if ($result && !isset($result['error'])) {
  814. echo 'online_inventory_details_search init done.';
  815. return true;
  816. } else {
  817. print_r($result['error']);
  818. return false;
  819. }
  820. break;
  821. //库存流水删除
  822. case 26:
  823. $searchServer = Factory::search('inventory_details_search');
  824. $searchServer->setIndex('online_inventory_details_search');
  825. $a = $searchServer->deleteBase('online_inventory_details_search');
  826. print_r($a);
  827. break;
  828. //客户调价单
  829. case 27:
  830. $mappings = array(
  831. 'mappings' => array(
  832. "customerPriceAdjustmentSheet" => [
  833. "properties" => [
  834. /*订单表信息*/
  835. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  836. 'id' => ["type" => "integer"],//自增id,
  837. 'no' => ["type" => "keyword"],//调价单号,
  838. 'goodsCode' => ['type' => 'keyword'],//商品编号
  839. 'goodsName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//商品名称
  840. 'goodsId' => ['type' => 'integer'],//商品id
  841. 'shopId' => ['type' => 'integer'],//店铺id
  842. 'shopName' => ['type' => 'keyword'],//店铺名称
  843. 'createUserId' => ['type' => 'integer'],//创建人id
  844. 'createUserName' => ['type' => 'keyword'],//创建人姓名
  845. 'effectiveUserName' => ['type' => 'keyword'],//生效人姓名
  846. 'effectiveUserId' => ['type' => 'integer'],//生效人id
  847. 'deleteStatus' => ['type' => 'integer'],//删除状态 4删除 5正常
  848. 'effectiveStatus' => ['type' => 'integer'],//生效状态 1.待审 2审核通过 3未通过 4审核中
  849. 'createTime' => ['type' => 'integer'],//创建时间
  850. 'updateTime' => ['type' => 'integer'],//修改时间
  851. 'customerId' => ['type' => 'integer'],//客户id
  852. 'customerName' => ['type' => 'keyword'],//客户名称
  853. 'customerCode' => ['type' => 'keyword'],//客户编码
  854. 'salePrice' => [
  855. "properties" => [
  856. ]
  857. ],//销售价格
  858. ]
  859. ]
  860. )
  861. );
  862. $searchServer = Factory::search('customerPriceAdjustmentSheet_search');
  863. $result = $searchServer->createBase('online_customer_price_adjustment_sheet_search', $mappings);
  864. if ($result && !isset($result['error'])) {
  865. echo 'online_customer_price_adjustment_sheet_search init done.';
  866. } else {
  867. print_r($result['error']);
  868. return false;
  869. }
  870. break;
  871. //客户调价单删除
  872. case 28:
  873. $searchServer = Factory::search('customerPriceAdjustmentSheet_search');
  874. $searchServer->setIndex('online_customer_price_adjustment_sheet_search');
  875. $a = $searchServer->deleteBase('dev_customer_price_adjustment_sheet_search');
  876. print_r($a);
  877. break;
  878. //销售退货
  879. case 29:
  880. $mappings = array(
  881. 'mappings' => array(
  882. "order_out" => [
  883. "properties" => [
  884. 'id' => ["type" => "integer"],
  885. 'no' => ["type" => "keyword"],
  886. 'sourceId' => ["type" => "integer"],
  887. 'sourceNo' => ["type" => "keyword"],
  888. 'shopId' => ['type' => 'integer'],
  889. 'operatorId' => ['type' => 'integer'],
  890. 'operatorName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  891. 'auditId' => ['type' => 'integer'],
  892. 'auditName' => ['type' => 'text'],
  893. 'remark' => ['type' => 'text'],
  894. 'auditTime' => ['type' => 'integer'],
  895. 'auditStatus' => ['type' => 'integer'],
  896. 'deleteStatus' => ['type' => 'integer'],
  897. 'linkId' => ['type' => 'integer'],
  898. 'goodsId' => ['type' => 'integer'],
  899. 'goodsName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  900. 'goodsCode' => ['type' => 'text'],
  901. 'goodsBasicId' => ['type' => 'integer'],
  902. 'skuId' => ['type' => 'integer'],
  903. 'num' => ['type' => 'double'],
  904. 'costUnitPrice' => ['type' => 'double'],
  905. 'createTime' => ['type' => 'integer'],
  906. 'updateTime' => ['type' => 'integer'],
  907. ]
  908. ]
  909. )
  910. );
  911. $searchServer = Factory::search('order_out_search');
  912. $result = $searchServer->createBase('online_order_out_search', $mappings);
  913. if ($result && !isset($result['error'])) {
  914. echo 'online_order_out_search init done.';
  915. return true;
  916. } else {
  917. print_r($result['error']);
  918. return false;
  919. }
  920. break;
  921. //销售退货删除
  922. case 30:
  923. $searchServer = Factory::search('order_out_search');
  924. $searchServer->setIndex('online_order_out_search');
  925. $a = $searchServer->deleteBase('online_order_out_search');
  926. print_r($a);
  927. break;
  928. //采购明细
  929. case 31:
  930. $mappings = array(
  931. 'mappings' => array(
  932. "purchase_details" => [
  933. "properties" => [
  934. 'id' => ["type" => "integer"],
  935. 'no' => ["type" => "keyword"],
  936. 'shopId' => ["type" => "integer"],
  937. 'shopName' => ["type" => "text", "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  938. 'supplierId' => ['type' => 'integer'],
  939. 'supplierName' => ['type' => 'text'],
  940. 'buyerId' => ['type' => 'integer'],
  941. 'buyerName' => ['type' => 'text'],
  942. 'remark' => ['type' => 'text'],
  943. 'operatorId' => ['type' => 'integer'],
  944. 'operatorName' => ['type' => 'text'],
  945. 'auditId' => ['type' => 'integer'],
  946. 'auditName' => ['type' => 'text'],
  947. 'auditTime' => ['type' => 'integer'],
  948. 'auditStatus' => ['type' => 'integer'],
  949. 'deleteStatus' => ['type' => 'integer'],
  950. 'createTime' => ['type' => 'integer'],
  951. 'updateTime' => ['type' => 'integer'],
  952. 'linkId' => ['type' => 'integer'],
  953. 'goodsId' => ['type' => 'integer'],
  954. 'goodsName' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  955. 'basicGoodsId' => ['type' => 'integer'],
  956. 'skuId' => ['type' => 'integer'],
  957. 'categoryId' => ['type' => 'integer'],
  958. 'categoryName' => ['type' => 'text'],
  959. 'buyerNum' => ['type' => 'double'],
  960. 'buyerUnitPrice' => ['type' => 'double'],
  961. 'subtotalPrice' => ['type' => 'double'],
  962. ]
  963. ]
  964. )
  965. );
  966. $searchServer = Factory::search('purchase_details_search');
  967. $result = $searchServer->createBase('online_purchase_details_search', $mappings);
  968. if ($result && !isset($result['error'])) {
  969. echo 'online_purchase_details_search init done.';
  970. return true;
  971. } else {
  972. print_r($result['error']);
  973. return false;
  974. }
  975. break;
  976. //采购明细删除
  977. case 32:
  978. $searchServer = Factory::search('purchase_details_search');
  979. $searchServer->setIndex('online_purchase_details_search');
  980. $a = $searchServer->deleteBase('online_purchase_details_search');
  981. print_r($a);
  982. break;
  983. //优惠券
  984. case 33:
  985. $mappings = array(
  986. 'mappings' => array(
  987. "coupon" => [
  988. "properties" => [
  989. /*优惠券信息*/
  990. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  991. 'id' => ["type" => "integer"],//自增id,
  992. 'startTime' => ["type" => "keyword"],//优惠券生效开始时间
  993. 'endTime' => ['type' => 'keyword'],//结束时间
  994. 'name' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//优惠券名称
  995. 'couponType' => ['type' => 'integer'],//优惠券类型
  996. 'reducePrice' => ['type' => 'scaled_float', 'scaling_factor' => 100],//满减券-减免金额(面值)
  997. 'minPrice' => ['type' => 'scaled_float', 'scaling_factor' => 100],//最低消费金额 0.00不限金额
  998. 'remark' => ['type' => 'text'],//使用说明
  999. 'grantType' => ['type' => 'integer'],//发放方式(10主动领取 20定向发放 30注册领取 40在线支付赠送)
  1000. 'totalNum' => ['type' => 'integer'],//发放总数量(-1为不限制)
  1001. 'allowNum' => ['type' => 'integer'],//每人限制领取数量(-1为不限制)
  1002. 'customerSourceId' => ['type' => 'text'],//领取范围
  1003. 'mustCondition' => ['type' => 'scaled_float', 'scaling_factor' => 100],//(40在线支付赠送)-满X金额发放 0.00所有在线支付不限金额可领取这个优惠券
  1004. 'grantStartTime' => ['type' => 'integer'],//发放开始时间
  1005. 'grantEndTime' => ['type' => 'integer'],//发放结束时间
  1006. 'useShop' => ['type' => 'text'],//使用范围
  1007. 'applyRange' => ['type' => 'integer'],//商品适用范围
  1008. 'categoryCollect' => ['type' => 'text'],//分类集合
  1009. 'brandCollect' => ['type' => 'text'],//品牌集合
  1010. 'receiveNum' => ['type' => 'integer'],//已领取数量
  1011. 'deleteStatus' => ['type' => 'integer'],//删除状态
  1012. 'auditStatus' => ['type' => 'integer'],
  1013. 'createTime' => ['type' => 'integer'],
  1014. 'updateTime' => ['type' => 'integer'],
  1015. ]
  1016. ]
  1017. )
  1018. );
  1019. $searchServer = Factory::search('coupon_search');
  1020. $result = $searchServer->createBase('dev_coupon_search', $mappings);
  1021. if ($result && !isset($result['error'])) {
  1022. echo 'dev_coupon_search init done.';
  1023. } else {
  1024. print_r($result['error']);
  1025. return false;
  1026. }
  1027. break;
  1028. //删除优惠券
  1029. case 34:
  1030. $searchServer = Factory::search('coupon_search');
  1031. $searchServer->setIndex('dev_coupon_search');
  1032. $a = $searchServer->deleteBase('dev_coupon_search');
  1033. print_r($a);
  1034. break;
  1035. //优惠券记录
  1036. case 35:
  1037. $mappings = array(
  1038. 'mappings' => array(
  1039. "user_coupon" => [
  1040. "properties" => [
  1041. /*优惠券信息*/
  1042. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  1043. 'id' => ["type" => "integer"],//自增id,
  1044. 'couponId' => ["type" => "integer"],//优惠券id
  1045. 'name' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//优惠券名称
  1046. 'remark' => ['type' => 'text'],//使用说明
  1047. 'couponType' => ['type' => 'integer'],//优惠券类型
  1048. 'reducePrice' => ['type' => 'scaled_float', 'scaling_factor' => 100],//满减券-减免金额(面值)
  1049. 'minPrice' => ['type' => 'scaled_float', 'scaling_factor' => 100],//最低消费金额 0.00不限金额
  1050. 'startTime' => ["type" => "keyword"],//优惠券生效开始时间,
  1051. 'endTime' => ['type' => 'keyword'],//结束时间
  1052. 'applyRange' => ['type' => 'integer'],//商品适用范围
  1053. 'categoryCollect' => ['type' => 'text'],//分类集合
  1054. 'brandCollect' => ['type' => 'text'],//品牌集合
  1055. 'isExpire' => ['type' => 'integer'],//是否过期 4未过期 5已过期
  1056. 'isUse' => ['type' => 'integer'],//是否使用 4未过期 5已过期
  1057. 'useTime' => ['type' => 'integer'],//使用时间
  1058. 'userId' => ['type' => 'integer'],//用户id
  1059. 'customerId' => ['type' => 'integer'],//客户id
  1060. 'shopId' => ['type' => 'integer'],//店铺id
  1061. 'useShop' => ['type' => 'text'],//使用范围
  1062. 'source' => ['type' => 'integer'],//优惠券来源(10主动领取 20定向发放 30注册领取 40在线支付赠送)
  1063. 'createTime' => ['type' => 'integer'],//创建时间
  1064. 'updateTime' => ['type' => 'integer'],//更新时间
  1065. 'orderNo' => ['type' => 'text'],//使用单号
  1066. 'orderId' => ['type' => 'integer'],//订单id
  1067. ]
  1068. ]
  1069. )
  1070. );
  1071. $searchServer = Factory::search('user_coupon_search');
  1072. $result = $searchServer->createBase('online_user_coupon_search', $mappings);
  1073. if ($result && !isset($result['error'])) {
  1074. echo 'online_user_coupon_search init done.';
  1075. } else {
  1076. print_r($result['error']);
  1077. return false;
  1078. }
  1079. break;
  1080. //删除优惠券记录
  1081. case 36:
  1082. $searchServer = Factory::search('user_coupon_search');
  1083. $searchServer->setIndex('online_user_coupon_search');
  1084. $a = $searchServer->deleteBase('online_user_coupon_search');
  1085. print_r($a);
  1086. break;
  1087. //促销活动
  1088. case 37:
  1089. $mappings = array(
  1090. 'mappings' => array(
  1091. "activity" => [
  1092. "properties" => [
  1093. /*促销活动信息*/
  1094. 'enterpriseId' => ['type' => 'integer'],//enterpriseId,
  1095. 'id' => ["type" => "integer"],//自增id,
  1096. 'activityType' => ["type" => "integer"],//活动类型
  1097. 'title' => ['type' => 'text', "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],//名称
  1098. 'remark' => ['type' => 'text'],//客户沟通
  1099. 'startTime' => ["type" => "integer"],//活动开始时间,
  1100. 'endTime' => ['type' => 'integer'],//活动结束时间
  1101. 'enableStatus' => ["type" => "integer"],
  1102. 'images' => ["type" => "text"],//活动图
  1103. 'useShop' => ['type' => 'text'],//使用范围
  1104. 'customerRange' => ['type' => 'integer'],//客户范围
  1105. 'customerSourceId' => ['type' => 'text'],//客户id 1,2
  1106. 'sort' => ['type' => 'integer'],
  1107. 'describe' => ['type' => 'text'],
  1108. 'createTime' => ['type' => 'integer'],
  1109. 'updateTime' => ['type' => 'integer'],
  1110. 'isEnd' => ['type' => 'integer'],
  1111. 'deleteStatus' => ['type' => 'integer'],
  1112. 'auditStatus' => ['type' => 'integer'],
  1113. ]
  1114. ]
  1115. )
  1116. );
  1117. $searchServer = Factory::search('activity_search');
  1118. $result = $searchServer->createBase('online_activity_search', $mappings);
  1119. if ($result && !isset($result['error'])) {
  1120. echo 'online_activity_search init done.';
  1121. } else {
  1122. print_r($result['error']);
  1123. return false;
  1124. }
  1125. break;
  1126. //促销活动删除
  1127. case 38:
  1128. $searchServer = Factory::search('activity_search');
  1129. $searchServer->setIndex('online_activity_search');
  1130. $a = $searchServer->deleteBase('online_activity_search');
  1131. print_r($a);
  1132. break;
  1133. //批次
  1134. case 39:
  1135. $mappings = array(
  1136. 'mappings' => array(
  1137. "inventory_batch" => [
  1138. "properties" => [
  1139. 'id' => ["type" => "integer"],
  1140. 'enterpriseId' => ['type' => 'integer'],
  1141. 'warehouseId' => ["type" => "integer"],
  1142. 'batchNo' => ["type" => "keyword"],
  1143. 'originId' => ["type" => "integer"],
  1144. 'originNo' => ["type" => "keyword"],
  1145. 'sourceNo' => ["type" => "keyword"],
  1146. 'materielId' => ["type" => "integer"],
  1147. 'materielCode' => ["type" => "keyword"],
  1148. 'materielName' => ["type" => "text", "analyzer" => "ik_max_word", "search_analyzer" => "ik_max_word"],
  1149. 'skuId' => ["type" => "integer"],
  1150. 'num' => ['type' => 'double'],
  1151. 'averageCost' => ['type' => 'double'],
  1152. 'batchCost' => ['type' => 'double'],
  1153. 'productionData' => ["type" => "integer"],
  1154. 'batchStatus' => ["type" => "integer"],
  1155. 'createTime' => ["type" => "integer"],
  1156. 'updateTime' => ["type" => "integer"],
  1157. ]
  1158. ]
  1159. )
  1160. );
  1161. $searchServer = Factory::search('inventory_batch_search');
  1162. $result = $searchServer->createBase('online_inventory_batch_search', $mappings);
  1163. if ($result && !isset($result['error'])) {
  1164. echo 'online_inventory_batch_search init done.';
  1165. return true;
  1166. } else {
  1167. print_r($result['error']);
  1168. return false;
  1169. }
  1170. break;
  1171. //批次删除
  1172. case 40:
  1173. $searchServer = Factory::search('inventory_batch_search');
  1174. $searchServer->setIndex('online_inventory_batch_search');
  1175. $a = $searchServer->deleteBase('online_inventory_batch_search');
  1176. print_r($a);
  1177. break;
  1178. //添加登录日志索引库
  1179. case 41:
  1180. //创建映射
  1181. $mappings = array(
  1182. 'mappings' => array(
  1183. "_default_" => [
  1184. "properties" => [
  1185. 'id' => ["type" => "integer"],
  1186. 'name' => ['type' => 'keyword'],//联系电话
  1187. ]
  1188. ]
  1189. )
  1190. );
  1191. $searchServer = Factory::search('test');
  1192. $result = $searchServer->createBase('test', $mappings);
  1193. if ($result && !isset($result['error'])) {
  1194. echo 'test init done.';
  1195. return true;
  1196. } else {
  1197. print_r($result['error']);
  1198. return false;
  1199. }
  1200. break;
  1201. //删除登录日志
  1202. case 42:
  1203. $searchServer = Factory::search('test');
  1204. $searchServer->setIndex('test');
  1205. $a = $searchServer->deleteBase('test');
  1206. print_r($a);
  1207. break;
  1208. }
  1209. }
  1210. public function initSearch()
  1211. {
  1212. $num = $this->request->param('request_id');
  1213. //$search = [2,4,6,8,10,12];
  1214. //$search = [1,3,5,7,9,11];
  1215. $search = [$num];
  1216. foreach ($search as $s) {
  1217. $this->search($s);
  1218. }
  1219. }
  1220. }