Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

jlutt@163.com 2 rokov pred
rodič
commit
e4901f9d0b

+ 68 - 4
conf/esTemplate/businessorder.json

@@ -6,11 +6,43 @@
       },
       "orderName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "orderCode": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "orderStatus": {
         "type": "integer"
@@ -24,7 +56,23 @@
       },
       "incomePlatformOrderCode": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "incomePlatformOrderTimeLong": {
         "type": "long"
@@ -37,7 +85,23 @@
       },
       "storeName": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "deliverFee": {
         "type": "double"

+ 102 - 7
conf/esTemplate/orderdeliveryinfo.json

@@ -12,35 +12,130 @@
       },
       "deliverProvince": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "deliverCity": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "deliverDistract": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "deliverAddress": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "geoLocationSerial": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "receiveMan": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          },
+          "number": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "number_analyzer"
+          },
+          "letter": {
+            "type": "text",
+            "index": "analyzed",
+            "analyzer": "letter_analyzer"
+          }
+        }
       },
       "contractPhone": {
         "type": "text",
-        "index": "not_analyzed"
+        "analyzer": "index_ansj",
+        "search_analyzer": "query_ansj",
+        "fields": {
+          "raw": {
+            "type": "keyword"
+          }
+        }
       },
       "deliverTimeliness": {
         "type": "integer"
       },
+      "bookingDeliverTimeLong": {
+        "type": "long"
+      },
       "customerInvoiceInfo": {
         "type": "text",
         "index": "not_analyzed"

+ 4 - 3
conf/eskeys.properties

@@ -33,9 +33,6 @@ es.productinfo.index = dydeliver_product_info_
 es.product.image.index = dydeliver_product_image_
 
 es.workprocess.index = dydeliver_workprocess_info_
-#订单索引
-es.printorder.index = dydeliver_printorder_
-es.orderstep.index = dydeliver_orderstep_
 
 #施工单
 es.printbill.index = dydeliver_printbill_
@@ -69,4 +66,8 @@ es.storebrand.index = dydeliver_storebrand_
 es.storeinfo.index = dydeliver_storeinfo_
 #门店已开通平台
 es.storeplatform.index = dydeliver_storeplatform_
+#订单
+es.businesorder.index = dydeliver_businessorder_
+#订单脚印
+es.orderstep.index = dydeliver_orderstep_
 

+ 27 - 0
conf/script/1000/init/Init_16_BusinessOrder.groovy

@@ -0,0 +1,27 @@
+import com.dderp.business.dao.OrderDao
+import com.dderp.common.api.SupplierInitService
+import com.dderp.common.datas.ESKeys
+import com.dySweetFishPlugin.elasticsearch.ESClient
+import com.dySweetFishPlugin.redis.RedisService
+import com.sweetfish.convert.json.JsonConvert
+import com.sweetfish.util.Utility
+import org.apache.logging.log4j.Logger
+
+static def createRunnable(ESClient esClient, RedisService redisService, SupplierInitService supplierService,
+                          OrderDao orderDao, Logger logger, JsonConvert jsonConvert, String dataSourceId, long supplierCode) {
+    return {
+        esClient.checkIndexEx(supplierService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_BUSINESS_ORDER_INDEX, 0),
+                ESKeys.INDEX_CONFIG,
+                Utility.ofMap(ESKeys.ES_DELIVER_BUSINESS_ORDER_TYPE, "businessorder.json",
+                        ESKeys.ES_DELIVER_ORDER_DELIVERY_INFO_TYPE, "orderdeliveryinfo.json",
+                        ESKeys.ES_DELIVER_ORDER_FINANCES_TYPE, "orderfinances.json",
+                        ESKeys.ES_DELIVER_ORDER_DETAIL_ITEM_TYPE, "orderdetailitem.json"))
+
+        esClient.checkIndexEx(supplierService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_ORDER_STEP_INDEX, 0),
+                ESKeys.INDEX_CONFIG,
+                Utility.ofMap(ESKeys.ES_DELIVER_ORDER_STEP_TYPE, "orderStep.json"))
+
+    } as Runnable
+}
+
+createRunnable(esClient, redisService, supplierService, orderDao, logger, jsonConvert, dataSourceId, supplierCode)

+ 138 - 10
conf/script/1000/orderApi/BE_Order_CreateOrder_Douyin.groovy

@@ -1,17 +1,35 @@
+import com.dderp.business.dao.OrderDao
 import com.dderp.common.api.BusinessExecutor
 import com.dderp.common.api.StoreService
+import com.dderp.common.api.SupplierInitService
+import com.dderp.common.api.flycat.OrderStepService
 import com.dderp.common.datas.BusinessOrderStatus
 import com.dderp.common.datas.ERPModule
+import com.dderp.common.datas.ESKeys
+import com.dderp.common.datas.business.PlatformType
 import com.dderp.common.entity.base.ProcessStringItem
+import com.dderp.common.entity.geo.GeoPoiLocation
 import com.dderp.common.entity.order.BusinessOrder
 import com.dderp.common.entity.order.OrderDeliveryInfo
+import com.dderp.common.entity.order.OrderDetailItem
 import com.dderp.common.entity.order.OrderFinances
+import com.dderp.common.entity.order.OrderStep
+import com.dderp.common.entity.site.ERPTokenUser
+import com.dderp.common.entity.store.StorePlatform
+import com.dderp.common.entity.store.ViewStoreInfo
+import com.dySweetFishPlugin.elasticsearch.ESClient
 import com.dySweetFishPlugin.sql.TableIdService
+import com.dySweetFishPlugin.sql.dao.TunaService
 import com.sweetfish.convert.json.JsonConvert
 import com.sweetfish.service.RetResult
 import groovy.json.JsonSlurper
 import org.apache.logging.log4j.LogManager
 import org.apache.logging.log4j.Logger
+import org.elasticsearch.action.bulk.BulkRequestBuilder
+import org.elasticsearch.action.bulk.BulkResponse
+import org.elasticsearch.action.index.IndexRequestBuilder
+import org.elasticsearch.action.support.WriteRequest
+import org.elasticsearch.common.xcontent.XContentType
 
 import javax.annotation.Resource
 import java.math.RoundingMode
@@ -32,6 +50,20 @@ class BE_Order_CreateOrder_Douyin implements BusinessExecutor<ProcessStringItem,
     @Resource
     private StoreService storeService
 
+    @Resource
+    private ESClient esClient
+
+    @Resource
+    private SupplierInitService supplierInitService
+
+    @Resource
+    private OrderStepService orderStepService
+
+    @Resource
+    private TunaService tunaService
+
+    private OrderDao orderDao
+
     @Override
     String scriptName() {
         return "抖音来客创建订单"
@@ -42,11 +74,13 @@ class BE_Order_CreateOrder_Douyin implements BusinessExecutor<ProcessStringItem,
         return ERPModule.ORDER_API
     }
 
+
     RetResult<BusinessOrder> execute(ProcessStringItem source) {
         //秒级时间戳,groovy里面不让用system
         long currentTime = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))
         String dataSourceId = source.dataSourceId
         long supplierCode = source.supplierCode
+        ERPTokenUser currentUser = source.currentUser
 
         def jsonSlurper = new JsonSlurper()
         def invokeOrder = jsonSlurper.parseText(source.itemValue)
@@ -56,10 +90,10 @@ class BE_Order_CreateOrder_Douyin implements BusinessExecutor<ProcessStringItem,
         businessOrder.setOrderName(invokeOrder["merchant"]["account_name"] as String)
         businessOrder.setOrderCode(tableIdService.getTableCodeMulti("deBusinessOrder.code", dataSourceId, String.valueOf(supplierCode)))
         businessOrder.setOrderStatus(BusinessOrderStatus.init.value)
-        //todo 商户平台需求一个绑定逻辑,用以判断该平台适用于哪一个脚本
-//        storeService.getStorePlatformByInvokeInfo(invokeOrder["poi"]["poi_id"] )
-        //businessOrder.setIncomePlatformId(0)
-        //businessOrder.setIncomePlatformName("")
+        StorePlatform storePlatform = storeService.getStorePlatformByInvokeInfo(invokeOrder["poi"]["poi_id"] as String,
+                "DYLK", PlatformType.order.value, supplierCode)
+        businessOrder.setIncomePlatformId(storePlatform.id)
+        businessOrder.setIncomePlatformName(storePlatform.platformName)
         businessOrder.setIncomePlatformOrderCode(invokeOrder["order"]["order_id"] as String)
         businessOrder.setIncomePlatformOrderTimeLong(invokeOrder["order"]["pay_time"] as long * 1000)//抖音传过来的时间戳单位是秒
         businessOrder.setIncomePlatformOrderTime(new Date(businessOrder.incomePlatformOrderTimeLong))
@@ -67,14 +101,15 @@ class BE_Order_CreateOrder_Douyin implements BusinessExecutor<ProcessStringItem,
         long suggestTimeLong = (invokeOrder["order"]["sys_expect_time"] as String).split("-")[0] as long
         businessOrder.setSuggestDeliverTimeLong(suggestTimeLong * 1000)
         businessOrder.setSuggestDeliverTime(new Date(businessOrder.suggestDeliverTimeLong))
-        //todo 商户id同上
-        //businessOrder.setIdStore(0)
-        //businessOrder.setStoreName("")
+        ViewStoreInfo viewStoreInfo = storeService.getViewStoreInfo(storePlatform.idStore, supplierCode, false, false, false);
+        businessOrder.setIdStore(viewStoreInfo.storeInfo.id)
+        businessOrder.setStoreName(viewStoreInfo.storeInfo.storeName)
         BigDecimal deliverFee = new BigDecimal((invokeOrder["amount_info"]["freight_pay_amount"] as int) / 100).setScale(2, RoundingMode.CEILING)
         businessOrder.setDeliverFee(deliverFee)
         String address = "[" + invokeOrder["receiver_info"]["city"] + "]" + invokeOrder["receiver_info"]["province"] +
                 invokeOrder["receiver_info"]["city"] +
                 invokeOrder["receiver_info"]["district"] +
+                invokeOrder["receiver_info"]["town"] +
                 invokeOrder["receiver_info"]["location_address"] +
                 invokeOrder["receiver_info"]["location_name"] + "-" +
                 invokeOrder["receiver_info"]["receiver_name"]
@@ -93,8 +128,101 @@ class BE_Order_CreateOrder_Douyin implements BusinessExecutor<ProcessStringItem,
 
         //订单配送类信息
         OrderDeliveryInfo orderDeliveryInfo = new OrderDeliveryInfo()
-
-
-        return null;
+        orderDeliveryInfo.setId(tableIdService.getTableIdMulti("deOrderDeliveryInfo.id", 1, dataSourceId, String.valueOf(supplierCode)))
+        orderDeliveryInfo.setIdOrder(businessOrder.id)
+        orderDeliveryInfo.setDeliverProvince(invokeOrder["receiver_info"]["province"] as String)
+        orderDeliveryInfo.setDeliverCity(invokeOrder["receiver_info"]["city"] as String)
+        orderDeliveryInfo.setDeliverDistract(invokeOrder["receiver_info"]["district"] as String)
+        orderDeliveryInfo.setDeliverAddress(invokeOrder["receiver_info"]["location_address"] as String)
+        orderDeliveryInfo.setGeoPoiLocation(new GeoPoiLocation(invokeOrder["receiver_info"]["lng"] as double, invokeOrder["receiver_info"]["lat"] as double))
+        orderDeliveryInfo.setReceiveMan(invokeOrder["receiver_info"]["receiver_name"] as String)
+        orderDeliveryInfo.setContractPhone(invokeOrder["receiver_info"]["secret_number"] as String + "(" + invokeOrder["receiver_info"]["receiver_phone"] as String + ")")
+        orderDeliveryInfo.setDeliverTimeliness(invokeOrder["order"]["is_book"] as int - 1) //抖音1表示即时单,2表示预订单
+        orderDeliveryInfo.setBookingDeliverTimeLong(suggestTimeLong * 1000)
+        orderDeliveryInfo.setBookingDeliverTime(new Date(orderDeliveryInfo.bookingDeliverTimeLong))
+        orderDeliveryInfo.setCustomerMemo(invokeOrder["order"]["remark"] as String)
+
+        businessOrder.setOrderDeliveryInfo(orderDeliveryInfo)
+
+        //订单明细详情
+        List<OrderDetailItem> itemList = new ArrayList<>()
+        long itemId = tableIdService.getTableIdMulti("deOrderDetailItem.id", (invokeOrder["products"] as ArrayList).size(),
+                dataSourceId, String.valueOf(supplierCode))
+        (invokeOrder["products"] as ArrayList).each {
+            OrderDetailItem item = new OrderDetailItem()
+            item.setId(itemId)
+            item.setIdOrder(businessOrder.id)
+            item.setItemName(it["product_name"] as String)
+            item.setItemCount(it["num"] as int)
+            item.setItemMoney(it["origin_amount"] as BigDecimal)
+
+            itemList.add(item)
+        }
+
+        businessOrder.setDetailItemList(itemList)
+
+        OrderStep orderStep = orderStepService.parseOrderStep(businessOrder.id, 0, "抖音来客顾客完成下单,平台接单完成", "DYLK", currentUser)
+
+        //持久化
+        //订单主表
+        BulkRequestBuilder bulkRequest = esClient.getClient().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
+        IndexRequestBuilder orderRequest = esClient.getClient()
+                .prepareIndex(supplierInitService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_BUSINESS_ORDER_INDEX, 0),
+                        ESKeys.ES_DELIVER_BUSINESS_ORDER_TYPE)
+                .setId(String.valueOf(businessOrder.id))
+                .setSource(jsonConvert.convertTo(businessOrder), XContentType.JSON)
+        bulkRequest.add(orderRequest)
+        //订单金额信息
+        IndexRequestBuilder financesRequest = esClient.getClient()
+                .prepareIndex(supplierInitService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_BUSINESS_ORDER_INDEX, 0),
+                        ESKeys.ES_DELIVER_ORDER_FINANCES_TYPE)
+                .setId(String.valueOf(orderFinances.id))
+                .setParent(String.valueOf(orderFinances.idOrder))
+                .setSource(jsonConvert.convertTo(orderFinances), XContentType.JSON)
+        bulkRequest.add(financesRequest)
+        //订单配送信息
+        IndexRequestBuilder deliveryRequest = esClient.getClient()
+                .prepareIndex(supplierInitService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_BUSINESS_ORDER_INDEX, 0),
+                        ESKeys.ES_DELIVER_ORDER_DELIVERY_INFO_TYPE)
+                .setId(String.valueOf(orderDeliveryInfo.id))
+                .setParent(String.valueOf(orderDeliveryInfo.idOrder))
+                .setSource(jsonConvert.convertTo(orderDeliveryInfo), XContentType.JSON)
+        bulkRequest.add(deliveryRequest)
+        //订单明细详情
+        itemList.each {
+            IndexRequestBuilder itemRequest = esClient.getClient()
+                    .prepareIndex(supplierInitService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_BUSINESS_ORDER_INDEX, 0),
+                            ESKeys.ES_DELIVER_ORDER_DETAIL_ITEM_TYPE)
+                    .setId(String.valueOf(it.id))
+                    .setParent(String.valueOf(it.idOrder))
+                    .setSource(jsonConvert.convertTo(it), XContentType.JSON)
+            bulkRequest.add(itemRequest)
+        }
+        //订单脚印
+        IndexRequestBuilder orderStepRequest = esClient.getClient()
+                .prepareIndex(supplierInitService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_ORDER_STEP_INDEX, 0),
+                        ESKeys.ES_DELIVER_ORDER_STEP_TYPE)
+                .setId(String.valueOf(orderStep.id))
+                .setSource(jsonConvert.convertTo(orderStep), XContentType.JSON)
+        bulkRequest.add(orderStepRequest)
+
+
+        BulkResponse bulkResponse = bulkRequest.get();
+        orderDao = tunaService.generate(OrderDao.class)
+        if (bulkResponse.hasFailures()) {
+            logger.error("新建订单出错[抖音来客]:" + bulkResponse.buildFailureMessage());
+            return RetResult.<BusinessOrder> errorT().retinfo("新建订单出错[抖音来客]:" + businessOrder.orderName);
+        } else {
+            logger.info("新建订单成功[抖音来客]");
+            //写数据库
+            orderDao.addBusinessOrder(businessOrder,
+                    businessOrder.orderFinances,
+                    businessOrder.orderDeliveryInfo,
+                    businessOrder.detailItemList,
+                    [orderStep],
+                    dataSourceId,
+                    String.valueOf(supplierCode))
+            return RetResult.<BusinessOrder> successT().result(businessOrder)
+        }
     }
 }

+ 76 - 0
conf/sqlroot/com/dderp/business/dao/OrderDao.dql

@@ -0,0 +1,76 @@
+-- [queryBusinessOrderList]
+select * from $table$;
+
+-- [queryOrderFinancesList]
+select * from $table$;
+
+-- [queryOrderDeliveryInfoList]
+select * from $table$;
+
+-- [queryOrderDetailItemList]
+select * from $table$;
+
+-- [queryOrderStepList]
+select * from $table$;
+
+
+-- [addBusinessOrder]
+insert into $table$ (id, orderName, orderCode, orderStatus,
+incomePlatformId, incomePlatformName, incomePlatformOrderCode,
+incomePlatformOrderTime, incomePlatformOrderTimeLong, suggestDeliverTime,
+suggestDeliverTimeLong, idStore, storeName,
+deliverFee, deliverDistance, deliverAddressAll,
+outGoingPlatformId, outGoingPlatformName, voidFlag,
+createBy, createTime, createTimeLong,
+updateBy, updateTime, updateTimeLong ) values ( #{id}, #{ordername}, #{ordercode}, #{orderstatus},
+#{incomeplatformid}, #{incomeplatformname}, #{incomeplatformordercode},
+#{incomeplatformordertime}, #{incomeplatformordertimelong}, #{suggestdelivertime},
+#{suggestdelivertimelong}, #{idstore}, #{storename},
+#{deliverfee}, #{deliverdistance}, #{deliveraddressall},
+#{outgoingplatformid}, #{outgoingplatformname}, #{voidflag},
+#{createby}, #{createtime}, #{createtimelong},
+#{updateby}, #{updatetime}, #{updatetimelong} );
+
+-- [addOrderFinances]
+insert into $table$ (id, idOrder, orderMoney, deliverFee,
+orderPlatformSubsidy, storeDiscount, customerPaid,
+platformServiceFee, storeRealCollection, createBy,
+createTime, createTimeLong, updateBy,
+updateTime, updateTimeLong ) values ( #{id}, #{idorder}, #{ordermoney}, #{deliverfee},
+#{orderplatformsubsidy}, #{storediscount}, #{customerpaid},
+#{platformservicefee}, #{storerealcollection}, #{createby},
+#{createtime}, #{createtimelong}, #{updateby},
+#{updatetime}, #{updatetimelong} );
+
+-- [addOrderDeliveryInfo]
+insert into $table$ (id, idOrder, deliverProvince, deliverCity,
+deliverDistract, deliverAddress, geoLocationSerial,
+receiveMan, contractPhone, deliverTimeliness,
+bookingDeliverTime, bookingDeliverTimeLong, customerInvoiceInfo,
+customerMemo, createBy, createTime,
+createTimeLong, updateBy, updateTime,
+updateTimeLong ) values ( #{id}, #{idorder}, #{deliverprovince}, #{delivercity},
+#{deliverdistract}, #{deliveraddress}, #{geolocationserial},
+#{receiveman}, #{contractphone}, #{delivertimeliness},
+#{bookingdelivertime}, #{bookingdelivertimelong}, #{customerinvoiceinfo},
+#{customermemo}, #{createby}, #{createtime},
+#{createtimelong}, #{updateby}, #{updatetime},
+#{updatetimelong} );
+
+-- [addOrderDetailItem]
+insert into $table$ (id, idOrder, itemName, itemPrice,
+itemCount, itemMoney, createBy,
+createTime, createTimeLong, updateBy,
+updateTime, updateTimeLong ) values ( #{id}, #{idorder}, #{itemname}, #{itemprice},
+#{itemcount}, #{itemmoney}, #{createby},
+#{createtime}, #{createtimelong}, #{updateby},
+#{updatetime}, #{updatetimelong} );
+
+-- [addOrderStep]
+insert into $table$ (idOrder, idWorkMan, workMan, workTime,
+workMemo, workExplain, createBy,
+createTime, createTimeLong, updateBy,
+updateTime, updateTimeLong ) values ( #{idorder}, #{idworkman}, #{workman}, #{worktime},
+#{workmemo}, #{workexplain}, #{createby},
+#{createtime}, #{createtimelong}, #{updateby},
+#{updatetime}, #{updatetimelong} );

+ 6 - 3
conf/初始化业务表.sql

@@ -108,8 +108,8 @@ create table eoOrderFinances1000_current(
 -- ----------------------------
 -- Table structure for eoorderstep1000_current
 -- ----------------------------
-DROP TABLE IF EXISTS `eoorderstep1000_current`;
-CREATE TABLE `eoorderstep1000_current`  (
+DROP TABLE IF EXISTS `deorderstep1000_current`;
+CREATE TABLE `deorderstep1000_current`  (
                                             `id` bigint(20) NOT NULL AUTO_INCREMENT,
                                             `idOrder` bigint(20) NULL DEFAULT 0,
                                             `idWorkMan` bigint(20) NULL DEFAULT 0,
@@ -409,4 +409,7 @@ CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = `dbadmin`@`%` SQL SECURITY DEF
 
 
 ALTER TABLE `tbstoreplatform1000`
-    ADD COLUMN `platformStoreId` varchar(255) NULL AFTER `idStore`;
+    ADD COLUMN `platformStoreId` varchar(255) NULL AFTER `idStore`;
+
+ALTER TABLE `deorderdeliveryinfo1000_currnet`
+    ADD COLUMN `bookingDeliverTimeLong` bigint(20) NULL AFTER `bookingDeliverTime`;

+ 50 - 0
ddBusiness/src/main/java/com/dderp/business/dao/OrderDao.java

@@ -0,0 +1,50 @@
+package com.dderp.business.dao;
+
+import com.dderp.common.entity.order.*;
+import com.dderp.common.entity.store.StoreBrand;
+import com.dySweetFishPlugin.sql.dao.*;
+import com.sweetfish.source.PageFlipper;
+import org.rex.RMap;
+
+import java.util.List;
+
+public interface OrderDao extends DaoRepository {
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = OrderTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = OrderDao.class, sql = "queryBusinessOrderList", table = "deBusinessOrder", tableParam = 4, params = {1})
+    List<BusinessOrder> queryBusinessOrderList(RMap params, PageFlipper pageFlipper, @DatabaseShardingBy String dataSourceId, String tableKey);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = OrderTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = OrderDao.class, sql = "queryOrderFinancesList", table = "deOrderFinances", tableParam = 4, params = {1})
+    List<OrderFinances> queryOrderFinancesList(RMap params, PageFlipper pageFlipper, @DatabaseShardingBy String dataSourceId, String tableKey);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = OrderTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = OrderDao.class, sql = "queryOrderDeliveryInfoList", table = "deOrderDeliveryInfo", tableParam = 4, params = {1})
+    List<OrderDeliveryInfo> queryOrderDeliveryInfoList(RMap params, PageFlipper pageFlipper, @DatabaseShardingBy String dataSourceId, String tableKey);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = OrderTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = OrderDao.class, sql = "queryOrderDetailItemList", table = "deOrderDetailItem", tableParam = 4, params = {1})
+    List<OrderDetailItem> queryOrderDetailItemList(RMap params, PageFlipper pageFlipper, @DatabaseShardingBy String dataSourceId, String tableKey);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = OrderTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.QUERY, owait = OperatorWait.AWAIT)
+    @SqlId(clazz = OrderDao.class, sql = "queryOrderStepList", table = "deOrderStep", tableParam = 4, params = {1})
+    List<OrderStep> queryOrderStepList(RMap params, PageFlipper pageFlipper, @DatabaseShardingBy String dataSourceId, String tableKey);
+
+    @Sharding(databaseShardingStrategy = SupplierDataBaseShardingStrategy.class, tableShardingStrategy = OrderTableShardingStrategy.class)
+    @DAOMethod(operator = OperatorType.UPDATE, owait = OperatorWait.ASNYC)
+    @SqlId(clazz = OrderDao.class, sql = "addBusinessOrder", table = "deBusinessOrder", tableParam = 7, params = {1}, sort = 1)
+    @SqlId(clazz = OrderDao.class, sql = "addOrderFinances", table = "deOrderFinances", tableParam = 7, params = {2}, sort = 2)
+    @SqlId(clazz = OrderDao.class, sql = "addOrderDeliveryInfo", table = "deOrderDeliveryInfo", tableParam = 7, params = {3}, sort = 3)
+    @SqlId(clazz = OrderDao.class, sql = "addOrderDetailItem", table = "deOrderDetailItem", tableParam = 7, params = {4}, sort = 4)
+    @SqlId(clazz = OrderDao.class, sql = "addOrderStep", table = "deOrderStep", tableParam = 7, params = {5}, sort = 5)
+    int addBusinessOrder(BusinessOrder businessOrder,
+                         OrderFinances orderFinances,
+                         OrderDeliveryInfo orderDeliveryInfo,
+                         List<OrderDetailItem> items,
+                         List<OrderStep> stepList,
+                         @DatabaseShardingBy String dataSourceId, String tableKey);
+}

+ 4 - 3
ddBusiness/src/main/java/com/dderp/business/service/StoreServiceImpl.java

@@ -363,7 +363,7 @@ public class StoreServiceImpl extends BaseService implements StoreService {
 
                         return qb;
                     }),
-                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_INFO_INDEX, supplierCode),
+                    keysService.getESKey(ESKeys.ES_DELIVER_STORE_PLATFORM_INDEX, supplierCode),
                     (SortBuilderExecutor) null
             );
             storeInfo.setPlatformList(platformList);
@@ -615,12 +615,13 @@ public class StoreServiceImpl extends BaseService implements StoreService {
     }
 
     @Override
-    public StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, long supplierCode) {
+    public StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, int platformType, long supplierCode) {
         return this.getESOneInfo(esClient, jsonConvert, StorePlatform.class,
                 (a) -> {
                     BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_STORE_PLATFORM_TYPE));
                     qb.must(QueryBuilders.termQuery("platformStoreId.raw", platformStoreId))
-                            .must(QueryBuilders.termQuery("platformCode.raw", platformCode));
+                            .must(QueryBuilders.termQuery("platformCode.raw", platformCode))
+                            .must(QueryBuilders.termQuery("platformType", platformType));
 
                     return qb;
                 },

+ 4 - 0
ddBusiness/src/main/java/com/dderp/business/service/SupplierInitImpl.java

@@ -133,6 +133,8 @@ public class SupplierInitImpl extends BaseService implements SupplierInitService
 
     private StoreDao storeDao;
 
+    private OrderDao orderDao;
+
     private ExecutorService initInfoExecutor;
 
     private final List<ScheduledThreadPoolExecutor> scheduleThreadList = new ArrayList<>();
@@ -227,6 +229,7 @@ public class SupplierInitImpl extends BaseService implements SupplierInitService
         docDao = tunaService.generate(DocDao.class);
         platformDao = tunaService.generate(PlatformDao.class);
         storeDao = tunaService.generate(StoreDao.class);
+        orderDao = tunaService.generate(OrderDao.class);
 
         AnyValue environmentValue = config.getAnyValue("environment");
         if (environmentValue != null) {
@@ -356,6 +359,7 @@ public class SupplierInitImpl extends BaseService implements SupplierInitService
                 "docDao", docDao,
                 "platformDao", platformDao,
                 "storeDao", storeDao,
+                "orderDao", orderDao,
                 "jsonConvert", jsonConvert,
                 "dataSourceId", dataSourceId,
                 "supplierCode", supplierCode,

+ 162 - 0
ddBusiness/src/main/java/com/dderp/business/service/flycat/OrderStepServiceImpl.java

@@ -0,0 +1,162 @@
+package com.dderp.business.service.flycat;
+
+import com.dderp.common.api.flycat.OrderSearchService;
+import com.dderp.common.api.flycat.OrderStepService;
+import com.dderp.common.datas.ReadOrderOption;
+import com.dderp.common.entity.order.BusinessOrder;
+import com.dySweetFishPlugin.elasticsearch.ESClient;
+import com.dderp.common.api.SupplierInitService;
+import com.dderp.common.base.BaseService;
+import com.dderp.common.datas.ESKeys;
+import com.dderp.common.entity.order.OrderStep;
+import com.dderp.common.entity.site.ERPTokenUser;
+import com.sweetfish.convert.json.JsonConvert;
+import com.sweetfish.service.Local;
+import com.sweetfish.service.RetResult;
+import com.sweetfish.util.AnyValue;
+import com.sweetfish.util.AutoLoad;
+import com.sweetfish.util.ResourceType;
+import org.apache.commons.lang3.StringUtils;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.search.sort.SortBuilders;
+import org.elasticsearch.search.sort.SortOrder;
+import org.rex.RMap;
+
+import javax.annotation.Resource;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Created by jlutt on 2022-08-23
+ * 订单脚印服务
+ *
+ * @author jlutt
+ */
+@AutoLoad(false)
+@Local
+@ResourceType(OrderStepService.class)
+public class OrderStepServiceImpl extends BaseService implements OrderStepService {
+
+    @Resource
+    private OrderSearchService orderSearchService;
+
+    @Resource
+    ESClient esClient;
+
+    @Resource
+    JsonConvert jsonConvert;
+
+    @Resource
+    SupplierInitService supplierService;
+
+    @Override
+    public void init(AnyValue config) {
+        super.init(config);
+    }
+
+    /**
+     * 订单结构转订单脚印结构
+     *
+     * @param idOrder     订单
+     * @param orderYear   订单年份
+     * @param workMemo    备注
+     * @param workExplain 描述
+     * @param currentUser 当前用户
+     * @return 脚印
+     */
+    @Override
+    public OrderStep parseOrderStep(long idOrder, int orderYear, String workMemo, String workExplain, ERPTokenUser currentUser) {
+        Date now = Date.from(Instant.now());
+        return OrderStep.newBuilder()
+                .idOrder(idOrder)
+                .orderYear(orderYear)
+                .idWorkMan(currentUser.getId())
+                .workMan(currentUser.getUserName())
+                .workMemo(workMemo)
+                .workExplain(workExplain)
+                .workTime(now)
+                .workTimeLong(now.getTime())
+                .build();
+    }
+
+    /**
+     * 用于版工序反馈等需要批量写入订单脚印的场景
+     *
+     * @param printOrders 订单信息列表
+     * @param workMemo    备注
+     * @param workExplain 描述
+     * @param currentUser 当前用户
+     * @return List<OrderStep>
+     */
+    @Override
+    public List<OrderStep> parseOrderSteps(List<BusinessOrder> printOrders, String workMemo, String workExplain, ERPTokenUser currentUser) {
+        Date now = Date.from(Instant.now());
+        return printOrders.stream().map((x) -> OrderStep.newBuilder()
+                .idOrder(x.getId())
+                .orderYear(0)
+                .idWorkMan(currentUser.getId())
+                .workMan(currentUser.getUserName())
+                .workMemo(workMemo)
+                .workExplain(workExplain)
+                .workTime(now)
+                .workTimeLong(now.getTime())
+                .build()).collect(Collectors.toList());
+    }
+
+    @Override
+    public List<OrderStep> parseOrderSteps(String idOrderStr, String workMemo, String workExplain, ERPTokenUser currentUser) {
+        Date now = Date.from(Instant.now());
+        List<OrderStep> orderSteps = new ArrayList<>();
+        if (StringUtils.isBlank(idOrderStr)) return orderSteps;
+
+        return Arrays.stream(idOrderStr.split(",")).map((idOrder) -> OrderStep.newBuilder()
+                .idOrder(Long.parseLong(idOrder))
+                .orderYear(0)
+                .idWorkMan(currentUser.getId())
+                .workMan(currentUser.getUserName())
+                .workMemo(workMemo)
+                .workExplain(workExplain)
+                .workTime(now)
+                .workTimeLong(now.getTime())
+                .build()).collect(Collectors.toList());
+    }
+
+    /**
+     * 获取订单脚印
+     *
+     * @param idOrder     订单id
+     * @param currentUser 当前用户
+     * @return 脚印list
+     */
+    @Override
+    @SuppressWarnings({"unchecked"})
+    public RetResult<List<OrderStep>> getOrderStepList(long idOrder, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
+        if (idOrder < 0) {
+            return RetResult.<List<OrderStep>>errorT().retcode(-1).retinfo("未传入订单id");
+        }
+
+        RetResult<BusinessOrder> orderResult = orderSearchService.getBusinessOrder(idOrder, currentUser, dataSourceId, supplierCode, null);
+        if (!orderResult.isSuccess()) {
+            return RetResult.error().retcode(-1).retinfo("未找到id为" + idOrder + "的订单");
+        }
+        BusinessOrder esOrder = orderResult.getResult();
+        RMap<String, String> collectionData = new RMap<>();
+        collectionData.put("orderCode", esOrder.getOrderCode());
+        collectionData.put("orderName", esOrder.getOrderName());
+
+        List<OrderStep> stepList = searchESList(esClient, jsonConvert,
+                OrderStep.class,
+                null,
+                ((sd) -> QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_ORDER_STEP_TYPE))
+                        .must(QueryBuilders.termQuery("idOrder", idOrder))),
+                null,
+                supplierService.getDateYearESIndex(supplierCode, ESKeys.ES_DELIVER_ORDER_STEP_INDEX, 1),
+                () -> SortBuilders.fieldSort("workTimeLong").order(SortOrder.ASC));
+
+        return RetResult.success().retcode(0).retinfo("success").result(stepList).attachRMap(collectionData);
+    }
+}

+ 0 - 8
ddCommon/src/main/java/com/dderp/common/api/OrderService.java

@@ -1,8 +0,0 @@
-package com.dderp.common.api;
-
-import com.sweetfish.util.AutoLoad;
-
-@AutoLoad(value = false)
-public interface OrderService extends ScriptService{
-
-}

+ 4 - 3
ddCommon/src/main/java/com/dderp/common/api/StoreService.java

@@ -28,14 +28,14 @@ public interface StoreService extends ScriptService {
     //region 门店档案
     List<ViewStoreInfo> queryViewStoreInfo(RMap params, PageFlipper pageFlipper, long supplierCode);
 
-    ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, boolean readInvoice,boolean readEmployee,boolean readPlatform);
+    ViewStoreInfo getViewStoreInfo(long idStore, long supplierCode, boolean readInvoice, boolean readEmployee, boolean readPlatform);
 
     RetResult<StoreInfo> addStoreInfo(StoreInfo storeInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
     /**
      * 获取门店开票信息
      */
-    StoreInvoiceInfo getStoreInvoiceInfo(long idStore,long supplierCode);
+    StoreInvoiceInfo getStoreInvoiceInfo(long idStore, long supplierCode);
 
     RetResult<StoreInvoiceInfo> configStoreInvoiceInfo(StoreInvoiceInfo invoiceInfo, int enableInvoice, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 
@@ -45,12 +45,13 @@ public interface StoreService extends ScriptService {
     //endregion
 
     //region 门店平台
+
     /**
      * 获取已开通平台信息
      */
     StorePlatform getStorePlatformInfo(long id, long supplierCode);
 
-    StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, long supplierCode);
+    StorePlatform getStorePlatformByInvokeInfo(String platformStoreId, String platformCode, int platformType, long supplierCode);
 
     RetResult<StorePlatform> addStorePlatform(StorePlatform storePlatform, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
 

+ 54 - 0
ddCommon/src/main/java/com/dderp/common/api/flycat/OrderStepService.java

@@ -0,0 +1,54 @@
+package com.dderp.common.api.flycat;
+
+import com.dderp.common.api.ScriptService;
+import com.dderp.common.entity.order.BusinessOrder;
+import com.dderp.common.entity.order.OrderStep;
+import com.dderp.common.entity.site.ERPTokenUser;
+import com.sweetfish.service.RetResult;
+import com.sweetfish.util.AutoLoad;
+
+import java.util.List;
+
+/**
+ * Created by jlutt on 2022-08-29
+ * 订单脚印服务
+ *
+ * @author jlutt
+ */
+@AutoLoad(false)
+public interface OrderStepService extends ScriptService {
+
+    /**
+     * 订单结构转订单脚印结构
+     *
+     * @param idOrder     订单
+     * @param orderYear   订单年份
+     * @param workMemo    备注
+     * @param workExplain 描述
+     * @param currentUser 当前用户
+     * @return 脚印
+     */
+    OrderStep parseOrderStep(long idOrder, int orderYear, String workMemo, String workExplain, ERPTokenUser currentUser);
+
+    /**
+     * 用于版工序反馈等需要批量写入订单脚印的场景
+     *
+     * @param businessOrders 订单信息列表
+     * @param workMemo    备注
+     * @param workExplain 描述
+     * @param currentUser 当前用户
+     * @return List<OrderStep>
+     */
+    List<OrderStep> parseOrderSteps(List<BusinessOrder> businessOrders, String workMemo, String workExplain, ERPTokenUser currentUser);
+
+    List<OrderStep> parseOrderSteps(String idOrderStr, String workMemo, String workExplain, ERPTokenUser currentUser);
+
+    /**
+     * 获取订单脚印
+     *
+     * @param idOrder     订单id
+     * @param currentUser 当前用户
+     * @return 脚印list
+     */
+    RetResult<List<OrderStep>> getOrderStepList(long idOrder, ERPTokenUser currentUser, String dataSourceId, long supplierCode);
+}

+ 16 - 1
ddCommon/src/main/java/com/dderp/common/datas/ESKeys.java

@@ -104,7 +104,7 @@ public class ESKeys {
     //订单组版部件
     public static final String ES_ERP_WORK_PART_TYPE = "workpart";
     //订单物料
-    public static  final String ES_ERP_ORDER_MATERIAL_TYPE = "ordermaterial";
+    public static final String ES_ERP_ORDER_MATERIAL_TYPE = "ordermaterial";
     //订单预收款申请
     public static final String ES_ERP_ORDER_PREPAY_TYPE = "orderprepay";
     //订单应收账款
@@ -215,4 +215,19 @@ public class ESKeys {
     public static final String ES_DELIVER_STORE_PLATFORM_TYPE = "info";
     public static final String ES_DELIVER_STORE_PLATFORM_REQUIRE_TYPE = "storeplatformrequire";
     //endregion
+
+
+    //region 订单
+    public static final String ES_DELIVER_BUSINESS_ORDER_INDEX = "es.businesorder.index";
+    public static final String ES_DELIVER_BUSINESS_ORDER_TYPE = "info";
+    public static final String ES_DELIVER_ORDER_DELIVERY_INFO_TYPE = "orderdeliveryinfo";
+    public static final String ES_DELIVER_ORDER_FINANCES_TYPE = "orderfinances";
+    public static final String ES_DELIVER_ORDER_DETAIL_ITEM_TYPE = "orderdetailitem";
+    //endregion
+
+    //region 订单脚印
+    public static final String ES_DELIVER_ORDER_STEP_INDEX = "es.orderstep.index";
+    public static final String ES_DELIVER_ORDER_STEP_TYPE = "info";
+    //endregion
+
 }

+ 12 - 0
ddCommon/src/main/java/com/dderp/common/entity/order/OrderDeliveryInfo.java

@@ -56,6 +56,10 @@ public class OrderDeliveryInfo extends BaseEntity {
     @Comment("预约送达时间")
     private Date bookingDeliverTime;
 
+    @Comment("预约送达时间")
+    @RColumn("bookingdelivertimelong")
+    private long bookingDeliverTimeLong;
+
     @RColumn("customerinvoiceinfo")
     @Comment("客户要求的发票信息")
     private String customerInvoiceInfo;
@@ -175,4 +179,12 @@ public class OrderDeliveryInfo extends BaseEntity {
     public void setGeoLocationSerial(String geoLocationSerial) {
         this.geoLocationSerial = geoLocationSerial;
     }
+
+    public long getBookingDeliverTimeLong() {
+        return bookingDeliverTimeLong;
+    }
+
+    public void setBookingDeliverTimeLong(long bookingDeliverTimeLong) {
+        this.bookingDeliverTimeLong = bookingDeliverTimeLong;
+    }
 }