瀏覽代碼

旺店通erp

ct 2 周之前
父節點
當前提交
3643a71567

+ 81 - 0
fs-admin/src/main/java/com/fs/his/controller/FsStoreOrderController.java

@@ -4,8 +4,10 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.model.LoginUser;
 import com.fs.common.utils.ParseUtils;
@@ -29,11 +31,14 @@ import com.fs.his.enums.ShipperCodeEnum;
 import com.fs.his.param.FsFollowMsgParam;
 import com.fs.his.param.FsStoreOrderParam;
 import com.fs.his.param.FsStoreOrderSalesParam;
+import com.fs.his.param.FsStoreOrderSetErpPhoneParam;
 import com.fs.his.service.IFsExportTaskService;
 import com.fs.his.service.IFsExpressService;
 import com.fs.his.service.IFsStoreService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.*;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.mapper.SysConfigMapper;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -84,6 +89,9 @@ public class FsStoreOrderController extends BaseController
     @Autowired
     @Qualifier("wdtErpOrderServiceImpl")
     private IErpOrderService wdtOrderService;
+
+    @Autowired
+    SysConfigMapper sysConfigMapper;
     /**
      * 查询订单列表
      */
@@ -471,6 +479,26 @@ public class FsStoreOrderController extends BaseController
         return R.ok();
     }
 
+    @Log(title = "手动推管易", businessType = BusinessType.INSERT)
+    @ApiOperation("批量创建ERP订单")
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
+    @PostMapping(value = "/batchCreateErpOrder")
+    public R batchCreateErpOrder(@RequestBody List<Long> orderIds)
+    {
+        if (orderIds != null && !orderIds.isEmpty()) {
+            orderIds.forEach(orderId->{
+                try {
+                    fsStoreOrderService.createOmsOrder(orderId);
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+
+            });
+        }
+
+        return R.ok();
+    }
+
     @Log(title = "冻结/解冻", businessType = BusinessType.UPDATE)
     @PreAuthorize("@ss.hasPermi('his:storeOrder:editTuiMoney')")
     @GetMapping(value = "/editTuiMoney/{id}")
@@ -576,4 +604,57 @@ public class FsStoreOrderController extends BaseController
     }
 
 
+    /**
+     * 查询erp默认手机号
+     * @return
+     */
+    @GetMapping(value = "/queryErpPhone")
+    public AjaxResult queryErpPhone()
+    {
+        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("erp.phone");
+        List<String> list = new ArrayList<>();
+        if(sysConfig!=null){
+            String configValue = sysConfig.getConfigValue();
+            if(StringUtils.isNotEmpty(configValue)){
+                list = JSON.parseArray(configValue, String.class);
+            }
+        }
+        return AjaxResult.success(list);
+    }
+
+
+    /**
+     * 设置erp默认手机号
+     * @param phoneList
+     * @return
+     */
+    @PostMapping(value = "/saveErpPhone")
+    public AjaxResult saveErpPhone(@RequestBody List<String> phoneList)
+    {
+        //去重
+        phoneList = phoneList.stream().distinct().collect(Collectors.toList());
+        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("erp.phone");
+        sysConfig.setConfigValue(JSON.toJSONString(phoneList));
+        return AjaxResult.success(sysConfigMapper.updateConfig(sysConfig));
+    }
+
+    /**
+     * 批量设置erp手机号
+     */
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:createErpOrder')")
+    @Log(title = "订单", businessType = BusinessType.UPDATE)
+    @PostMapping("/editErpPhone")
+    public AjaxResult editErpPhone(@RequestBody FsStoreOrderSetErpPhoneParam param)
+    {
+        String erpPhone = param.getErpPhone();
+        if (StringUtils.isBlank(erpPhone)) {
+            return AjaxResult.error("请选择手机号");
+        }
+        List<Long> orderIds = param.getOrderIds();
+        if (orderIds  == null || orderIds.isEmpty()){
+            return AjaxResult.success();
+        }
+        return toAjax(fsStoreOrderService.batchUpdateErpByOrderIds(param));
+    }
+
 }

+ 7 - 1
fs-service/src/main/java/com/fs/erp/service/impl/WdtErpOrderServiceImpl.java

@@ -191,7 +191,7 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
             // 单价
             erpWdtOrder.setPrice(fsStoreProduct.getPrice());
             // 状态
-            erpWdtOrder.setStatus(TradeStatus.SHIPPED.getValue());
+            erpWdtOrder.setStatus(TradeStatus.PAID_WAITING_FOR_SHIPMENT.getValue());
             // 退款状态
             erpWdtOrder.setRefundStatus(RefundStatus.NO_REFUND.getValue());
 
@@ -605,6 +605,12 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
             config.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
             ErpWdtTradeQueryResponse tradeQueryResponseDTO = JSON.parseObject(execute, ErpWdtTradeQueryResponse.class);
             if(ObjectUtil.equal(0,tradeQueryResponseDTO.getCode())){
+//                if (tradeQueryResponseDTO.getTrades().isEmpty()){
+//                    //尝试查询原始订单
+//                    map.put("tid",param.getCode());
+//                    execute = client.execute("sales_api_trade_query.php", map);
+//                    ErpWdtTradeInfo2 erpWdtTradeInfo2 = JSON.parseObject(execute, ErpWdtTradeInfo2.class);
+//                }
                 ErpOrderQueryResponse erpOrderQueryResponse = ErpWdtToErpOrderMapper.INSTANCE.toErpOrderQueryResponse(tradeQueryResponseDTO);
                 log.info("查询订单成功: {}", erpOrderQueryResponse);
                 return erpOrderQueryResponse;

+ 1 - 0
fs-service/src/main/java/com/fs/his/domain/FsStoreOrder.java

@@ -264,5 +264,6 @@ public class FsStoreOrder extends BaseEntity
     private Long customerId;
     private Integer source;
     private BigDecimal billPrice;
+    private String erpPhone;
 
 }

+ 58 - 57
fs-service/src/main/java/com/fs/his/mapper/FsStoreOrderMapper.java

@@ -74,63 +74,63 @@ public interface FsStoreOrderMapper
     public int deleteFsStoreOrderByOrderIds(String[] orderIds);
     @Select("select order_id from fs_store_order where status = 3 and delivery_status = 0  and DATE(create_time)<='2024-3-1' ")
     List<Long> selectSyncExpressIds();
-    @Select({"<script> " +
-            "select so.*,st.store_name,us.nick_name,us.phone,d.doctor_name,p.patient_name,p.prescribe_code,c.company_name,cu.nick_name company_user_name " +
-            " FROM fs_store_order so LEFT JOIN fs_store st ON so.store_id =st.store_id " +
-            " LEFT JOIN fs_user us ON us.user_id=so.user_id " +
-            " LEFT JOIN fs_prescribe p ON p.prescribe_id =so.prescribe_id " +
-            " LEFT JOIN fs_doctor d ON so.doctor_id= d.doctor_id  " +
-            " LEFT JOIN company c on c.company_id =so.company_id " +
-            " LEFT JOIN company_user cu on cu.user_id=so.company_user_id  " +
-            " WHERE 1=1 "+
-            "<if test=\"maps.packageSecondName != null and maps.packageSecondName != '' \"> and so.package_second_name like concat('%', #{maps.packageSecondName}, '%')</if>"+
-            "<if test=\"maps.storeId != null \"> and so.store_id = #{maps.storeId}</if>\n" +
-            "<if test=\"maps.orderCode != null  and maps.orderCode != ''\"> and so.order_code = #{maps.orderCode}</if>\n" +
-            "<if test=\"maps.prescribeCode != null  and maps.prescribeCode != ''\"> and p.prescribe_code = #{maps.prescribeCode}</if>\n" +
-            "<if test=\"maps.userName != null  and maps.userName != ''\"> and so.user_name like concat('%', #{maps.userName}, '%')</if>\n" +
-            "<if test=\"maps.userPhone != null  and maps.userPhone != ''\"> and so.user_phone = #{maps.userPhone}</if>\n" +
-            "<if test=\"maps.userId != null  \"> and so.user_id = #{maps.userId}</if>\n" +
-            "<if test=\"maps.isFirst != null  \"> and so.is_first = #{maps.isFirst}</if>\n" +
-            "<if test=\"maps.status != null \"> and so.status = #{maps.status}</if>\n" +
-            "<if test=\"maps.source != null \"> and so.source = #{maps.source}</if>\n" +
-            "<if test=\"maps.deliverySn != null  and maps.deliverySn != ''\"> and so.delivery_sn = #{maps.deliverySn}</if>\n" +
-            "<if test=\"maps.prescribeId != null \"> and so.prescribe_id = #{maps.prescribeId}</if>\n" +
-            "<if test=\"maps.companyUserId != null \"> and so.company_user_id = #{maps.companyUserId}</if>\n" +
-            "<if test=\"maps.sTime != null \">  and DATE(so.create_time) &gt;= DATE(#{maps.sTime})</if>\n" +
-            "<if test=\"maps.eTime != null \">  and DATE(so.create_time) &lt;= DATE(#{maps.eTime})</if>\n" +
-            "<if test=\"maps.paysTime != null \">  and DATE(so.pay_time) &gt;= DATE(#{maps.paysTime})</if>\n" +
-            "<if test=\"maps.payeTime != null \">  and DATE(so.pay_time) &lt;= DATE(#{maps.payeTime})</if>\n" +
-            "<if test=\"maps.orderCreateType != null \"> and so.order_create_type = #{maps.orderCreateType}</if>"+
-            "<if test=\"maps.patientName != null \"> and p.patient_name like concat('%', #{maps.patientName}, '%')</if>"+
-            "<if test=\"maps.doctorName != null \"> and d.doctor_name like concat('%', #{maps.doctorName}, '%')</if>"+
-            "<if test=\"maps.orderType != null \"> and so.order_type = #{maps.orderType}</if>" +
-            "<if test=\"maps.deliverySendsTime != null \">  and DATE(so.delivery_send_time) &gt;= DATE(#{maps.deliverySendsTime})</if>\n" +
-            "<if test=\"maps.deliverySendeTime != null \">  and DATE(so.delivery_send_time) &lt;= DATE(#{maps.deliverySendeTime})</if>\n" +
-            "<if test=\"maps.deliveryImportsTime != null \">  and DATE(so.delivery_import_time) &gt;= DATE(#{maps.deliveryImportsTime})</if>\n" +
-            "<if test=\"maps.deliveryImporteTime != null \">  and DATE(so.delivery_import_time) &lt;= DATE(#{maps.deliveryImporteTime})</if>\n" +
-            "<if test=\"maps.tuisTime != null \">  and DATE(so.tui_money_time) &gt;= DATE(#{maps.tuisTime})</if>\n" +
-            "<if test=\"maps.tuieTime != null \">  and DATE(so.tui_money_time) &lt;= DATE(#{maps.tuieTime})</if>\n" +
-            "<if test=\"maps.companyUserNickName != null and  maps.companyUserNickName !='' \"> and cu.nick_name like concat( #{maps.companyUserNickName}, '%')</if> \n" +
-            "<if test = 'maps.companyId != null  and   maps.companyId != \"-1\" '> " + "and so.company_id =#{maps.companyId} " + "</if>" +
-            "<if test = ' maps.companyId == \"-1\" '> and so.company_id is null </if>" +
-            "<if test = 'maps.deliveryStatus != null    '> and so.delivery_status =#{maps.deliveryStatus} </if>" +
-            "<if test = 'maps.customerId != null    '> and so.customer_id =#{maps.customerId} </if>" +
-            "<if test = 'maps.deliveryPayStatus != null    '> and so.delivery_pay_status =#{maps.deliveryPayStatus} </if>" +
-            "<if test = 'maps.tuiMoneyStatus != null    '> and so.tui_money_status =#{maps.tuiMoneyStatus} </if>" +
-            "<if test = 'maps.deptId != null    '>   AND (so.dept_id = #{maps.deptId} OR so.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) </if>" +
-            "<if test = 'maps.packageName != null and maps.packageName != \"\" '> and so.package_name like concat('%', #{maps.packageName}, '%')</if> " +
-            "<if test = 'maps.payType != null '> and so.pay_type IN <foreach collection=\"maps.payType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
-            "<if test = 'maps.scheduleId != null  and  maps.scheduleId != \"-1\"   '> and so.schedule_id IN <foreach collection=\"maps.scheduleId.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
-            "<if test = 'maps.scheduleId == \"-1\"   '> and so.schedule_id is null </if>" +
-            "<if test = 'maps.orderBuyType != null  and  maps.orderBuyType != \"-1\"   '> and so.order_buy_type IN <foreach collection=\"maps.orderBuyType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
-            "<if test = 'maps.orderBuyType == \"-1\"   '> and so.order_buy_type is null </if>" +
-            "<if test = 'maps.orderChannel == \"-1\"   '> and so.order_channel is null </if>" +
-            "<if test = 'maps.orderChannel != null  and  maps.orderChannel != \"-1\"   '> and so.order_channel IN <foreach collection=\"maps.orderChannel.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
-            "<if test = 'maps.qwSubject == \"-1\"'>and so.qw_subject is null </if>" +
-            "<if test = 'maps.qwSubject != null  and  maps.qwSubject != \"-1\" '> and so.qw_subject IN <foreach collection=\"maps.qwSubject.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
-            " ${maps.params.dataScope} "+
-            " ORDER BY so.order_id desc "+
-            "</script>"})
+//    @Select({"<script> " +
+//            "select so.*,st.store_name,us.nick_name,us.phone,d.doctor_name,p.patient_name,p.prescribe_code,c.company_name,cu.nick_name company_user_name " +
+//            " FROM fs_store_order so LEFT JOIN fs_store st ON so.store_id =st.store_id " +
+//            " LEFT JOIN fs_user us ON us.user_id=so.user_id " +
+//            " LEFT JOIN fs_prescribe p ON p.prescribe_id =so.prescribe_id " +
+//            " LEFT JOIN fs_doctor d ON so.doctor_id= d.doctor_id  " +
+//            " LEFT JOIN company c on c.company_id =so.company_id " +
+//            " LEFT JOIN company_user cu on cu.user_id=so.company_user_id  " +
+//            " WHERE 1=1 "+
+//            "<if test=\"maps.packageSecondName != null and maps.packageSecondName != '' \"> and so.package_second_name like concat('%', #{maps.packageSecondName}, '%')</if>"+
+//            "<if test=\"maps.storeId != null \"> and so.store_id = #{maps.storeId}</if>\n" +
+//            "<if test=\"maps.orderCode != null  and maps.orderCode != ''\"> and so.order_code = #{maps.orderCode}</if>\n" +
+//            "<if test=\"maps.prescribeCode != null  and maps.prescribeCode != ''\"> and p.prescribe_code = #{maps.prescribeCode}</if>\n" +
+//            "<if test=\"maps.userName != null  and maps.userName != ''\"> and so.user_name like concat('%', #{maps.userName}, '%')</if>\n" +
+//            "<if test=\"maps.userPhone != null  and maps.userPhone != ''\"> and so.user_phone = #{maps.userPhone}</if>\n" +
+//            "<if test=\"maps.userId != null  \"> and so.user_id = #{maps.userId}</if>\n" +
+//            "<if test=\"maps.isFirst != null  \"> and so.is_first = #{maps.isFirst}</if>\n" +
+//            "<if test=\"maps.status != null \"> and so.status = #{maps.status}</if>\n" +
+//            "<if test=\"maps.source != null \"> and so.source = #{maps.source}</if>\n" +
+//            "<if test=\"maps.deliverySn != null  and maps.deliverySn != ''\"> and so.delivery_sn = #{maps.deliverySn}</if>\n" +
+//            "<if test=\"maps.prescribeId != null \"> and so.prescribe_id = #{maps.prescribeId}</if>\n" +
+//            "<if test=\"maps.companyUserId != null \"> and so.company_user_id = #{maps.companyUserId}</if>\n" +
+//            "<if test=\"maps.sTime != null \">  and DATE(so.create_time) &gt;= DATE(#{maps.sTime})</if>\n" +
+//            "<if test=\"maps.eTime != null \">  and DATE(so.create_time) &lt;= DATE(#{maps.eTime})</if>\n" +
+//            "<if test=\"maps.paysTime != null \">  and DATE(so.pay_time) &gt;= DATE(#{maps.paysTime})</if>\n" +
+//            "<if test=\"maps.payeTime != null \">  and DATE(so.pay_time) &lt;= DATE(#{maps.payeTime})</if>\n" +
+//            "<if test=\"maps.orderCreateType != null \"> and so.order_create_type = #{maps.orderCreateType}</if>"+
+//            "<if test=\"maps.patientName != null \"> and p.patient_name like concat('%', #{maps.patientName}, '%')</if>"+
+//            "<if test=\"maps.doctorName != null \"> and d.doctor_name like concat('%', #{maps.doctorName}, '%')</if>"+
+//            "<if test=\"maps.orderType != null \"> and so.order_type = #{maps.orderType}</if>" +
+//            "<if test=\"maps.deliverySendsTime != null \">  and DATE(so.delivery_send_time) &gt;= DATE(#{maps.deliverySendsTime})</if>\n" +
+//            "<if test=\"maps.deliverySendeTime != null \">  and DATE(so.delivery_send_time) &lt;= DATE(#{maps.deliverySendeTime})</if>\n" +
+//            "<if test=\"maps.deliveryImportsTime != null \">  and DATE(so.delivery_import_time) &gt;= DATE(#{maps.deliveryImportsTime})</if>\n" +
+//            "<if test=\"maps.deliveryImporteTime != null \">  and DATE(so.delivery_import_time) &lt;= DATE(#{maps.deliveryImporteTime})</if>\n" +
+//            "<if test=\"maps.tuisTime != null \">  and DATE(so.tui_money_time) &gt;= DATE(#{maps.tuisTime})</if>\n" +
+//            "<if test=\"maps.tuieTime != null \">  and DATE(so.tui_money_time) &lt;= DATE(#{maps.tuieTime})</if>\n" +
+//            "<if test=\"maps.companyUserNickName != null and  maps.companyUserNickName !='' \"> and cu.nick_name like concat( #{maps.companyUserNickName}, '%')</if> \n" +
+//            "<if test = 'maps.companyId != null  and   maps.companyId != \"-1\" '> " + "and so.company_id =#{maps.companyId} " + "</if>" +
+//            "<if test = ' maps.companyId == \"-1\" '> and so.company_id is null </if>" +
+//            "<if test = 'maps.deliveryStatus != null    '> and so.delivery_status =#{maps.deliveryStatus} </if>" +
+//            "<if test = 'maps.customerId != null    '> and so.customer_id =#{maps.customerId} </if>" +
+//            "<if test = 'maps.deliveryPayStatus != null    '> and so.delivery_pay_status =#{maps.deliveryPayStatus} </if>" +
+//            "<if test = 'maps.tuiMoneyStatus != null    '> and so.tui_money_status =#{maps.tuiMoneyStatus} </if>" +
+//            "<if test = 'maps.deptId != null    '>   AND (so.dept_id = #{maps.deptId} OR so.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) </if>" +
+//            "<if test = 'maps.packageName != null and maps.packageName != \"\" '> and so.package_name like concat('%', #{maps.packageName}, '%')</if> " +
+//            "<if test = 'maps.payType != null '> and so.pay_type IN <foreach collection=\"maps.payType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
+//            "<if test = 'maps.scheduleId != null  and  maps.scheduleId != \"-1\"   '> and so.schedule_id IN <foreach collection=\"maps.scheduleId.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
+//            "<if test = 'maps.scheduleId == \"-1\"   '> and so.schedule_id is null </if>" +
+//            "<if test = 'maps.orderBuyType != null  and  maps.orderBuyType != \"-1\"   '> and so.order_buy_type IN <foreach collection=\"maps.orderBuyType.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
+//            "<if test = 'maps.orderBuyType == \"-1\"   '> and so.order_buy_type is null </if>" +
+//            "<if test = 'maps.orderChannel == \"-1\"   '> and so.order_channel is null </if>" +
+//            "<if test = 'maps.orderChannel != null  and  maps.orderChannel != \"-1\"   '> and so.order_channel IN <foreach collection=\"maps.orderChannel.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
+//            "<if test = 'maps.qwSubject == \"-1\"'>and so.qw_subject is null </if>" +
+//            "<if test = 'maps.qwSubject != null  and  maps.qwSubject != \"-1\" '> and so.qw_subject IN <foreach collection=\"maps.qwSubject.split(',')\"  item='item' index='index'  open='(' separator=',' close=')'> #{item} </foreach></if>" +
+//            " ${maps.params.dataScope} "+
+//            " ORDER BY so.order_id desc "+
+//            "</script>"})
     List<FsStoreOrderListVO> selectFsStoreOrderListVO(@Param("maps")FsStoreOrderParam fsStoreOrder);
 
     @Select({"<script> " +
@@ -1085,4 +1085,5 @@ public interface FsStoreOrderMapper
     @Select("select * from fs_store_order where  `status`=2 ")
     List<FsStoreOrder> selectWdtOmsOrderdeliveryOp();
 
+    int batchUpdateErpByOrderIds(@Param("maps") FsStoreOrderSetErpPhoneParam param);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/service/IFsStoreOrderService.java

@@ -211,4 +211,6 @@ public interface IFsStoreOrderService
     ErpOrder getErpOrder(FsStoreOrder order) throws ParseException;
 
     Integer selectFsStoreOrderCountByType(Long companyId, long l, int i);
+
+    int batchUpdateErpByOrderIds(FsStoreOrderSetErpPhoneParam param);
 }

+ 65 - 35
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -27,6 +27,7 @@ import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.company.vo.FsStoreOrderStatisticsVO;
 import com.fs.company.vo.FsStoreProductStatisticsVO;
+import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
 import com.fs.erp.domain.*;
@@ -240,6 +241,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     private QwUserServiceImpl qwUserServiceImpl;
     @Autowired
     private IFsStoreProductGroupService storeProductGroupService;
+    @Autowired
+    CloudHostProper cloudHostProper;
 
     /**
      * 查询订单
@@ -1618,7 +1621,6 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                     //旺店通
                     erpOrderService =  wdtOrderService;
                 }
-                //管易作废
                 if(erpOrderService!= null && StringUtils.isNotEmpty(order.getExtendOrderId())){
                     if (!order.getExtendOrderId().equals("HIS")){
                         ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
@@ -1703,34 +1705,35 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 
 
         //物流代收都发 互联网医院顺丰
-        if (order.getPayRemain().compareTo(new BigDecimal(0)) == 0) {
-            //没有物流代收
-            //大于100发发顺丰云配
-            if(order.getPayMoney().compareTo(new BigDecimal(100))>0){
-                //发互联网医院SF.0235488558_241101
-                FsExpress express=expressService.selectFsExpressByOmsCode("SF.0235488558_241101");
-                erpOrder.setExpress_code(express.getOmsCode());
-                order.setDeliveryName(express.getName());
-                order.setDeliveryCode(express.getCode());
-            }else {
-                //发ztpdd
-                FsExpress express=expressService.selectFsExpressByOmsCode("CDYJFYD.400011111705_241230");
-                erpOrder.setExpress_code(express.getOmsCode());
-                order.setDeliveryName(express.getName());
-                order.setDeliveryCode(express.getCode());
+        if (!("金牛明医".equals(cloudHostProper.getCompanyName()))){
+            if (order.getPayRemain().compareTo(new BigDecimal(0)) == 0) {
+                //没有物流代收
+                //大于100发发顺丰云配
+                if(order.getPayMoney().compareTo(new BigDecimal(100))>0){
+                    //发互联网医院SF.0235488558_241101
+                    FsExpress express=expressService.selectFsExpressByOmsCode("SF.0235488558_241101");
+                    erpOrder.setExpress_code(express.getOmsCode());
+                    order.setDeliveryName(express.getName());
+                    order.setDeliveryCode(express.getCode());
+                }else {
+                    //发ztpdd
+                    FsExpress express=expressService.selectFsExpressByOmsCode("CDYJFYD.400011111705_241230");
+                    erpOrder.setExpress_code(express.getOmsCode());
+                    order.setDeliveryName(express.getName());
+                    order.setDeliveryCode(express.getCode());
                 }
-        } else {
-            FsExpress express = new FsExpress();
-            if (order.getCompanyId()!=null){
-                Company company = companyService.selectCompanyById(order.getCompanyId());
-                if (company != null && StringUtils.isNotEmpty(company.getOmsCode())){
-                    express = expressService.selectFsExpressByOmsCode(company.getOmsCode());
+            } else {
+                FsExpress express = new FsExpress();
+                if (order.getCompanyId()!=null){
+                    Company company = companyService.selectCompanyById(order.getCompanyId());
+                    if (company != null && StringUtils.isNotEmpty(company.getOmsCode())){
+                        express = expressService.selectFsExpressByOmsCode(company.getOmsCode());
+                    }else {
+                        express=expressService.selectFsExpressByOmsCode("SF.0235469535");
+                    }
                 }else {
                     express=expressService.selectFsExpressByOmsCode("SF.0235469535");
                 }
-            }else {
-                express=expressService.selectFsExpressByOmsCode("SF.0235469535");
-            }
                 //物流代发互联网医院顺
                 erpOrder.setExpress_code(express.getOmsCode());
                 order.setDeliveryName(express.getName());
@@ -1744,6 +1747,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 erpOrder.setCod(true);
 
             }
+        }
+
 
         erpOrder.setPayments(payments);
         if(order.getCompanyId()!=null){
@@ -1799,11 +1804,21 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         }
         erpOrder.setDetails(details);
         erpOrder.setReceiver_name(order.getUserName().replaceAll("[^\\u4e00-\\u9fa5a-zA-Z0-9]", ""));
-        if (order.getUserPhone().length()>11){
-            String phone = decryptPhone(order.getUserPhone());
+        //2025.6.27 金牛要求erp推送电话可以设置默认 不影响其他推送
+        String phone = null;
+        if (StringUtils.isNotBlank(order.getErpPhone())){
+            phone = order.getErpPhone();
+        } else {
+            if (order.getUserPhone().length()>11){
+                phone = decryptPhone(order.getUserPhone());
+            }else {
+                phone = order.getUserPhone();
+            }
+        }
+        if(phone.length()>11){
+            erpOrder.setReceiver_phone(phone);
+        } else{
             erpOrder.setReceiver_mobile(phone);
-        }else {
-            erpOrder.setReceiver_mobile(order.getUserPhone());
         }
 
         String[] address=order.getUserAddress().split(" ");
@@ -1844,7 +1859,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             //支付成功后 将订单号写入待发货的REDIS中
             redisCache.setCacheObject("delivery"+":"+response.getCode(),order.getOrderCode());
             //写入外部订单号
-            order.setExtendOrderId(response.getCode());
+            if (erpType == 2){
+                order.setExtendOrderId(order.getOrderCode());
+            } else {
+                order.setExtendOrderId(response.getCode());
+            }
             fsStoreOrderMapper.updateFsStoreOrder(order);
         }else {
 //            if (response.getErrorDesc().equals("该订单已创建")){
@@ -3061,7 +3080,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             }
         }
 
-        if(order.getStoreHouseCode().equals("WHSP001")){
+        if("WHSP001".equals(order.getStoreHouseCode())){
             //武汉不备注快递史
             //erpOrder.setSeller_memo(erpOrder.getSeller_memo()+"-"+order.getDeliveryName());
         }
@@ -3128,11 +3147,17 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         }
         erpOrder.setDetails(details);
         erpOrder.setReceiver_name(order.getUserName());
-        if(order.getUserPhone().length()>11){
-            erpOrder.setReceiver_phone(order.getUserPhone());
+        //2025.6.27 金牛要求erp推送电话可以设置默认 不影响其他推送
+        String phone = null;
+        if (StringUtils.isNotBlank(order.getErpPhone())){
+            phone = order.getErpPhone();
+        } else {
+            phone = order.getUserPhone();
         }
-        else{
-            erpOrder.setReceiver_mobile(order.getUserPhone());
+        if(phone.length()>11){
+            erpOrder.setReceiver_phone(phone);
+        } else{
+            erpOrder.setReceiver_mobile(phone);
         }
         String[] address= order.getUserAddress().split(" ");
         erpOrder.setReceiver_province(address[0]);
@@ -3160,6 +3185,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         return fsStoreOrderMapper.selectFsStoreOrderCountByType(companyId,userId,type);
     }
 
+    @Override
+    public int batchUpdateErpByOrderIds(FsStoreOrderSetErpPhoneParam param) {
+        return fsStoreOrderMapper.batchUpdateErpByOrderIds(param);
+    }
+
     public  boolean containsAddress(String companyName) {
         String[] items= {"新疆","西藏","内蒙古","海南"};
         boolean found = false;

+ 3 - 0
fs-service/src/main/java/com/fs/his/vo/FsStoreOrderListVO.java

@@ -60,4 +60,7 @@ public class FsStoreOrderListVO {
     private Integer isFirst;
 
     private String source;
+
+    //erp推送号码
+    private String erpPhone;
 }

+ 7 - 7
fs-service/src/main/resources/application-config-druid-lmjy.yml

@@ -26,12 +26,13 @@ wx:
   mp:
     useRedis: false
     redisConfig:
-      host: 127.0.0.1
+      host: 192.168.0.161
       port: 6379
       timeout: 2000
+      password: Ylrztek250218!3@.
     configs:
-      - appId: wx5d3096e20e4bd8bb # 第一个公众号的appid  //公众号名称:成都九州在线互联网医院
-        secret: 1afa05f0c71beff0d52fb849c62e479a # 公众号的appsecret
+      - appId: wxe0b82a0018449a62 # 第一个公众号的appid  //公众号名称:成都九州在线互联网医院
+        secret: 9d55faa03111d3c352d99f45dd4be3eb # 公众号的appsecret
         token: PPKOdAlCoMO # 接口配置里的Token值
         aesKey: Eswa6VjwtVMCcw03qZy6fWllgrv5aytIA1SZPEU0kU2 # 接口配置里的EncodingAESKey值
 aifabu:  #爱链接
@@ -48,9 +49,8 @@ watch:
   password3: v9xsKuqn_$d2y
 
 fs :
-  commonApi: http://172.27.0.7:8010
-#  commonApi: http://127.0.0.1:8010
-  h5CommonApi: http://119.29.195.254:8010
+  commonApi: http://127.0.0.1:8010
+  h5CommonApi: http://127.0.0.1:8010
 nuonuo:
   key:
   secret:
@@ -68,7 +68,7 @@ cloud_host:
   company_name: 良苗教育
 #看课授权时显示的头像
 headerImg:
-  imgUrl:
+  imgUrl: https://liangmiao.obs.cn-southwest-2.myhuaweicloud.com/fs/20250626/1750922536598.png
 ipad:
   ipadUrl:
 

+ 150 - 0
fs-service/src/main/resources/application-druid-jnmy-test.yml

@@ -0,0 +1,150 @@
+# 数据源配置
+spring:
+    profiles:
+        include: config-druid-jnmy,common
+    # redis 配置
+    redis:
+        # 地址
+        host: 127.0.0.1
+        # 端口,默认为6379
+        port: 6379
+        # 数据库索引
+        database: 0
+        # 密码
+        password:
+        # 连接超时时间
+        timeout: 20s
+        lettuce:
+            pool:
+                # 连接池中的最小空闲连接
+                min-idle: 0
+                # 连接池中的最大空闲连接
+                max-idle: 8
+                # 连接池的最大数据库连接数
+                max-active: 8
+                # #连接池最大阻塞等待时间(使用负值表示没有限制)
+                max-wait: -1ms
+    datasource:
+        #        clickhouse:
+        #            type: com.alibaba.druid.pool.DruidDataSource
+        #            driverClassName: com.clickhouse.jdbc.ClickHouseDriver
+        #            url: jdbc:clickhouse://cc-2vc8zzo26w0l7m2l6.public.clickhouse.ads.aliyuncs.com/sop?compress=0&use_server_time_zone=true&use_client_time_zone=false&timezone=Asia/Shanghai
+        #            username: rt_2024
+        #            password: Yzx_19860213
+        #            initialSize: 10
+        #            maxActive: 100
+        #            minIdle: 10
+        #            maxWait: 6000
+        mysql:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://120.46.174.121:2345/fs_his?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: Ylrztek250218!3@.
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: false
+                    url:
+                    username:
+                    password:
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+        sop:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://120.46.174.121:2345/sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: Ylrztek250218!3@.
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+rocketmq:
+    name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
+    producer:
+        group: my-producer-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+    consumer:
+        group: test-group
+        access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+        secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey

+ 150 - 0
fs-service/src/main/resources/application-druid-lmjy-test.yml

@@ -0,0 +1,150 @@
+# 数据源配置
+spring:
+    profiles:
+        include: config-druid-lmjy,common
+    # redis 配置
+    redis:
+        # 地址
+        host: 127.0.0.1
+        # 端口,默认为6379
+        port: 6379
+        # 数据库索引
+        database: 0
+        # 密码
+        password:
+        # 连接超时时间
+        timeout: 20s
+        lettuce:
+            pool:
+                # 连接池中的最小空闲连接
+                min-idle: 0
+                # 连接池中的最大空闲连接
+                max-idle: 8
+                # 连接池的最大数据库连接数
+                max-active: 8
+                # #连接池最大阻塞等待时间(使用负值表示没有限制)
+                max-wait: -1ms
+    datasource:
+        #        clickhouse:
+        #            type: com.alibaba.druid.pool.DruidDataSource
+        #            driverClassName: com.clickhouse.jdbc.ClickHouseDriver
+        #            url: jdbc:clickhouse://cc-2vc8zzo26w0l7m2l6.public.clickhouse.ads.aliyuncs.com/sop?compress=0&use_server_time_zone=true&use_client_time_zone=false&timezone=Asia/Shanghai
+        #            username: rt_2024
+        #            password: Yzx_19860213
+        #            initialSize: 10
+        #            maxActive: 100
+        #            minIdle: 10
+        #            maxWait: 6000
+        mysql:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://1.95.62.166:2345/lm_scrm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: Ylrztek250218!3@.
+                # 从库数据源
+                slave:
+                    # 从数据源开关/默认关闭
+                    enabled: false
+                    url:
+                    username:
+                    password:
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+        sop:
+            type: com.alibaba.druid.pool.DruidDataSource
+            driverClassName: com.mysql.cj.jdbc.Driver
+            druid:
+                # 主库数据源
+                master:
+                    url: jdbc:mysql://1.95.62.166:2345/fs_his_sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                    username: root
+                    password: Ylrztek250218!3@.
+                # 初始连接数
+                initialSize: 5
+                # 最小连接池数量
+                minIdle: 10
+                # 最大连接池数量
+                maxActive: 20
+                # 配置获取连接等待超时的时间
+                maxWait: 60000
+                # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+                timeBetweenEvictionRunsMillis: 60000
+                # 配置一个连接在池中最小生存的时间,单位是毫秒
+                minEvictableIdleTimeMillis: 300000
+                # 配置一个连接在池中最大生存的时间,单位是毫秒
+                maxEvictableIdleTimeMillis: 900000
+                # 配置检测连接是否有效
+                validationQuery: SELECT 1 FROM DUAL
+                testWhileIdle: true
+                testOnBorrow: false
+                testOnReturn: false
+                webStatFilter:
+                    enabled: true
+                statViewServlet:
+                    enabled: true
+                    # 设置白名单,不填则允许所有访问
+                    allow:
+                    url-pattern: /druid/*
+                    # 控制台管理用户名和密码
+                    login-username: fs
+                    login-password: 123456
+                filter:
+                    stat:
+                        enabled: true
+                        # 慢SQL记录
+                        log-slow-sql: true
+                        slow-sql-millis: 1000
+                        merge-sql: true
+                    wall:
+                        config:
+                            multi-statement-allow: true
+rocketmq:
+    name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
+    producer:
+        group: my-producer-group
+        access-key: a # 替换为实际的 accessKey
+        secret-key: k # 替换为实际的 secretKey
+    consumer:
+        group: test-group
+        access-key: l # 替换为实际的 accessKey
+        secret-key: l # 替换为实际的 secretKey

+ 2 - 2
fs-service/src/main/resources/application-druid-lmjy.yml

@@ -5,13 +5,13 @@ spring:
     # redis 配置
     redis:
         # 地址
-        host: 127.0.0.1
+        host: 192.168.0.161
         # 端口,默认为6379
         port: 6379
         # 数据库索引
         database: 0
         # 密码
-        password:
+        password: Ylrztek250218!3@.
         # 连接超时时间
         timeout: 20s
         lettuce:

+ 191 - 1
fs-service/src/main/resources/mapper/his/FsStoreOrderMapper.xml

@@ -89,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="customerId"    column="customer_id"    />
         <result property="source"    column="source"    />
         <result property="billPrice"    column="bill_price"    />
+        <result property="erpPhone"    column="erp_phone"    />
     </resultMap>
 
     <sql id="selectFsStoreOrderVo">
@@ -230,6 +231,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isFirst != null">is_first,</if>
             <if test="customerId != null">customer_id,</if>
             <if test="source != null">source,</if>
+            <if test="erpPhone != null">erp_phone,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="storeId != null">#{storeId},</if>
@@ -314,6 +316,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isFirst != null">#{isFirst},</if>
             <if test="customerId != null">#{customerId},</if>
             <if test="source != null">#{source},</if>
+            <if test="erpPhone != null">#{erpPhone},</if>
          </trim>
     </insert>
 
@@ -403,9 +406,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="customerId != null">customer_id = #{customerId},</if>
             <if test="source != null">source = #{source},</if>
             <if test="billPrice != null">bill_price = #{billPrice},</if>
+            <if test="erpPhone != null and erpPhone != ''">erp_phone = #{erpPhone},</if>
         </trim>
         where order_id = #{orderId}
     </update>
+    <update id="batchUpdateErpByOrderIds">
+        update fs_store_order set erp_phone = #{maps.erpPhone} where
+        order_id in
+        <foreach collection="maps.orderIds" separator="," open="(" close=")" index="index" item="item">
+            #{item}
+        </foreach>
+    </update>
 
     <delete id="deleteFsStoreOrderByOrderId" parameterType="String">
         delete from fs_store_order where order_id = #{orderId}
@@ -526,9 +537,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="maps.isFirst != null ">
             and so.is_first = #{maps.isFirst}
         </if>
-        <if test="maps.status != null">
+        <if test="maps.status != null  and maps.status != 5">
             and so.status = #{maps.status}
         </if>
+        <if test="maps.status == 5">
+            and so.`status`= 2
+            and (
+            so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
+            )
+            and  so.extend_order_id is null
+        </if>
         <if test="maps.deliverySn != null and maps.deliverySn != ''">
             and so.delivery_sn = #{maps.deliverySn}
         </if>
@@ -664,4 +682,176 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
         group by user_id
     </select>
+    <select id="selectFsStoreOrderListVO" resultType="com.fs.his.vo.FsStoreOrderListVO">
+        select so.*,st.store_name,us.nick_name,us.phone,d.doctor_name,p.patient_name,p.prescribe_code,c.company_name,
+               cu.nick_name company_user_name
+        FROM fs_store_order so LEFT JOIN fs_store st ON so.store_id =st.store_id
+        LEFT JOIN fs_user us ON us.user_id=so.user_id
+        LEFT JOIN fs_prescribe p ON p.prescribe_id =so.prescribe_id
+        LEFT JOIN fs_doctor d ON so.doctor_id= d.doctor_id
+        LEFT JOIN company c on c.company_id =so.company_id
+        LEFT JOIN company_user cu on cu.user_id=so.company_user_id
+        <where>
+            <if test="maps.packageSecondName != null and maps.packageSecondName != ''">
+                and so.package_second_name like concat('%', #{maps.packageSecondName}, '%')
+            </if>
+            <if test="maps.storeId != null">
+                and so.store_id = #{maps.storeId}
+            </if>
+            <if test="maps.orderCode != null  and maps.orderCode != ''">
+                and so.order_code = #{maps.orderCode}
+            </if>
+            <if test="maps.prescribeCode != null  and maps.prescribeCode != ''">
+                and p.prescribe_code = #{maps.prescribeCode}
+            </if>
+            <if test="maps.userName != null  and maps.userName != ''">
+                and so.user_name like concat('%', #{maps.userName}, '%')
+            </if>
+            <if test="maps.userPhone != null  and maps.userPhone != ''">
+                and so.user_phone = #{maps.userPhone}
+            </if>
+            <if test="maps.userId != null ">
+                and so.user_id = #{maps.userId}
+            </if>
+            <if test="maps.isFirst != null">
+                and so.is_first = #{maps.isFirst}
+            </if>
+            <if test="maps.status != null and maps.status != 5">
+                and so.status = #{maps.status}
+            </if>
+            <if test="maps.status == 5">
+                and so.`status`= 2
+                and (
+                so.store_id in (select store_id from fs_store where delivery_type=2 or delivery_type=1)
+                )
+                and  so.extend_order_id is null
+            </if>
+            <if test="maps.source != null">
+                and so.source = #{maps.source}
+            </if>
+            <if test="maps.deliverySn != null  and maps.deliverySn != ''">
+                and so.delivery_sn = #{maps.deliverySn}
+            </if>
+            <if test="maps.prescribeId != null">
+                and so.prescribe_id = #{maps.prescribeId}
+            </if>
+            <if test="maps.companyUserId != null">
+                and so.company_user_id = #{maps.companyUserId}
+            </if>
+            <if test="maps.sTime != null">
+                and DATE(so.create_time) &gt;= DATE(#{maps.sTime})
+            </if>
+            <if test="maps.eTime != null">
+                and DATE(so.create_time) &lt;= DATE(#{maps.eTime})
+            </if>
+            <if test="maps.paysTime != null">
+                and DATE(so.pay_time) &gt;= DATE(#{maps.paysTime})
+            </if>
+            <if test="maps.payeTime != null">
+                and DATE(so.pay_time) &lt;= DATE(#{maps.payeTime})
+            </if>
+            <if test="maps.orderCreateType != null">
+                and so.order_create_type = #{maps.orderCreateType}
+            </if>
+            <if test="maps.patientName != null">
+                and p.patient_name like concat('%', #{maps.patientName}, '%')
+            </if>
+            <if test="maps.doctorName != null">
+                and d.doctor_name like concat('%', #{maps.doctorName}, '%')
+            </if>
+            <if test="maps.orderType != null">
+                and so.order_type = #{maps.orderType}
+            </if>
+            <if test="maps.deliverySendsTime != null">
+                and DATE(so.delivery_send_time) &gt;= DATE(#{maps.deliverySendsTime})
+            </if>
+            <if test="maps.deliverySendeTime != null">
+                and DATE(so.delivery_send_time) &lt;= DATE(#{maps.deliverySendeTime})
+            </if>
+            <if test="maps.deliveryImportsTime != null">
+                and DATE(so.delivery_import_time) &gt;= DATE(#{maps.deliveryImportsTime})
+            </if>
+            <if test="maps.deliveryImporteTime != null">
+                and DATE(so.delivery_import_time) &lt;= DATE(#{maps.deliveryImporteTime})
+            </if>
+            <if test="maps.tuisTime != null">
+                and DATE(so.tui_money_time) &gt;= DATE(#{maps.tuisTime})
+            </if>
+            <if test="maps.tuieTime != null">
+                and DATE(so.tui_money_time) &lt;= DATE(#{maps.tuieTime})
+            </if>
+            <if test="maps.companyUserNickName != null and  maps.companyUserNickName !=''">
+                and cu.nick_name like concat( #{maps.companyUserNickName}, '%')
+            </if>
+            <if test="maps.companyId != null and  maps.companyId != -1">
+                " + "and so.company_id =#{maps.companyId} " + "
+            </if>
+            <if test="maps.companyId == -1">
+                and so.company_id is null
+            </if>
+            <if test="maps.deliveryStatus != null">
+                and so.delivery_status =#{maps.deliveryStatus}
+            </if>
+            <if test="maps.customerId != null">
+                and so.customer_id =#{maps.customerId}
+            </if>
+            <if test="maps.deliveryPayStatus != null">
+                and so.delivery_pay_status =#{maps.deliveryPayStatus}
+            </if>
+            <if test="maps.tuiMoneyStatus != null">
+                and so.tui_money_status =#{maps.tuiMoneyStatus}
+            </if>
+            <if test="maps.deptId != null">
+                AND (so.dept_id = #{maps.deptId} OR so.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
+            </if>
+            <if test="maps.packageName != null and maps.packageName != ''">
+                and so.package_name like concat('%', #{maps.packageName}, '%')
+            </if>
+            <if test="maps.payType != null">
+                and so.pay_type IN
+                <foreach collection="maps.payType.split(',')" item="item" index="index" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="maps.scheduleId != null  and  maps.scheduleId != -1">
+                and so.schedule_id IN
+                <foreach collection="maps.scheduleId.split(',')" item="item" index="index" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="maps.scheduleId == -1">
+                and so.schedule_id is null
+            </if>
+            <if test="maps.orderBuyType != null and maps.orderBuyType != -1">
+                and so.order_buy_type IN
+                <foreach collection="maps.orderBuyType.split(',')" item="item" index="index" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="maps.orderBuyType == -1">
+                and so.order_buy_type is null
+            </if>
+            <if test="maps.orderChannel == -1">
+                and so.order_channel is null
+            </if>
+            <if test="maps.orderChannel != null and maps.orderChannel != -1">
+                and so.order_channel IN
+                <foreach collection="maps.orderChannel.split(',')" item="item" index="index" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="maps.qwSubject == -1">
+                and so.qw_subject is null
+            </if>
+            <if test="maps.qwSubject != null and maps.qwSubject != -1">
+                and so.qw_subject IN
+                <foreach collection="maps.qwSubject.split(',')" item="item" index="index" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+
+        </where>
+        ${maps.params.dataScope}
+        ORDER BY so.order_id desc
+    </select>
 </mapper>