Browse Source

Merge branch 'openIm' of http://1.14.104.71:10880/root/ylrz_his_scrm_java

# Conflicts:
#	fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java
#	fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
15376779826 1 day ago
parent
commit
8bc127ead1

+ 112 - 8
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -15,6 +15,7 @@ import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.company.vo.QwIpadTotalVo;
 import com.fs.company.vo.RedPacketMoneyVO;
+import com.fs.course.dto.BatchSendCourseAllDTO;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.course.service.IFsCourseWatchLogService;
 import com.fs.course.service.ITencentCloudCosService;
@@ -52,8 +53,10 @@ import com.fs.his.service.*;
 import com.fs.his.service.impl.FsPackageOrderServiceImpl;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsSubOrderResultVO;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.im.dto.*;
 import com.fs.im.service.IImService;
+import com.fs.im.service.OpenIMService;
 import com.fs.qw.domain.QwCompany;
 import com.fs.qw.mapper.QwRestrictionPushRecordMapper;
 import com.fs.qw.service.*;
@@ -68,6 +71,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import java.time.LocalDate;
@@ -170,6 +174,10 @@ public class Task {
     private IQwCompanyService qwCompanyService;
     @Autowired
     private IQwUserService qwUserService;
+    @Autowired
+    private OpenIMService openIMService;
+    @Autowired
+    public RedisTemplate redisTemplate;
 
     @Autowired
     private ICompanyUserService userService;
@@ -620,12 +628,8 @@ public class Task {
         } else if (erpOrderService == wdtOrderService || erpOrderService == dfOrderService || erpOrderService == jSTOrderService) {
             orders = fsStoreOrderMapper.selectWdtOmsOrderdeliveryOp();
         }
-
-
-        for (FsStoreOrder order : orders) {
-
-            ErpOrderQueryRequert request = new ErpOrderQueryRequert();
-
+        for(FsStoreOrder order:orders){
+            ErpOrderQueryRequert request=new ErpOrderQueryRequert();
             request.setCode(order.getExtendOrderId());
             if (erpOrderService != null) {
                 ErpOrderQueryResponse response = erpOrderService.getOrder(request);
@@ -640,20 +644,52 @@ public class Task {
                                         redisCache.deleteObject("delivery" + ":" + order.getExtendOrderId());
                                     }
                                 }
-
                             }
                         }
                     }
                 }
             }
+        }
+    }
 
+    public void deliveryOpScrm()
+    {
+        IErpOrderService erpOrderService = getErpService();
+        List<FsStoreOrderScrm> orders = null;
+        if (erpOrderService == gyOrderService){
+            orders = fsStoreOrderMapper.selectOmsOrderdeliveryOpScrm();
+        } else if (erpOrderService == wdtOrderService || erpOrderService == dfOrderService || erpOrderService == jSTOrderService){
+            orders = fsStoreOrderMapper.selectWdtOmsOrderdeliveryOpScrm();
+        }
+        for(FsStoreOrderScrm order:orders){
+            ErpOrderQueryRequert request=new ErpOrderQueryRequert();
+            request.setCode(order.getExtendOrderId());
+            if (erpOrderService != null){
+                ErpOrderQueryResponse response=erpOrderService.getScrmOrder(request);
+                if (erpOrderService != dfOrderService){
+                    if(response.getOrders()!=null&&response.getOrders().size()>0){
+                        for(ErpOrderQuery orderQuery : response.getOrders()){
+                            if(orderQuery.getDeliverys()!=null&&orderQuery.getDeliverys().size()>0){
+                                for(ErpDeliverys delivery:orderQuery.getDeliverys()){
+                                    if(delivery.getDelivery()&& StringUtils.isNotEmpty(delivery.getMail_no())){
+                                        //更新商订单状态 删除REDIS
+                                        fsStoreOrderService.deliveryOrderScrm(order.getOrderCode(),delivery.getMail_no(),delivery.getExpress_code(),delivery.getExpress_name());
+                                        redisCache.deleteObject("delivery"+":"+order.getExtendOrderId());
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
         }
 
 
     }
 
 
-    public void getOrderDeliveryStatus() {
+    public void getOrderDeliveryStatus()
+    {
         IErpOrderService erpOrderService = getErpService();
         List<FsStoreOrder> orders = null;
         if (erpOrderService != null && erpOrderService == dfOrderService) {
@@ -777,6 +813,7 @@ public class Task {
     }
 
 
+
     @Autowired
     private ICompanyService companyService;
 
@@ -1415,4 +1452,71 @@ public class Task {
         }
         return null;
     }
+
+
+    /**
+     * 定时任务-im会员定时发课,每一分钟执行一次
+     */
+    public void sendOpenImCourse(){
+        String redisKey = "openIm:batchSendMsg:sendCourse";
+        Map<String, BatchSendCourseAllDTO> cacheMap = redisCache.getCacheMap(redisKey);
+        if(cacheMap == null || cacheMap.isEmpty()){
+            logger.info("=====================会员IM定时发课,不存在对应的redisKey==================");
+            return;
+        }
+        List<Map.Entry<String, BatchSendCourseAllDTO>> toSendMap = cacheMap.entrySet().parallelStream().filter((v) -> {
+            String[] split = v.getKey().split(":");
+            long timestamp = Long.parseLong(split[2]);
+            return timestamp < System.currentTimeMillis();
+        }).collect(Collectors.toList());
+
+        if(toSendMap.isEmpty()){
+            logger.info("=====================会员IM定时发课,不存在可执行的发课任务==================");
+            return;
+        }
+        for (Map.Entry<String, BatchSendCourseAllDTO> entry : toSendMap) {
+            //执行发送消息任务
+            BatchSendCourseAllDTO batchSendCourseAllDTO = entry.getValue();
+            openIMService.batchSendCourseTask(batchSendCourseAllDTO.getBatchSendCourseDTO(), batchSendCourseAllDTO.getOpenImBatchMsgDTO(), batchSendCourseAllDTO.getProject(), batchSendCourseAllDTO.getImMsgSendDetailList());
+
+            // 执行结束,删除
+            this.redisTemplate.<String, BatchSendCourseAllDTO>opsForHash().delete(redisKey, entry.getKey());
+
+        }
+
+    }
+
+
+    /**
+     * 定时任务-im 会员催课,每一分钟执行一次
+     */
+    public void urgeOpenImCourse(){
+        String redisKey = "openIm:batchSendMsg:urgeCourse";
+        Map<String, BatchSendCourseAllDTO> cacheMap = redisCache.getCacheMap(redisKey);
+        if(cacheMap == null || cacheMap.isEmpty()){
+            logger.info("===================== 会员-IM发消息催课,不存在对应的redisKey==================");
+            return;
+        }
+        List<Map.Entry<String, BatchSendCourseAllDTO>> toSendMap = cacheMap.entrySet().parallelStream().filter((v) -> {
+            String[] split = v.getKey().split(":");
+            long timestamp = Long.parseLong(split[2]);
+            return timestamp < System.currentTimeMillis();
+        }).collect(Collectors.toList());
+
+        if(toSendMap.isEmpty()){
+            logger.info("===================== 会员-IM发消息催课,不存在可发送的消息==================");
+            return;
+        }
+        for (Map.Entry<String, BatchSendCourseAllDTO> entry : toSendMap) {
+            //执行发送消息任务
+            BatchSendCourseAllDTO batchSendCourseAllDTO = entry.getValue();
+            openIMService.batchUrgeCourseTask(batchSendCourseAllDTO.getOpenImBatchMsgDTO(), batchSendCourseAllDTO.getImMsgSendDetailList());
+
+            // 执行结束,删除
+            this.redisTemplate.<String, BatchSendCourseAllDTO>opsForHash().delete(redisKey, entry.getKey());
+
+        }
+    }
+
+
 }

+ 1 - 1
fs-service/src/main/java/com/fs/course/param/FsCourseWatchLogListParam.java

@@ -65,7 +65,7 @@ public class FsCourseWatchLogListParam implements Serializable {
 
 
     private Long taskId;//任务ID
-    private Long project;//任务ID
+    //private Long project;//任务ID
 
     private List<Long> periodIds;//训练营期ID
 

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/IFsUserCourseService.java

@@ -130,4 +130,6 @@ public interface IFsUserCourseService
     List<FsUserCourseVideoAppletVO.FsUserCourseVideo> selectFsUserCourseVideoAppletByCourseId(Long courseId);
 
     List<FsUserCourseVideoAppletVO> selectFsUserCourseVideoAppletListByCourseId(Long courseId);
+
+    R createAppCourseSortLink(FsCourseLinkCreateParam fsCourseLinkCreateParam);
 }

+ 38 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseServiceImpl.java

@@ -132,6 +132,10 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
     public static final String shortLink = "/courseH5/pages/course/learning?s=";
 
     private static final String userRealLink = "/pages/user/users/becomeVIP?";
+
+    private static final String appRealLink = "/#/pages_course/videovip?course=";
+    public static final String appShortLink = "/#/pages_course/videovip?s=";
+
     /**
      * 查询课程
      *
@@ -715,6 +719,40 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
         return fsUserCourseMapper.selectFsUserCourseVideoAppletListByCourseId(courseId);
     }
 
+    @Override
+    public R createAppCourseSortLink(FsCourseLinkCreateParam param) {
+        String json = configService.selectConfigByKey("course.config");
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        //短链参数
+        String random = generateRandomString();
+
+        //新增链接表信息
+        FsCourseLink link = new FsCourseLink();
+        BeanUtils.copyProperties(param, link);
+        link.setLinkType(0);
+        link.setIsRoom(0);
+        link.setLink(random);
+
+        FsCourseRealLink courseMap = new FsCourseRealLink();
+        BeanUtils.copyProperties(link, courseMap);
+        courseMap.setProjectId(param.getProjectId());
+        String courseJson = JSON.toJSONString(courseMap);
+        link.setRealLink(appRealLink + courseJson);
+
+        link.setCreateTime(new Date());
+
+        //获取过期时间
+        Calendar calendar = getExpireDay(param, config, link.getCreateTime());
+        link.setUpdateTime(calendar.getTime());
+        int i = fsCourseLinkMapper.insertFsCourseLink(link);
+        if (i > 0){
+            String domainName = getDomainName(param.getCompanyUserId(), config);
+            String sortLink = domainName + appShortLink + link.getLink();
+            return R.ok().put("url", sortLink).put("link", random);
+        }
+        return R.error("生成链接失败!");
+    }
+
 
     private Graphics2D initializeGraphics(BufferedImage combined) {
         Graphics2D graphics = combined.createGraphics();

+ 1 - 0
fs-service/src/main/java/com/fs/his/mapper/FsDoctorMapper.java

@@ -220,4 +220,5 @@ public interface FsDoctorMapper
      * 根据医生id集合查询列表
      */
     List<FsDoctorListUVO> getFsDoctorListUVOListByIds(@Param("doctorIds") List<Long> doctorIds);
+    String selectDoctorNameByIds(@Param("doctorIds") String doctorIds);
 }

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

@@ -18,6 +18,7 @@ import com.fs.his.domain.*;
 import com.fs.his.dto.*;
 import com.fs.his.param.*;
 import com.fs.his.vo.*;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -269,4 +270,10 @@ public interface IFsStoreOrderService
      * 查询互联网医院订单金额统计信息
      * */
     FsStoreOrderAmountStatsVo selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto);
+
+    void deliveryOrderScrm(String orderCode, String mailNo, String expressCode, String expressName);
+
+    FsStoreOrderScrm selectFsStoreOrderScrmByOrderCode(String soId);
+
+    FsStoreOrder confirmOrder(FsPackageOrder packageOrder,Long doctorId);
 }

+ 289 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -50,6 +50,7 @@ import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.param.FsStoreOrderRefundByProductParam;
+import com.fs.hisStore.service.IFsStoreOrderLogsScrmService;
 import com.fs.hisapi.domain.ApiResponse;
 import com.fs.hisapi.param.CreateOrderParam;
 import com.fs.hisapi.param.RecipeDetailParam;
@@ -4101,5 +4102,293 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
     public FsStoreOrderAmountStatsVo selectFsStoreOrderAmountStats(FsStoreOrderAmountStatsQueryDto queryDto) {
         return fsStoreOrderMapper.selectFsStoreOrderAmountStats(queryDto);
     }
+    @Autowired
+    FsStoreOrderScrmMapper storeOrderScrmMapper;
+
+
+    @Autowired
+    IFsStoreOrderLogsScrmService iFsStoreOrderLogsScrmService;
+    @Override
+    public void deliveryOrderScrm(String orderCode, String deliveryId, String deliverCode, String deliverName) {
+        FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderScrmByOrderCode(orderCode);
+        if (order != null && order.getStatus() == 1) {
+            FsExpress express = expressService.selectFsExpressByOmsCode(deliverCode);
+            if (express != null) {
+                order.setDeliveryName(deliverName);
+                order.setDeliveryCode(express.getCode());
+            }
+            order.setStatus(2);
+            order.setDeliverySn(deliveryId);
+            order.setDeliverySendTime(DateUtils.getNowDate());
+            storeOrderScrmMapper.updateFsStoreOrder(order);
+            iFsStoreOrderLogsScrmService.create(order.getId(), FsStoreOrderLogEnum.DELIVERY_GOODS.getValue(), FsStoreOrderLogEnum.DELIVERY_GOODS.getDesc());
+            if (order.getCompanyId() != null && order.getCompanyId() > 0) {
+                companyService.subtractCompanyMoneyScrm(order);
+            }
+
+            FsStore store = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
+            //订阅物流回调
+            String lastFourNumber = "";
+            if (order.getDeliveryCode().equals(ShipperCodeEnum.SF.getValue())) {
+                if (store != null && store.getSendPhone() != null) {
+                    lastFourNumber = store.getSendPhone();
+                } else {
+                    lastFourNumber = order.getUserPhone();
+                }
+                if (lastFourNumber.length() == 11) {
+                    lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+                }
+            }
+            expressService.subscribeEspress(order.getOrderCode(), order.getDeliveryCode(), order.getDeliverySn(), lastFourNumber);
+
+
+        }
+
+    }
+
+    @Override
+    public FsStoreOrderScrm selectFsStoreOrderScrmByOrderCode(String soId) {
+        return fsStoreOrderMapper.selectFsStoreOrderScrmByOrderCode(soId);
+    }
+    @Override
+    public FsStoreOrder confirmOrder(FsPackageOrder packageOrder, Long doctorId) {
+
+        FsPackage fsPackage = fsPackageMapper.selectFsPackageByPackageId(packageOrder.getPackageId());
+        JSONArray objects = JSONUtil.parseArray(fsPackage.getProductJson());
+        List<FsPackagePruductDTO> products = JSONUtil.toList(objects, FsPackagePruductDTO.class);
+        Map<String, Object> packageJson = (Map) JSON.parse(packageOrder.getPackageJson());
+        Integer packageSubType = (Integer) packageJson.get("packageSubType");
+        Integer productType = (Integer) packageJson.get("productType");
+        FsStoreOrder order = new FsStoreOrder();
+        Long prescribeId =null;
+        if (productType==1 || packageSubType==2){
+            if (packageOrder.getDoctorId() == null) {
+                Long doctorID = iFsDoctorService.selectFsDoctorDoctorByPackage();
+                packageOrder.setDoctorId(doctorID);
+            }
+            if (packageSubType == 3 ) {
+                inquiryOrderService.createOrderByPackageOrderStatus4(packageOrder);
+            }
+            prescribeId = fsPrescribeService.insertFsPrescribeByPackageOrder(packageOrder);
+            order.setPrescribeId(prescribeId);
+        }
+
+
+        List<FsStoreOrderItem> items = new ArrayList<>();
+        log.info("套餐包生成药品订单:{}", packageOrder.getOrderSn());
+        order.setOrderCode(packageOrder.getOrderSn());
+        order.setUserId(packageOrder.getUserId());
+        order.setStoreId(fsPackage.getStoreId());
+
+        order.setStatus(1);
+        order.setPayDelivery(packageOrder.getPayDelivery());
+        order.setPayRemain(packageOrder.getPayRemain());
+        order.setPayType(packageOrder.getPayType());
+        order.setPackageSecondName(packageOrder.getPackageSecondName());
+        order.setDoctorId(packageOrder.getDoctorId());
+
+        order.setPackageId(packageOrder.getPackageId());
+        order.setPackageName(packageOrder.getPackageName());
+        order.setPrescribePrice(packageOrder.getTotalPrice());
+        order.setDiscountMoney(packageOrder.getDiscountMoney());
+        order.setDeptId(packageOrder.getDeptId());
+        order.setCompanyId(packageOrder.getCompanyId());
+        order.setCompanyUserId(packageOrder.getCompanyUserId());
+        order.setPackageOrderId(packageOrder.getOrderId());
+        order.setCreateTime(new Date());
+        if (packageOrder.getSource() != null) {
+            order.setSource(packageOrder.getSource());
+        }
+        String addressJson = packageOrder.getAddressJson();
+        if (addressJson != null && addressJson != "") {
+            Map<String, String> parse = (Map) JSON.parse(addressJson);
+            order.setUserName(parse.get("userName"));
+            order.setUserPhone(parse.get("userPhone"));
+            order.setUserAddress(parse.get("userAddress"));
+        }
+
+
+        Long totalNum = 0L;
+        BigDecimal totalPrice = new BigDecimal(0);
+        boolean noTui = false;
+        for (FsPackagePruductDTO product : products) {
+            if (product.getBarCode().equals("106013")) {
+                noTui = true;
+            }
+            totalPrice = totalPrice.add(product.getPrice().multiply(BigDecimal.valueOf(product.getCount())));
+            totalNum = totalNum + product.getCount();
+            FsStoreOrderItem item = new FsStoreOrderItem();
+            item.setProductId(product.getProductId());
+            item.setStoreId(fsPackage.getStoreId());
+            item.setProductAttrValueId(product.getId());
+            item.setNum(Long.parseLong(product.getCount().toString()));
+            item.setIsDrug(product.getIsDrug());
+            FsStoreOrderItemDTO dto = new FsStoreOrderItemDTO();
+            dto.setImage(product.getImage());
+            dto.setNum(Long.parseLong(product.getCount().toString()));
+            dto.setProductName(product.getProductName());
+            dto.setProductId(product.getProductId());
+            dto.setSku(product.getSku());
+            dto.setBarCode(product.getBarCode());
+            dto.setPrice(product.getPrice());
+            dto.setNum(Long.parseLong(product.getCount().toString()));
+            dto.setImage(product.getImage());
+            item.setIsPrescribe(0);
+            item.setJsonInfo(JSON.toJSONString(dto));
+            item.setIsGift(0);
+            items.add(item);
+        }
+        String json = configService.selectConfigByKey("his.package");
+        PackageConfigDTO configDTO = JSONUtil.toBean(json, PackageConfigDTO.class);
+        FsPackageOrder fsPackageOrder = new FsPackageOrder();
+        //赠品处理
+        if (configDTO.getGiftStoreId() != null && configDTO.getGiftStoreId() == packageOrder.getStoreId() && packageOrder.getCompanyId() != null && packageOrder.getCompanyId() > 0 && packageOrder.getPayType().equals(1) && packageOrder.getPayMoney().compareTo(configDTO.getGiftPrice()) >= 0) {
+            if (configDTO.getGift() != null && !configDTO.getGift().isEmpty()) {
+                for (StoreOrderProductDTO product : configDTO.getGift()) {
+                    totalNum = totalNum + product.getCount();
+                    FsStoreOrderItem item = new FsStoreOrderItem();
+                    item.setProductId(product.getProductId());
+                    item.setStoreId(fsPackage.getStoreId());
+                    item.setProductAttrValueId(product.getId());
+                    item.setNum(Long.parseLong(product.getCount().toString()));
+                    FsStoreOrderItemDTO dto = new FsStoreOrderItemDTO();
+                    dto.setImage(product.getImage());
+                    dto.setNum(Long.parseLong(product.getCount().toString()));
+                    dto.setProductName(product.getProductName());
+                    dto.setProductId(product.getProductId());
+                    dto.setSku(product.getSku());
+                    dto.setBarCode(product.getBarCode());
+                    dto.setPrice(product.getPrice());
+                    if (product.getCount() != null) {
+                        dto.setNum(Long.parseLong(product.getCount().toString()));
+                    }
+                    dto.setImage(product.getImage());
+                    item.setIsPrescribe(0);
+                    item.setJsonInfo(JSON.toJSONString(dto));
+                    item.setIsGift(1);
+                    items.add(item);
+                    fsPackageOrder.setProductCostPrice(packageOrder.getProductCostPrice().add(product.getCostPrice()));
+                    fsPackageOrder.setTotalCostPrice(packageOrder.getTotalCostPrice().add(product.getCostPrice()));
+                    fsPackageOrder.setCostDiscountMoney(packageOrder.getCostDiscountMoney().subtract(product.getCostPrice()));
+                }
+            }
+        }
+        //物流代收赠品
+        if (configDTO.getGiftStoreId() != null && configDTO.getGiftStoreId() == packageOrder.getStoreId() && packageOrder.getCompanyId() != null && packageOrder.getCompanyId() > 0 && packageOrder.getPayType().equals(2) && packageOrder.getPayPrice().compareTo(configDTO.getGiftPrice()) >= 0) {
+            if (configDTO.getDeliveryGift() != null && !configDTO.getDeliveryGift().isEmpty()) {
+                for (StoreOrderProductDTO product : configDTO.getDeliveryGift()) {
+                    totalNum = totalNum + product.getCount();
+                    FsStoreOrderItem item = new FsStoreOrderItem();
+                    item.setProductId(product.getProductId());
+                    item.setStoreId(fsPackage.getStoreId());
+                    item.setProductAttrValueId(product.getId());
+                    item.setNum(Long.parseLong(product.getCount().toString()));
+                    FsStoreOrderItemDTO dto = new FsStoreOrderItemDTO();
+                    dto.setImage(product.getImage());
+                    dto.setNum(Long.parseLong(product.getCount().toString()));
+                    dto.setProductName(product.getProductName());
+                    dto.setProductId(product.getProductId());
+                    dto.setSku(product.getSku());
+                    dto.setBarCode(product.getBarCode());
+                    dto.setPrice(product.getPrice());
+                    if (product.getCount() != null) {
+                        dto.setNum(Long.parseLong(product.getCount().toString()));
+                    }
+                    dto.setImage(product.getImage());
+                    item.setIsPrescribe(0);
+                    item.setJsonInfo(JSON.toJSONString(dto));
+                    item.setIsGift(1);
+                    items.add(item);
+                    fsPackageOrder.setProductCostPrice(packageOrder.getProductCostPrice().add(product.getCostPrice()));
+                    fsPackageOrder.setTotalCostPrice(packageOrder.getTotalCostPrice().add(product.getCostPrice()));
+                    fsPackageOrder.setCostDiscountMoney(packageOrder.getCostDiscountMoney().subtract(product.getCostPrice()));
+                }
+            }
+        }
+        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.store");
+        Map<String, Object> config = (Map<String, Object>) JSON.parse(sysConfig.getConfigValue());
+        Integer followRate = (Integer) config.get("followRate");
+        Long followDoctorId = fsPackageOrderMapper.selectFsPackageOrderByUserId(order.getUserId());
+        if (followDoctorId != null && followDoctorId > 0) {
+            order.setFollowDoctorId(followDoctorId);
+        } else {
+            if (packageOrder.getCompanyId() != null) {
+                Company company = companyService.selectCompanyById(packageOrder.getCompanyId());
+                if (company != null) {
+                    String followDoctorIdsJson = company.getFollowDoctorIds();
+                    if (followDoctorIdsJson != null && followDoctorIdsJson != "") {
+                        long[] ids = JSON.parseObject(followDoctorIdsJson, long[].class);
+                        if (ids.length > 0) {
+                            Random random = new Random();
+                            // 从数组中随机选择一个数字
+                            int randomIndex = random.nextInt(ids.length);
+                            long randomId = ids[randomIndex];
+                            order.setFollowDoctorId(randomId);
+                        }
+                    }
+                }
+            }
+            if (order.getFollowDoctorId() == null) {
+                order.setFollowDoctorId(iFsDoctorService.selectFollowDoctorDoctorByPackage());
+            }
+        }
+
+        order.setOrderType(fsPackage.getProductType());
+        order.setTotalNum(totalNum);
+        order.setTotalPrice(totalPrice);
+        order.setPayPrice(packageOrder.getPayPrice());
+        order.setPayMoney(packageOrder.getPayMoney());
+        order.setIsPay(0);
+        order.setItemJson(JSONUtil.toJsonStr(items));
+
+        if (packageOrder.getCycle() >= followRate) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(new Date());
+            calendar.add(Calendar.DAY_OF_MONTH, followRate);
+            order.setFollowTime(calendar.getTime());
+            order.setCycle(packageOrder.getCycle());
+            Calendar calendar2 = Calendar.getInstance();
+            calendar2.setTime(new Date());
+            calendar2.add(Calendar.DAY_OF_MONTH, 30 + packageOrder.getCycle());
+            order.setFollowEndTime(calendar2.getTime());
+            order.setFollowStatus(0);
+        }
+        if (fsStoreOrderMapper.insertFsStoreOrder(order) > 0) {
+
+            if (order.getOrderId() == null) {
+                throw new CustomException("订单id为空" + order);
+            }
+            fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.CREATE_ORDER.getValue(),
+                    FsStoreOrderLogEnum.CREATE_ORDER.getDesc());
+            fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.UN_PAY_ORDER.getValue(),
+                    FsStoreOrderLogEnum.UN_PAY_ORDER.getDesc());
+
+            if (prescribeId != null) {
+                FsPrescribe fsPrescribe = new FsPrescribe();
+                fsPrescribe.setPrescribeId(prescribeId);
+                fsPrescribe.setStoreOrderId(order.getOrderId());
+                fsPrescribeService.updateFsPrescribe(fsPrescribe);
+            }
+
+            for (FsStoreOrderItem item : items) {
+                item.setOrderId(order.getOrderId());
+                fsStoreOrderItemMapper.insertFsStoreOrderItem(item);
+            }
+            if (noTui) {
+                FsStoreOrder fsStoreOrder = new FsStoreOrder();
+                fsStoreOrder.setOrderId(order.getOrderId());
+                fsStoreOrder.setExtendOrderId("XN");
+                fsStoreOrderMapper.updateFsStoreOrder(fsStoreOrder);
+            }
+            FsUser fsUser = fsUserService.selectFsUserByUserId(order.getUserId());
+            if (fsUser.getIsBuy() == null || fsUser.getIsBuy() == 0) {
+                FsUser u = new FsUser();
+                u.setUserId(order.getUserId());
+                u.setIsBuy(1);
+                fsUserService.updateFsUser(u);
+            }
+        }
+        return order;
+    }
 
 }

+ 13 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java

@@ -181,7 +181,7 @@ public interface IFsStoreOrderScrmService
 
     R addUserCart(long userId, String createOrderKey);
 
-    R updateSalseOrderMoney(String createOrderKey, BigDecimal money,BigDecimal payAmount);
+    R updateSalseOrderMoney(String createOrderKey, BigDecimal money,BigDecimal payAmount,Integer payType);
 
     Integer selectFsStoreOrderCountByType(Long companyId, long userId, int type);
 
@@ -290,6 +290,18 @@ public interface IFsStoreOrderScrmService
      * */
     FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);
 
+    R pay(FsStoreOrderPayParam param);
+
+    void cancelPay(FsStoreOrderPayParam param);
+
+    R otherPaymentRemain(FsStoreOrderOtherPayParam param);
+
+    R otherPayment(FsStoreOrderOtherPayParam param);
+
+    R payRemain(FsStoreOrderPayParam param);
+
+    R editPayType(FsStoreOrderPayParam param);
+
     /**
      * 跟进代服账户查询订单
      * @param param

+ 631 - 16
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.service.impl;
 
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.core.date.DateTime;
 import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.hutool.core.net.URLDecoder;
@@ -11,6 +12,7 @@ import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.fs.api.param.OrderListParam;
 import com.fs.api.vo.OrderListVO;
 import com.fs.api.vo.ProductListVO;
@@ -25,8 +27,12 @@ import com.fs.common.exception.CustomException;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.IpUtil;
+import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.utils.ip.IpUtils;
+import com.fs.common.utils.spring.SpringUtils;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyDept;
 import com.fs.company.domain.CompanyMoneyLogs;
@@ -37,6 +43,7 @@ import com.fs.company.mapper.CompanyMoneyLogsMapper;
 import com.fs.company.service.ICompanyDeptService;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
+import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
@@ -64,6 +71,7 @@ import com.fs.his.vo.FsStoreOrderExcelVO;
 import com.fs.his.vo.*;
 import com.fs.his.vo.FsPrescribeVO;
 import com.fs.hisStore.config.FsErpConfig;
+import com.fs.hisStore.constants.ErpTypeEnum;
 import com.fs.hisStore.dto.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
@@ -78,9 +86,12 @@ import com.fs.hisapi.domain.ApiResponse;
 import com.fs.hisapi.param.CreateOrderParam;
 import com.fs.hisapi.param.RecipeDetailParam;
 import com.fs.hisapi.service.HisApiService;
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
+import com.fs.pay.pay.dto.OrderQueryDTO;
 import com.fs.pay.pay.dto.RefundDTO;
 import com.fs.pay.service.IPayService;
 import com.fs.hisStore.config.StoreConfig;
@@ -90,7 +101,10 @@ import com.fs.hisStore.domain.*;
 import com.fs.hisStore.enums.*;
 import com.fs.hisStore.service.*;
 import com.fs.system.service.ISysConfigService;
+import com.fs.wx.miniapp.config.WxMaProperties;
+import com.fs.ybPay.domain.OrderResult;
 import com.fs.ybPay.domain.RefundResult;
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
 import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
 import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult;
@@ -100,7 +114,10 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import lombok.Synchronized;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.ObjectUtils;
+import org.apache.http.util.Asserts;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.aop.framework.AopContext;
@@ -146,6 +163,7 @@ import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
 @EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
 @Slf4j
 public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
+    private static final String STORE_PAY_CONF = "his.pay";
 
     Logger logger = LoggerFactory.getLogger(getClass());
     @Autowired
@@ -171,7 +189,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     private IFsUserBillScrmService billService;
 
     @Autowired
-    RedisCache redisCache;
+    private RedisCache redisCache;
 
     @Autowired
     private IFsStoreCartScrmService cartService;
@@ -202,13 +220,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Autowired
     private ConfigUtil configUtil;
     @Autowired
-    IFsStorePaymentScrmService paymentService;
+    private IFsStorePaymentScrmService paymentService;
 
     @Autowired
-    IFsStoreProductPackageScrmService productPackageService;
+    private IFsStoreProductPackageScrmService productPackageService;
 
     @Autowired
-    ICompanyUserService companyUserService;
+    private ICompanyUserService companyUserService;
     @Autowired
     private IFsStoreProductAttrValueScrmService attrValueService;
     @Autowired
@@ -237,15 +255,15 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     private FsStorePaymentScrmMapper fsStorePaymentMapper;
 
     @Autowired
-    ICompanyDeptService companyDeptService;
+    private ICompanyDeptService companyDeptService;
     @Autowired
-    IFsPrescribeScrmService prescribeService;
+    private IFsPrescribeScrmService prescribeService;
 
     @Autowired
-    IPayService ybPayService;
+    private IPayService ybPayService;
 
     @Autowired
-    HuiFuService huiFuService;
+    private HuiFuService huiFuService;
     @Autowired
     private WxPayService wxPayService;
     @Autowired
@@ -304,6 +322,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
     @Autowired
     private FsStoreProductAttrValueScrmMapper fsStoreProductAttrValueMapper;
+    @Autowired
+    private CloudHostProper cloudHostProper;
 
     @Autowired
     //fsStoreMapper
@@ -327,6 +347,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Autowired
     private FsPackageOrderMapper fsPackageOrderMapper;
 
+    @Autowired
+    private WxMaProperties properties;
+
     //ERP 类型到服务的映射
     private Map<Integer, IErpOrderService> erpServiceMap;
     @PostConstruct
@@ -591,10 +614,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + param.getOrderKey());
         BigDecimal payPrice = getOrderSumPrice(carts, "truePrice");
         if (StringUtils.isNotEmpty(param.getCreateOrderKey())) {
-            BigDecimal money = redisCache.getCacheObject("createOrderMoney:" + param.getCreateOrderKey());
-            if (money != null) {
-                payPrice = money;
+            Integer payType = redisCache.getCacheObject("createOrderPayType:" + param.getCreateOrderKey());
+            if (payType != null && payType == 3) {
+                payPrice = redisCache.getCacheObject("createOrderAmount:" + param.getCreateOrderKey());
+            } else {
+                BigDecimal money = redisCache.getCacheObject("createOrderMoney:" + param.getCreateOrderKey());
+                if (money != null) {
+                    payPrice = money;
+                }
             }
+
         }
         BigDecimal serviceFee = BigDecimal.ZERO;
         String configJson = configService.selectConfigByKey("store.config");
@@ -682,6 +711,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         //计算金额
         FsStoreOrderComputeDTO dto = this.computedOrder(userId, computedParam);
         String cartIds = redisCache.getCacheObject("orderKey:" + param.getOrderKey());
+        Integer payType = redisCache.getCacheObject("createOrderPayType:" + param.getCreateOrderKey());
+        if (payType != null) {
+            param.setPayType(payType.toString());
+        }
 //        Integer totalNum = 0;
         BigDecimal integral = BigDecimal.ZERO;
         if (cartIds != null) {
@@ -2113,7 +2146,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             if(ObjectUtils.equals(order.getStatus(),2)){
                 FsStoreAfterSalesParam fsStoreAfterSalesParam = new FsStoreAfterSalesParam();
                 fsStoreAfterSalesParam.setOrderCode(order.getOrderCode());
-                fsStoreAfterSalesParam.setRefundAmount(order.getRefundMoney());
+                fsStoreAfterSalesParam.setRefundAmount(order.getPayMoney());
                 fsStoreAfterSalesParam.setServiceType(1);
                 fsStoreAfterSalesParam.setReasons("后台手动退款流程");
                 fsStoreAfterSalesParam.setExplainImg(null);
@@ -2187,9 +2220,25 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                             return R.error("退款请求失败" + e.getErrCodeDes());
                         }
                     } else if (payment.getPayMode() != null && payment.getPayMode().equals("hf")) {
+                        String huifuId="";
+                        FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
+                        if (payment.getAppId() != null) {
+                            FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(payment.getAppId());
+                            huifuId = fsHfpayConfig.getHuifuId();
+                        } else {
+                            if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
+
+                                FsHfpayConfig fsPayConfig2 = fsHfpayConfigMapper.selectByAppId("wx0d1a3dd485268521");
+                                huifuId = fsPayConfig2.getHuifuId();
+                            }else {
+                                huifuId=fsPayConfig.getHuifuId();
+                            }
+                        }
+
+
                         V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
                         request.setOrgHfSeqId(payment.getTradeNo());
-                        request.setHuifuId(fsPayConfig.getHuifuId());
+                        request.setHuifuId(huifuId);
                         request.setOrdAmt(payment.getPayMoney().toString());
                         request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
                         request.setReqSeqId("refund-" + payment.getPayCode());
@@ -2248,7 +2297,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
         ErpOrderQueryRequert request = new ErpOrderQueryRequert();
         request.setCode(order.getExtendOrderId());
-        ErpOrderQueryResponse response = erpOrderService.getOrder(request);
+        ErpOrderQueryResponse response = erpOrderService.getScrmOrder(request);
         if (response.getOrders() != null && response.getOrders().size() > 0) {
             for (ErpOrderQuery orderQuery : response.getOrders()) {
                 if (orderQuery.getDeliverys() != null && orderQuery.getDeliverys().size() > 0) {
@@ -2354,10 +2403,15 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         String key = redisCache.getCacheObject("createOrderKey:" + createOrderKey);
         List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + createOrderKey);
         BigDecimal money = redisCache.getCacheObject("createOrderMoney:" + createOrderKey);
+        Integer payType = redisCache.getCacheObject("createOrderPayType:" + createOrderKey);
+        //展示代收金额
+        if (payType != null && payType == 3) {
+            money = redisCache.getCacheObject("createOrderAmount:" + createOrderKey);
+        }
         if (StringUtils.isEmpty(key)) {
             throw new CustomException("订单已过期", 501);
         }
-        return R.ok().put("carts", carts).put("totalMoney", money);
+        return R.ok().put("carts", carts).put("totalMoney", money).put("payType", payType);
     }
 
     @Override
@@ -2393,7 +2447,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     }
 
     @Override
-    public R updateSalseOrderMoney(String createOrderKey, BigDecimal money, BigDecimal payAmount) {
+    public R updateSalseOrderMoney(String createOrderKey, BigDecimal money, BigDecimal payAmount,Integer payType) {
         //货到付款自定义金额
         if (payAmount == null) {
             String configJson = configService.selectConfigByKey("store.config");
@@ -2433,6 +2487,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
         redisCache.setCacheObject("createOrderMoney:" + createOrderKey, money, 24, TimeUnit.HOURS);
         redisCache.setCacheObject("createOrderAmount:" + createOrderKey, payAmount, 24, TimeUnit.HOURS);//物流代收自定义金额
+        redisCache.setCacheObject("createOrderPayType:" + createOrderKey, payType, 24, TimeUnit.HOURS);//支付类型 1-全付款 3-物流代收(货到付款)
         return R.ok();
     }
 
@@ -3004,6 +3059,20 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         return fsStoreOrderMapper.selectFsStoreOrderStatisticsByUserId(fsUserIdList);
     }
 
+
+    /**
+     * 获取当前ERP类型
+     * @return ERP类型
+     */
+    public ErpTypeEnum getErpType(){
+        FsSysConfig erpConfig = configUtil.getSysConfig();
+        Integer erpType = erpConfig.getErpType();
+        ErpTypeEnum byCode = ErpTypeEnum.getByCode(erpType);
+        Asserts.notNull(byCode,String.format("当前ERP 类型: %d 未找到!",erpType));
+        return byCode;
+    }
+
+
     private IErpOrderService getErpService() {
         //判断是否开启erp
         IErpOrderService erpOrderService = null;
@@ -3756,6 +3825,552 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
     }
 
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public R pay(FsStoreOrderPayParam param) {
+        FsStoreOrderScrm order=this.selectFsStoreOrderById(param.getOrderId());
+        if(order==null){
+            return R.error("订单不存在");
+        }
+        if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
+            return R.error("订单状态不正确");
+        }
+        String orderId=redisCache.getCacheObject("isPaying:"+param.getOrderId());
+        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getId().toString())){
+            return R.error("正在支付中...");
+        }
+
+        FsUserScrm user=userService.selectFsUserById(order.getUserId());
+        if(user!=null){
+            //已改价处理
+            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
+                //改过价不做处理
+
+            }
+            else{
+                String config=configService.selectConfigByKey("his.store");
+                com.fs.store.config.StoreConfig storeConfig= JSONUtil.toBean(config, com.fs.store.config.StoreConfig.class);
+                if(param.getPayType().equals(1)){
+                    order.setPayType("1");
+                    order.setPayMoney(order.getPayPrice());
+                    order.setPayDelivery(BigDecimal.ZERO);
+                }
+                else if(param.getPayType().equals(2)){
+                    order.setPayType("2");
+                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+                    order.setPayMoney(payMoney);
+                }
+                else if(param.getPayType().equals(3)){
+                    //货到付款
+                    order.setPayType("3");
+                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getId());
+                    BigDecimal payMoney = BigDecimal.ZERO;
+                    if (amount != null){
+                        payMoney=amount;
+                    }
+                    order.setPayMoney(payMoney);
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
+                }
+                this.updateFsStoreOrder(order);
+            }
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
+                String json = configService.selectConfigByKey(STORE_PAY_CONF);
+                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+                FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
+                storePayment.setCompanyId(order.getCompanyId());
+                storePayment.setCompanyUserId(order.getCompanyUserId());
+                storePayment.setPayMode(fsPayConfig.getType());
+                storePayment.setStatus(0);
+                storePayment.setPayCode(payCode);
+                storePayment.setPayMoney(order.getPayMoney());
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(2);
+                storePayment.setRemark("商城订单支付");
+                storePayment.setOpenId(user.getRealName());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessOrderId(order.getId().toString());
+                storePayment.setOrderId(order.getId());
+                fsStorePaymentMapper.insertFsStorePayment(storePayment);
+
+                if (fsPayConfig.getType().equals("hf")){
+                    HuiFuCreateOrder o = new HuiFuCreateOrder();
+                    o.setTradeType("T_MINIAPP");
+                    o.setOpenid(user.getMaOpenId());
+                    o.setReqSeqId("store-"+storePayment.getPayCode());
+                    o.setTransAmt(storePayment.getPayMoney().toString());
+                    o.setGoodsDesc("商城订单支付");
+                    o.setAppId(param.getAppId());
+                    HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                    if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+                        FsStorePaymentScrm mt=new FsStorePaymentScrm();
+                        mt.setPaymentId(storePayment.getPaymentId());
+                        mt.setTradeNo(result.getHf_seq_id());
+                        mt.setAppId(param.getAppId());
+                        fsStorePaymentMapper.updateFsStorePayment(mt);
+                        redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
+                        Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                        String s = (String) resultMap.get("package");
+                        resultMap.put("packageValue",s);
+                        return R.ok().put("payType",param.getPayType()).put("result",resultMap);
+                    }
+                    else{
+                        return R.error(result.getResp_desc());
+                    }
+                }else  if (fsPayConfig.getType().equals("wx")){
+                    WxPayConfig payConfig = new WxPayConfig();
+                    payConfig.setAppId(fsPayConfig.getAppId());
+                    payConfig.setMchId(fsPayConfig.getWxMchId());
+                    payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                    payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                    payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                    payConfig.setKeyPath(fsPayConfig.getKeyPath());
+                    payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                    wxPayService.setConfig(payConfig);
+                    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                    orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                    orderRequest.setBody("商城订单支付");
+                    orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
+                    orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                    orderRequest.setTradeType("JSAPI");
+                    orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                    //调用统一下单接口,获取"预支付交易会话标识"
+                    try {
+                        WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                        return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
+                    } catch (WxPayException e) {
+                        e.printStackTrace();
+                        throw new CustomException("支付失败" + e.getMessage());
+                    }
+                }
+            }
+            else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
+                //货到付款
+                IFsStoreOrderScrmService fsStoreOrderScrmService = (IFsStoreOrderScrmService) AopContext.currentProxy();
+                fsStoreOrderScrmService.payConfirm(2,order.getId(),null,null,null,null);
+                return R.ok().put("payType",param.getPayType());
+            }
+            return R.error();
+        }
+        else{
+            return R.error("用户OPENID不存在");
+        }
+    }
+
+    @Override
+    public void cancelPay(FsStoreOrderPayParam param) {
+        redisCache.deleteObject("isPaying:"+param.getOrderId());
+    }
+
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public R otherPaymentRemain(FsStoreOrderOtherPayParam param) {
+        final WxMaService wxService = WxMaConfiguration.getMaService(properties.getConfigs().get(0).getAppid());
+        try {
+            String ip = IpUtil.getRequestIp();
+            WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+            FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
+            if(user==null){
+                //创建
+                user=new FsUserScrm();
+                user.setUsername("");
+                user.setNickname("微信用户");
+                user.setStatus(1);
+                user.setMaOpenId(session.getOpenid());
+                user.setUnionId(session.getUnionid());
+                user.setIsWeixinAuth(0);
+                user.setLastIp(ip);
+                user.setCreateTime(new Date());
+                userService.insertFsUser(user);
+            }
+            FsStoreOrderScrm order=this.selectFsStoreOrderById(param.getOrderId());
+            if(order==null){
+                return R.error("订单不存在");
+            }
+            if(order.getStatus()!= OrderInfoEnum.STATUS_2.getValue()){
+                return R.error("待收货订单可申请支付尾款");
+            }
+            if(order.getPayType().equals(1)){
+                return R.error("此订单已支付");
+            }
+            //只有顺风才可以付尾
+            if(!order.getDeliverySn().trim().equals("SF")){
+                return R.error("只有顺丰物流支持尾款支付");
+            }
+
+            if(!order.getIsPayRemain().equals(0)){
+                return R.error("此订单已支付");
+            }
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            String json = configService.selectConfigByKey(STORE_PAY_CONF);
+            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
+            storePayment.setCompanyId(order.getCompanyId());
+            storePayment.setCompanyUserId(order.getCompanyUserId());
+            storePayment.setStatus(0);
+            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayCode(payCode);
+            storePayment.setPayMoney(order.getPayDelivery());
+            storePayment.setCreateTime(new Date());
+            storePayment.setPayTypeCode("weixin");
+            storePayment.setBusinessType(2);
+            storePayment.setRemark("商城订单尾款支付");
+            storePayment.setOpenId(user.getRealName());
+            storePayment.setUserId(user.getUserId());
+            storePayment.setBusinessOrderId(order.getId().toString());
+            storePayment.setOrderId(order.getId());
+            storePayment.setIsPayRemain(1);
+            fsStorePaymentMapper.insertFsStorePayment(storePayment);
+
+            if (fsPayConfig.getType().equals("hf")){
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(user.getMaOpenId());
+                o.setReqSeqId("store-"+storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("商城订单支付");
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+
+                    FsStorePaymentScrm mt=new FsStorePaymentScrm();
+                    mt.setPaymentId(storePayment.getPaymentId());
+                    mt.setTradeNo(result.getHf_seq_id());
+                    fsStorePaymentMapper.updateFsStorePayment(mt);
+                    redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
+                    Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                    String s = (String) resultMap.get("package");
+                    resultMap.put("packageValue",s);
+                    return R.ok().put("result",resultMap);
+                }
+                else{
+                    return R.error(result.getResp_desc());
+                }
+            }else  if (fsPayConfig.getType().equals("wx")){
+                //创建微信订单
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(fsPayConfig.getAppId());
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setKeyPath(null);
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                wxPayService.setConfig(payConfig);
+                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                orderRequest.setBody("商城订单支付");
+                orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
+                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+                orderRequest.setTradeType("JSAPI");
+                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                //调用统一下单接口,获取"预支付交易会话标识"
+                try {
+                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                    return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
+                } catch (WxPayException e) {
+                    e.printStackTrace();
+                    throw new CustomException("支付失败" + e.getMessage());
+                }
+            }
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
+        }
+        return R.error("无支付类型");
+    }
+
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public R otherPayment(FsStoreOrderOtherPayParam param) {
+        final WxMaService wxService = WxMaConfiguration.getMaService(properties.getConfigs().get(0).getAppid());
+        try {
+            String ip = IpUtil.getRequestIp();
+            WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+            FsUserScrm user=userService.selectFsUserByMaOpenId(session.getOpenid());
+            if(user==null){
+                //创建
+                user=new FsUserScrm();
+                user.setUsername("");
+                user.setNickname("微信用户");
+                user.setStatus(1);
+                user.setMaOpenId(session.getOpenid());
+                user.setUnionId(session.getUnionid());
+                user.setIsWeixinAuth(0);
+                user.setLastIp(ip);
+                user.setCreateTime(new Date());
+                userService.insertFsUser(user);
+            }
+            FsStoreOrderScrm order=selectFsStoreOrderById(param.getOrderId());
+            if(order==null){
+                return R.error("订单不存在");
+            }
+            if(!Objects.equals(order.getStatus(), OrderInfoEnum.STATUS_0.getValue())){
+                return R.error("此订单不能支付");
+            }
+            if(order.getPayMoney().compareTo(new BigDecimal(0))<1){
+                return R.error("此订单没有可支付的金额");
+            }
+
+            String orderId=redisCache.getCacheObject("isPaying:"+order.getId());
+            if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getId().toString())){
+                return R.error("正在支付中...");
+            }
+
+            String json = configService.selectConfigByKey(STORE_PAY_CONF);
+            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            //易宝支付
+            FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
+            storePayment.setCompanyId(order.getCompanyId());
+            storePayment.setCompanyUserId(order.getCompanyUserId());
+            storePayment.setStatus(0);
+            storePayment.setPayCode(payCode);
+            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayMoney(order.getPayMoney());
+            storePayment.setCreateTime(new Date());
+            storePayment.setPayTypeCode("weixin");
+            storePayment.setBusinessType(2);
+            storePayment.setRemark("商城订单支付");
+            storePayment.setOpenId(session.getOpenid());
+            storePayment.setUserId(user.getUserId());
+            storePayment.setBusinessOrderId(order.getId().toString());
+            storePayment.setOrderId(order.getId());
+            fsStorePaymentMapper.insertFsStorePayment(storePayment);
+
+            if (fsPayConfig.getType().equals("hf")){
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(user.getMaOpenId());
+                o.setReqSeqId("store-"+storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("商城订单支付");
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+
+                    FsStorePaymentScrm mt=new FsStorePaymentScrm();
+                    mt.setPaymentId(storePayment.getPaymentId());
+                    mt.setTradeNo(result.getHf_seq_id());
+                    fsStorePaymentMapper.updateFsStorePayment(mt);
+                    redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
+                    Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                    String s = (String) resultMap.get("package");
+                    resultMap.put("packageValue",s);
+                    return R.ok().put("result",resultMap);
+                }
+                else{
+                    return R.error(result.getResp_desc());
+                }
+            }else  if (fsPayConfig.getType().equals("wx")){
+                //创建微信订单
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(fsPayConfig.getAppId());
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setKeyPath(null);
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                wxPayService.setConfig(payConfig);
+                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                orderRequest.setBody("商城订单支付");
+                orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
+                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                orderRequest.setTradeType("JSAPI");
+                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                //调用统一下单接口,获取"预支付交易会话标识"
+                try {
+                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                    return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
+                } catch (WxPayException e) {
+                    e.printStackTrace();
+                    throw new CustomException("支付失败" + e.getMessage());
+                }
+            }
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
+        }
+        return R.error("无支付类型");
+    }
+
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public R payRemain(FsStoreOrderPayParam param) {
+        FsStoreOrderScrm order=selectFsStoreOrderById(param.getOrderId());
+        if(order==null){
+            return R.error("订单不存在");
+        }
+        if(order.getStatus()!= OrderInfoEnum.STATUS_2.getValue()){
+            return R.error("待收货订单可申请支付尾款");
+        }
+        if(order.getPayType().equals(1)){
+            return R.error("此订单已支付");
+        }
+        //只有顺风才可以付尾
+        if(!order.getDeliverySn().trim().equals("SF")){
+            return R.error("只有顺丰物流支持尾款支付");
+        }
+
+        if(!order.getIsPayRemain().equals(0)){
+            return R.error("此订单已支付");
+        }
+        FsUserScrm user=userService.selectFsUserById(order.getUserId());
+        if(user!=null){
+            String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
+            String json = configService.selectConfigByKey(STORE_PAY_CONF);
+            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
+            storePayment.setCompanyId(order.getCompanyId());
+            storePayment.setCompanyUserId(order.getCompanyUserId());
+            storePayment.setStatus(0);
+            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayCode(payCode);
+            storePayment.setPayMoney(order.getPayDelivery());
+            storePayment.setCreateTime(new Date());
+            storePayment.setPayTypeCode("weixin");
+            storePayment.setBusinessType(2);
+            storePayment.setRemark("商城订单尾款支付");
+            storePayment.setOpenId(user.getRealName());
+            storePayment.setUserId(user.getUserId());
+            storePayment.setBusinessOrderId(order.getId().toString());
+            storePayment.setOrderId(order.getId());
+            storePayment.setIsPayRemain(1);
+            fsStorePaymentMapper.insertFsStorePayment(storePayment);
+
+            if (fsPayConfig.getType().equals("hf")){
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(user.getMaOpenId());
+                o.setReqSeqId("store_remain-"+storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("商城订单尾款支付");
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                //创建订单
+                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+
+                    FsStorePaymentScrm mt=new FsStorePaymentScrm();
+                    mt.setPaymentId(storePayment.getPaymentId());
+                    mt.setTradeNo(result.getHf_seq_id());
+                    fsStorePaymentMapper.updateFsStorePayment(mt);
+                    redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
+                    Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                    String s = (String) resultMap.get("package");
+                    resultMap.put("packageValue",s);
+                    return R.ok().put("payType",param.getPayType()).put("result",resultMap);
+                }
+                else{
+                    return R.error(result.getResp_desc());
+                }
+            }else if(fsPayConfig.getType().equals("wx")) {
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(fsPayConfig.getAppId());
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setKeyPath(null);
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                wxPayService.setConfig(payConfig);
+                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                orderRequest.setBody("商城订单支付");
+                orderRequest.setOutTradeNo("store-" + storePayment.getPayCode());
+                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+                orderRequest.setTradeType("JSAPI");
+                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                //调用统一下单接口,获取"预支付交易会话标识"
+                try {
+                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                    return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0);
+                } catch (WxPayException e) {
+                    e.printStackTrace();
+                    throw new CustomException("支付失败" + e.getMessage());
+                }
+            }
+        }
+        else{
+            return R.error("用户OPENID不存在");
+        }
+        return R.error("无支付类型");
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
+    public R editPayType(FsStoreOrderPayParam param) {
+        FsStoreOrderScrm order=this.selectFsStoreOrderById(param.getOrderId());
+        if(order==null){
+            return R.error("订单不存在");
+        }
+        if(!Objects.equals(order.getStatus(), OrderInfoEnum.STATUS_0.getValue())){
+            return R.error("订单状态不正确");
+        }
+        String orderId=redisCache.getCacheObject("isPaying:"+order.getId());
+        if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getId().toString())){
+            return R.error("正在支付中...");
+        }
+        List<FsStorePaymentScrm>  payments=fsStorePaymentMapper.selectFsStorePaymentByOrder(order.getId());
+        if(CollectionUtils.isNotEmpty(payments)){
+            for(FsStorePaymentScrm payment : payments){
+                OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
+                orderQueryDTO.setLowOrderId("store-"+payment.getPayCode());
+                OrderResult orderResult = ybPayService.getOrder(orderQueryDTO);
+                if(orderResult.getStatus()!= null&&orderResult.getStatus().equals("100")){
+                    if(orderResult.getState()!=null&&orderResult.getState().equals("0")){
+                        return R.error("订单已支付");
+                    }
+
+                }
+            }
+        }
+        FsUserScrm user=userService.selectFsUserById(order.getUserId());
+        if(user!=null){
+            //已改价处理
+            if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
+                //改过价不做处理
+            }
+            else{
+                String config=configService.selectConfigByKey("his.store");
+                com.fs.store.config.StoreConfig storeConfig= JSONUtil.toBean(config, com.fs.store.config.StoreConfig.class);
+                if(param.getPayType().equals(1)){
+                    order.setPayType("1");
+                    order.setPayMoney(order.getPayPrice());
+                    order.setPayDelivery(BigDecimal.ZERO);
+                }
+                else if(param.getPayType().equals(2)){
+
+                    order.setPayType("2");
+                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+                    order.setPayMoney(payMoney);
+                }
+                else if(param.getPayType().equals(3)){
+                    //货到付款
+                    order.setPayType("3");
+                    BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getId());
+                    BigDecimal payMoney = BigDecimal.ZERO;
+                    if (amount != null){
+                        payMoney=amount;
+                    }
+                    order.setPayMoney(payMoney);
+                    order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
+                }
+                IFsStoreOrderScrmService fsStoreOrderScrmService = (IFsStoreOrderScrmService) AopContext.currentProxy();
+                fsStoreOrderScrmService.updateFsStoreOrder(order);
+            }
+            return R.ok().put("order",order);
+        }
+        else{
+            return R.error("用户OPENID不存在");
+        }
+    }
+
     @Override
     public List<FsStoreOrderVO> selectFsStoreOrderListVOByErpAccount(FsStoreOrderParam param) {
         List<FsStoreOrderVO> list = fsStoreOrderMapper.selectFsStoreOrderListVOByErpAccount(param);