瀏覽代碼

直播间代码

yuhongqi 4 周之前
父節點
當前提交
0b0536220d
共有 43 個文件被更改,包括 2671 次插入59 次删除
  1. 15 0
      fs-admin/src/main/java/com/fs/his/task/Task.java
  2. 1 1
      fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java
  3. 104 1
      fs-company/src/main/java/com/fs/company/controller/live/LiveOrderController.java
  4. 29 0
      fs-live-app/src/main/java/com/fs/app/controller/CommonController.java
  5. 1 1
      fs-live-app/src/main/java/com/fs/app/controller/LiveGoodsController.java
  6. 32 1
      fs-live-app/src/main/java/com/fs/app/controller/LiveOrderController.java
  7. 104 0
      fs-live-app/src/main/java/com/fs/app/controller/LiveOrderPaymentController.java
  8. 148 0
      fs-live-app/src/main/java/com/fs/app/controller/UserAddressController.java
  9. 247 18
      fs-live-app/src/main/java/com/fs/app/controller/UserController.java
  10. 18 0
      fs-live-app/src/main/java/com/fs/app/param/FsAddressParseParam.java
  11. 59 0
      fs-live-app/src/main/java/com/fs/app/param/FsUserAddressAddEditParam.java
  12. 32 0
      fs-live-app/src/main/java/com/fs/app/param/FsUserEditPhoneParam.java
  13. 19 0
      fs-live-app/src/main/java/com/fs/app/param/FsUserLoginByWeChatParam.java
  14. 85 0
      fs-live-app/src/main/java/com/fs/app/utils/CityTreeUtil.java
  15. 81 0
      fs-live-app/src/main/java/com/fs/app/utils/WxUtil.java
  16. 23 0
      fs-live-app/src/main/java/com/fs/app/vo/CityVO.java
  17. 13 0
      fs-service/src/main/java/com/fs/course/param/FsUserLiveOrderPayUParam.java
  18. 2 0
      fs-service/src/main/java/com/fs/his/domain/FsUser.java
  19. 5 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrder.java
  20. 4 4
      fs-service/src/main/java/com/fs/live/domain/LiveOrderItem.java
  21. 120 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrderPayment.java
  22. 38 0
      fs-service/src/main/java/com/fs/live/domain/LiveOrderPaymentError.java
  23. 8 0
      fs-service/src/main/java/com/fs/live/mapper/LiveGoodsMapper.java
  24. 11 7
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java
  25. 8 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java
  26. 64 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderPaymentErrorMapper.java
  27. 66 0
      fs-service/src/main/java/com/fs/live/mapper/LiveOrderPaymentMapper.java
  28. 12 0
      fs-service/src/main/java/com/fs/live/param/LiveOrderConfirmParam.java
  29. 1 1
      fs-service/src/main/java/com/fs/live/service/ILiveGoodsService.java
  30. 61 0
      fs-service/src/main/java/com/fs/live/service/ILiveOrderPaymentService.java
  31. 71 1
      fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java
  32. 8 15
      fs-service/src/main/java/com/fs/live/service/impl/LiveGoodsServiceImpl.java
  33. 93 0
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderPaymentServiceImpl.java
  34. 798 4
      fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java
  35. 3 0
      fs-service/src/main/java/com/fs/live/vo/LiveGoodsVo.java
  36. 15 2
      fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml
  37. 1 1
      fs-service/src/main/resources/mapper/live/LiveMapper.xml
  38. 2 2
      fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml
  39. 77 0
      fs-service/src/main/resources/mapper/live/LiveOrderPaymentErrorMapper.xml
  40. 174 0
      fs-service/src/main/resources/mapper/live/LiveOrderPaymentMapper.xml
  41. 6 0
      fs-user-app/src/main/java/com/fs/app/controller/TzPayController.java
  42. 6 0
      fs-user-app/src/main/java/com/fs/app/controller/WxPayController.java
  43. 6 0
      fs-user-app/src/main/java/com/fs/app/controller/YbPayController.java

+ 15 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -38,6 +38,8 @@ import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.FsSubOrderResultVO;
 import com.fs.im.dto.*;
 import com.fs.im.service.IImService;
+import com.fs.live.domain.LiveOrder;
+import com.fs.live.service.ILiveOrderService;
 import com.fs.qw.service.IQwAppContactWayService;
 import com.fs.qw.service.IQwExternalContactTransferLogService;
 import com.fs.qwApi.service.QwApiService;
@@ -142,8 +144,21 @@ public class Task {
 
     @Autowired
     ITencentCloudCosService tencentCloudCosService;
+
+    @Autowired
+    private ILiveOrderService liveOrderService;
     @Autowired
     private ConfigUtil configUtil;
+
+    public void pushLiveOrder()
+    {
+        List<LiveOrder> list = liveOrderService.selectNotPushedLiveOrder();
+        for (LiveOrder liveOrder : list) {
+            try {
+                liveOrderService.pushLiveOrder(liveOrder);
+            } catch (Exception e) {}
+        }
+    }
     public void videoTranscode() throws Exception
     {
 

+ 1 - 1
fs-admin/src/main/java/com/fs/live/controller/LiveGoodsController.java

@@ -137,6 +137,6 @@ public class LiveGoodsController extends BaseController
     @GetMapping("/liveStore/{liveId}")
     public R liveGoodsStore(@PathVariable Long liveId)
     {
-        return R.ok().put("store", liveGoodsService.getStoreByLiveId(liveId));
+        return liveGoodsService.getStoreByLiveId(liveId);
     }
 }

+ 104 - 1
fs-company/src/main/java/com/fs/company/controller/live/LiveOrderController.java

@@ -9,14 +9,27 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.erp.domain.ErpDeliverys;
+import com.fs.erp.domain.ErpOrderQuery;
+import com.fs.erp.dto.ErpOrderQueryRequert;
+import com.fs.erp.dto.ErpOrderQueryResponse;
+import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.FsStoreOrder;
+import com.fs.his.domain.FsStoreOrderItem;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.enums.ShipperCodeEnum;
 import com.fs.his.service.IFsExpressService;
+import com.fs.his.utils.ConfigUtil;
+import com.fs.live.domain.Live;
+import com.fs.live.domain.LiveGoods;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.enums.LiveOrderCancleReason;
 import com.fs.live.service.ILiveOrderService;
+import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderVo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
@@ -42,6 +55,29 @@ public class LiveOrderController extends BaseController
     @Autowired
     private IFsExpressService expressService;
 
+    @Autowired
+    private ConfigUtil configUtil;
+
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtOrderService;
+
+
+    /**
+     * 推送到智慧药房
+     */
+    @Log(title = "推药房", businessType = BusinessType.INSERT)
+    @PreAuthorize("@ss.hasPermi('his:storeOrder:sendHisGoods')")
+    @PutMapping("/tuiOrder")
+    public AjaxResult tuiOrder(@RequestBody LiveOrder liveOrder)
+    {
+        return toAjax(liveOrderService.tuiOrder(liveOrder.getOrderId()));
+    }
+
     /**
      * 查询订单列表
      */
@@ -85,7 +121,8 @@ public class LiveOrderController extends BaseController
     @PostMapping("/create")
     public R add(@RequestBody LiveOrder liveOrder)
     {
-        return R.ok().put("data", liveOrderService.insertLiveOrder(liveOrder));
+        liveOrder.setUserId(String.valueOf(getUserId()));
+        return liveOrderService.createLiveOrder(liveOrder);
     }
 
     /**
@@ -168,4 +205,70 @@ public class LiveOrderController extends BaseController
     }
 
 
+    @Log(title = "同步物流", businessType = BusinessType.UPDATE)
+    @GetMapping(value = "/syncExpress/{id}")
+    public R syncExpress(@PathVariable("id") Long id) {
+        return liveOrderService.syncExpress(id);
+    }
+
+    @Log(title = "同步管易物流单号", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('store:storeOrder:updateErpOrder')")
+    @PostMapping("/updateErpOrder")
+    public R updateErpOrder( @RequestBody LiveOrder param) {
+        LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+        ErpOrderQueryRequert request = new ErpOrderQueryRequert();
+        IErpOrderService erpOrderService = getErpService();
+        request.setCode(order.getExtendOrderId());
+        ErpOrderQueryResponse response = erpOrderService.getOrder(request);
+        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())){
+                            //更新商订单状态
+                            liveOrderService.updateDeliveryOrder(param.getOrderId(), delivery.getMail_no(),delivery.getExpress_code(),delivery.getExpress_name());
+                            return R.ok();
+                        }
+                    }
+
+                }
+            }
+        }
+        return R.error("未查询到快递信息");
+    }
+    private IErpOrderService getErpService() {
+        FsSysConfig sysConfig = configUtil.getSysConfig();
+        Integer erpOpen = sysConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1){
+            //判断erp类型
+            Integer erpType = sysConfig.getErpType();
+            if (erpType != null){
+                IErpOrderService erpOrderService = null;
+                if (erpType == 1){
+                    //管易
+                    erpOrderService =  gyOrderService;
+                } else if (erpType == 2){
+                    //旺店通
+                    erpOrderService =  wdtOrderService;
+                }
+                return erpOrderService;
+
+
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 查询订单商品列表
+     */
+
+    @GetMapping("/ltemlist/{orderId}")
+    public TableDataInfo ltemlist(@PathVariable("orderId") String orderId)
+    {
+        List<LiveGoodsVo> list = liveOrderService.selectLiveOrderItemList(orderId);
+        return getDataTable(list);
+    }
+
+
 }

+ 29 - 0
fs-live-app/src/main/java/com/fs/app/controller/CommonController.java

@@ -2,19 +2,28 @@ package com.fs.app.controller;
 
 
 import com.alibaba.fastjson.JSON;
+import com.fs.app.utils.CityTreeUtil;
+import com.fs.app.vo.CityVO;
 import com.fs.app.websocket.bean.SendMsgVo;
 import com.fs.app.websocket.service.WebSocketServer;
 import com.fs.common.core.domain.R;
 import com.fs.company.service.ICompanyWxChatService;
+import com.fs.his.domain.FsCity;
+import com.fs.his.service.IFsCityService;
 import com.fs.wxUser.domain.CompanyWxUser;
 import com.fs.wxUser.service.ICompanyWxUserService;
+import com.google.common.collect.Lists;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import jdk.nashorn.internal.ir.annotations.Ignore;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
+import java.util.List;
 
 
 @Slf4j
@@ -29,6 +38,9 @@ public class CommonController {
     private final ICompanyWxUserService companyWxUserService;
     private final ICompanyWxChatService companyWxChatService;
 
+    @Autowired
+    private IFsCityService cityService;
+
     @GetMapping("/testSend")
     public R testSend(Long userId, String msg) throws Exception{
         return R.ok();
@@ -39,5 +51,22 @@ public class CommonController {
         return R.ok();
     }
 
+    @ApiOperation("获取城市数据")
+    @GetMapping("/getCitys")
+    @Cacheable("cityData")
+    public R getCitys(){
+        List<FsCity> list=cityService.selectFsCityList(new FsCity());
+        List<CityVO> cityVOS = Lists.newArrayList();
+        for (FsCity city : list){
+            CityVO cityVO = new CityVO();
+            cityVO.setV(city.getCityId());
+            cityVO.setN(city.getCityName());
+            cityVO.setPid(city.getParentId());
+            cityVOS.add(cityVO);
+        }
+        return R.ok().put("data", CityTreeUtil.list2TreeConverter(cityVOS, "0"));
+
+    }
+
 
 }

+ 1 - 1
fs-live-app/src/main/java/com/fs/app/controller/LiveGoodsController.java

@@ -106,7 +106,7 @@ public class LiveGoodsController extends BaseController
     @GetMapping("/liveStore/{liveId}")
     public R liveGoodsStore(@PathVariable Long liveId)
     {
-        return R.ok(liveGoodsService.getStoreByLiveId(liveId));
+        return liveGoodsService.getStoreByLiveId(liveId);
     }
 
     /**

+ 32 - 1
fs-live-app/src/main/java/com/fs/app/controller/LiveOrderController.java

@@ -10,16 +10,21 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.course.param.FsUserLiveOrderPayUParam;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.enums.ShipperCodeEnum;
 import com.fs.his.service.IFsExpressService;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.enums.LiveOrderCancleReason;
+import com.fs.live.param.LiveOrderConfirmParam;
 import com.fs.live.service.ILiveOrderService;
 import com.github.pagehelper.PageHelper;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 import java.util.Map;
 
@@ -80,6 +85,13 @@ public class LiveOrderController extends AppBaseController
         return AjaxResult.success(liveOrderService.selectLiveOrderByOrderId(orderId));
     }
 
+    @ApiOperation("确认订单")
+    @PostMapping("/confirm")
+    public R confirm(@Validated @RequestBody LiveOrderConfirmParam param, HttpServletRequest request){
+        param.setUserId(Long.parseLong(getUserId()));
+        return liveOrderService.confirmOrder(param);
+    }
+
     /**
      * 新增订单
      */
@@ -88,7 +100,8 @@ public class LiveOrderController extends AppBaseController
     @PostMapping("/create")
     public R add(@RequestBody LiveOrder liveOrder)
     {
-        return R.ok().put("orderId", liveOrderService.insertLiveOrder(liveOrder));
+        liveOrder.setUserId(getUserId());
+        return liveOrderService.createLiveOrder(liveOrder);
     }
 
     /**
@@ -150,6 +163,24 @@ public class LiveOrderController extends AppBaseController
        liveOrderService.handlePay(liveOrder);
     }
 
+    @Login
+    @ApiOperation("支付宝支付")
+    @PostMapping("/aliPayment")
+    public R aliPayment(@Validated @RequestBody FsUserLiveOrderPayUParam param)
+    {
+        param.setUserId(Long.parseLong(getUserId()));
+        return liveOrderService.aliPayment(param);
+    }
+
+    @Login
+    @ApiOperation("微信支付")
+    @PostMapping("/weChatPayment")
+    public R payment(@Validated @RequestBody FsUserLiveOrderPayUParam param)
+    {
+        param.setUserId(Long.parseLong(getUserId()));
+        return liveOrderService.wxPayment(param);
+    }
+
     /**
      * 订单确认
      * */

+ 104 - 0
fs-live-app/src/main/java/com/fs/app/controller/LiveOrderPaymentController.java

@@ -0,0 +1,104 @@
+package com.fs.app.controller;
+
+import java.util.List;
+
+import com.fs.live.domain.LiveOrderPayment;
+import com.fs.live.service.ILiveOrderPaymentService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 支付明细Controller
+ *
+ * @author fs
+ * @date 2025-08-07
+ */
+@RestController
+@RequestMapping("/app/payment")
+public class LiveOrderPaymentController extends BaseController
+{
+    @Autowired
+    private ILiveOrderPaymentService liveOrderPaymentService;
+
+    /**
+     * 查询支付明细列表
+     */
+    @PreAuthorize("@ss.hasPermi('app:payment:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(LiveOrderPayment liveOrderPayment)
+    {
+        startPage();
+        List<LiveOrderPayment> list = liveOrderPaymentService.selectLiveOrderPaymentList(liveOrderPayment);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出支付明细列表
+     */
+    @PreAuthorize("@ss.hasPermi('app:payment:export')")
+    @Log(title = "支付明细", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(LiveOrderPayment liveOrderPayment)
+    {
+        List<LiveOrderPayment> list = liveOrderPaymentService.selectLiveOrderPaymentList(liveOrderPayment);
+        ExcelUtil<LiveOrderPayment> util = new ExcelUtil<LiveOrderPayment>(LiveOrderPayment.class);
+        return util.exportExcel(list, "支付明细数据");
+    }
+
+    /**
+     * 获取支付明细详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('app:payment:query')")
+    @GetMapping(value = "/{paymentId}")
+    public AjaxResult getInfo(@PathVariable("paymentId") Long paymentId)
+    {
+        return AjaxResult.success(liveOrderPaymentService.selectLiveOrderPaymentByPaymentId(paymentId));
+    }
+
+    /**
+     * 新增支付明细
+     */
+    @PreAuthorize("@ss.hasPermi('app:payment:add')")
+    @Log(title = "支付明细", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody LiveOrderPayment liveOrderPayment)
+    {
+        return toAjax(liveOrderPaymentService.insertLiveOrderPayment(liveOrderPayment));
+    }
+
+    /**
+     * 修改支付明细
+     */
+    @PreAuthorize("@ss.hasPermi('app:payment:edit')")
+    @Log(title = "支付明细", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody LiveOrderPayment liveOrderPayment)
+    {
+        return toAjax(liveOrderPaymentService.updateLiveOrderPayment(liveOrderPayment));
+    }
+
+    /**
+     * 删除支付明细
+     */
+    @PreAuthorize("@ss.hasPermi('app:payment:remove')")
+    @Log(title = "支付明细", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{paymentIds}")
+    public AjaxResult remove(@PathVariable Long[] paymentIds)
+    {
+        return toAjax(liveOrderPaymentService.deleteLiveOrderPaymentByPaymentIds(paymentIds));
+    }
+}

+ 148 - 0
fs-live-app/src/main/java/com/fs/app/controller/UserAddressController.java

@@ -0,0 +1,148 @@
+package com.fs.app.controller;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.fs.app.annotation.Login;
+import com.fs.app.param.FsAddressParseParam;
+import com.fs.app.param.FsUserAddressAddEditParam;
+import com.fs.common.annotation.RepeatSubmit;
+import com.fs.common.core.domain.R;
+import com.fs.his.domain.FsUserAddress;
+import com.fs.his.service.IFsCityService;
+import com.fs.his.service.IFsExpressService;
+import com.fs.his.service.IFsUserAddressService;
+import com.fs.his.service.IFsUserIntegralLogsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import java.util.List;
+
+import static com.fs.his.utils.PhoneUtil.decryptPhone;
+
+
+@Api("地址接口")
+@RestController
+@RequestMapping(value="/app/userAddress")
+public class UserAddressController extends  AppBaseController {
+
+
+    @Autowired
+    private IFsUserAddressService addressService;
+
+    @Autowired
+    private IFsCityService cityService;
+    @Autowired
+    private IFsExpressService expressService;
+    @Autowired
+    private IFsUserIntegralLogsService fsUserIntegralLogsService;
+
+
+
+
+    @Login
+    @ApiOperation("获取地址列表")
+    @GetMapping("/getAddressList")
+    public R getAddressList(HttpServletRequest request){
+        try {
+            FsUserAddress map=new FsUserAddress();
+            map.setUserId(Long.parseLong(getUserId()));
+            map.setIsDel(0);
+            List<FsUserAddress> list=addressService.selectFsUserAddressList(map);
+            for (FsUserAddress fsUserAddress : list) {
+
+                if (fsUserAddress.getPhone()!=null&&fsUserAddress.getPhone().length()>11&&!fsUserAddress.getPhone().matches("\\d+")){
+                    fsUserAddress.setPhone(decryptPhone(fsUserAddress.getPhone()));
+                }
+            }
+            return R.ok().put("data",list);
+        } catch (Exception e){
+            return R.error("操作异常");
+        }
+    }
+    @Login
+    @ApiOperation("获取地址信息")
+    @GetMapping("/getAddressById")
+    public R getAddressById(@RequestParam("addressId")Long addressId, HttpServletRequest request){
+        FsUserAddress address=addressService.selectFsUserAddressByAddressId(addressId);
+
+        if (address.getPhone()!=null&&address.getPhone().length()>11&&!address.getPhone().matches("\\d+")){
+            address.setPhone(decryptPhone(address.getPhone()));
+        }
+        if(!address.getUserId().equals(Long.parseLong(getUserId()))){
+            return R.error("非法操作");
+        }
+        return R.ok().put("data",address);
+    }
+    @Login
+    @RepeatSubmit
+    @ApiOperation("添加地址")
+    @PostMapping("/addAddress")
+    public R addAddress(@Valid @RequestBody FsUserAddressAddEditParam address, HttpServletRequest request){
+        //处理地址数量 最大20个
+        Integer count=addressService.selectFsUserAddressCountsByUserId(Long.parseLong(getUserId()));
+        if(count>10){
+            return R.error("最多可创建10个地址");
+        }
+        if(address.getIsDefault()==1){
+            //处理默认地址
+            addressService.clearIsDefalut(Long.parseLong(getUserId()));
+        }
+        FsUserAddress userAddress=new FsUserAddress();
+        BeanUtil.copyProperties(address, userAddress);
+        address.setPhone(address.getPhone().trim());
+        userAddress.setUserId(Long.parseLong(getUserId()));
+        addressService.insertFsUserAddress(userAddress);
+        fsUserIntegralLogsService.addUserAddressIntegral(Long.parseLong(getUserId()),userAddress.getAddressId());
+        return R.ok("操作成功");
+    }
+
+    @Login
+    @ApiOperation("编辑地址")
+    @PostMapping("/editAddress")
+    public R editAddress(@Valid @RequestBody FsUserAddressAddEditParam address, HttpServletRequest request){
+        if(address.getIsDefault()==1){
+            //处理默认地址
+            addressService.clearIsDefalut(Long.parseLong(getUserId()));
+        }
+        FsUserAddress userAddress=new FsUserAddress();
+        BeanUtil.copyProperties(address, userAddress);
+        addressService.updateFsUserAddress(userAddress);
+        return R.ok("操作成功");
+    }
+
+    @Login
+    @ApiOperation("删除地址")
+    @PostMapping("/delAddress")
+    public R delAddress(@RequestBody FsUserAddressAddEditParam address, HttpServletRequest request){
+        addressService.deleteFsUserAddressByAddressId(address.getAddressId());
+        return R.ok("操作成功");
+    }
+
+    @Login
+    @ApiOperation("地址解析")
+    @PostMapping("/parseAddress")
+    public R parseAddress(@RequestBody FsAddressParseParam param){
+        return expressService.parseAddress(param.getContent());
+    }
+
+    @Login
+    @ApiOperation("获取默认地址信息")
+    @GetMapping("/getAddressByDefault")
+    public R getAddressByDefault( HttpServletRequest request){
+        FsUserAddress address=addressService.selectFsUserAddressByDefault(Long.parseLong(getUserId()));
+        if (address!=null&&address.getPhone()!=null&&address.getPhone().length()>11&&!address.getPhone().matches("\\d+")){
+            address.setPhone(decryptPhone(address.getPhone()));
+        }
+        if (null!=address){
+            if(!address.getUserId().equals(Long.parseLong(getUserId()))){
+                return R.error("非法操作");
+            }
+        }
+        return R.ok().put("data",address);
+    }
+
+}

+ 247 - 18
fs-live-app/src/main/java/com/fs/app/controller/UserController.java

@@ -3,10 +3,15 @@ package com.fs.app.controller;
 
 import cn.hutool.core.date.DateTime;
 import com.fs.app.annotation.Login;
+import com.fs.app.param.FsUserEditPhoneParam;
+import com.fs.app.param.FsUserLoginByWeChatParam;
 import com.fs.app.param.FsUserLoginParam;
 import com.fs.app.param.LoginParam;
+import com.fs.app.utils.WxUtil;
 import com.fs.app.websocket.constant.NickNameConstant;
+import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.constant.Constants;
+import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.user.CaptchaException;
@@ -20,9 +25,11 @@ import com.fs.company.service.ICompanyUserService;
 import com.fs.framework.manager.AsyncManager;
 import com.fs.framework.manager.factory.AsyncFactory;
 import com.fs.his.domain.FsUser;
+import com.fs.his.domain.FsUserAddress;
 import com.fs.his.mapper.FsUserMapper;
 import com.fs.his.service.IFsUserNewTaskService;
 import com.fs.his.service.IFsUserService;
+import com.fs.his.vo.FsUserRegisterParam;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -44,6 +51,7 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
+import static com.fs.his.utils.PhoneUtil.decryptPhoneMk;
 import static com.fs.his.utils.PhoneUtil.encryptPhone;
 
 
@@ -65,6 +73,9 @@ public class UserController extends AppBaseController {
 	@Autowired
 	private IFsUserNewTaskService userNewTaskService;
 
+	private static final String APP_ID = "wx703c4bd07bbd1695";
+	private static final String APP_SECRET = "034f5cc8d9b5151f9d25da9628541e35";
+
 
 	@ApiOperation("课程短链公众号登录")
 	@PostMapping("/loginByMp")
@@ -120,21 +131,6 @@ public class UserController extends AppBaseController {
 
 	}
 
-	@ApiOperation("检测是否登录")
-	@GetMapping("/checkLogin")
-	public R checkLogin(){
-		if(StringUtils.isEmpty(getUserId())){
-			//未登录
-			return R.error("未登录");
-		}
-		else{
-			//登录
-			String token = jwtUtils.generateToken(Long.parseLong(getUserId()));
-			Map<String,Object> map=new HashMap<>();
-			map.put("token",token);
-			return R.ok("认证成功").put("userId",getUserId()).put("token",token);
-		}
-	}
 
 	/**
 	 * 获取用户信息
@@ -180,6 +176,63 @@ public class UserController extends AppBaseController {
 		}
 	}
 
+	@ApiOperation("检测是否登录")
+	@GetMapping("/checkLogin")
+	public R checkLogin(HttpServletRequest request){
+		if(StringUtils.isEmpty(getUserId())){
+			//未登录
+			return R.error("未登录");
+		}
+		else{
+			//登录
+			String token = jwtUtils.generateToken(Long.parseLong(getUserId()));
+			Map<String,Object> map=new HashMap<>();
+			map.put("token",token);
+			return R.ok("认证成功").put("userId",getUserId()).put("token",token);
+		}
+	}
+
+	@ApiOperation("注册app用户")
+	@PostMapping("/register")
+	@RepeatSubmit
+	public R registerDoctor(@Validated @RequestBody FsUserRegisterParam param){
+		FsUser fsUser = findUserByPhone(param.getPhone());
+
+//        if (fsUser == null) {
+//            // 尝试使用加密后的手机号查询
+//            fsUser = userService.selectFsUserByPhone(encryptPhone(param.getPhone()));
+//        }
+
+		if (fsUser != null && org.apache.commons.lang3.StringUtils.isNotEmpty(fsUser.getPassword())) {
+			return R.error("此账号已经注册");
+		}
+
+		FsUser user = new FsUser();
+		if (fsUser != null) {
+			// 更新已有用户的密码
+			user.setUserId(fsUser.getUserId());
+			user.setPassword(Md5Utils.hash(param.getPassword()));
+			user.setUpdateTime(new DateTime());
+			userService.updateFsUser(user);
+			return R.ok("注册成功");
+		} else {
+			// 创建新用户
+			user.setPhone(param.getPhone());
+			user.setNickName("app用户" + param.getPhone().substring(param.getPhone().length() - 4));
+			user.setStatus(1);
+			user.setAvatar("https://cos.his.cdwjyyh.com/fs/20240926/420728ee06e54575ba82665dedb4756b.png");
+			user.setPassword(Md5Utils.hash(param.getPassword()));
+			user.setCreateTime(new Date());
+
+			if (userService.insertFsUser(user) > 0) {
+				return R.ok("注册成功");
+			} else {
+				return R.error("注册失败");
+			}
+		}
+
+	}
+
 
 	/**
 	 * app登录
@@ -199,6 +252,163 @@ public class UserController extends AppBaseController {
 		}
 	}
 
+	@ApiOperation("获取用户收货地址")
+	@GetMapping(value = "/getUserAddr/{userId}")
+	public AjaxResult getUserAddr(@PathVariable("userId") Long userId)
+	{
+
+		List<FsUserAddress> fsUserAddresses = userService.selectFsUserAddressByUserId(userId);
+		for (FsUserAddress fsUserAddress : fsUserAddresses) {
+			if (fsUserAddress.getPhone()!=null&&fsUserAddress.getPhone()!=""){
+				if (fsUserAddress.getPhone().length()>11){
+					fsUserAddress.setPhone(decryptPhoneMk(fsUserAddress.getPhone()));
+				}else {
+					fsUserAddress.setPhone(fsUserAddress.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
+				}
+			}
+		}
+
+		return AjaxResult.success(fsUserAddresses);
+	}
+
+	@ApiOperation("微信登录")
+	@PostMapping("/loginByWeChat")
+	@Transactional
+	public R loginByWeChat(@Validated @RequestBody FsUserLoginByWeChatParam param) {
+		try {
+			if (org.apache.commons.lang3.StringUtils.isBlank(param.getCode())) {
+				return R.error("code不存在");
+			}
+			logger.info("zyp app微信登录,param:{}", param);
+			Map result = WxUtil.getAccessToken(param.getCode(),APP_ID,APP_SECRET);
+			String accessToken = result.get("access_token").toString();
+			String unionid = result.get("unionid").toString();
+
+			String openid = result.get("openid").toString();
+
+			Map userInfo = WxUtil.getUserInfo(accessToken, openid);
+
+			String nickname = userInfo.get("nickname").toString();
+			Integer sex = (Integer) userInfo.get("sex");
+			String avatar = userInfo.get("headimgurl").toString();
+			FsUser user = userService.selectFsUserByUnionid(unionid);
+
+			Map<String, Object> map = new HashMap<>();
+			if (user == null) {
+				user = new FsUser();
+				user.setLoginDevice(param.getLoginDevice()!=null ? param.getLoginDevice() : null);
+				user.setSource(param.getSource()!=null ? param.getSource() : null);
+				user.setNickName(nickname);
+				user.setAvatar(avatar);
+				if (sex!=0){
+					user.setSex(sex);
+				}
+				user.setUnionId(unionid);
+				user.setCreateTime(new Date());
+				user.setStatus(1);
+				if (org.apache.commons.lang3.StringUtils.isNotEmpty(param.getJpushId())) {
+					user.setJpushId(param.getJpushId());
+				}
+				userService.insertFsUser(user);
+				map.put("isNew", true);
+				map.put("unionid",unionid);
+//				if (org.apache.commons.lang3.StringUtils.isNotEmpty(param.getJpushId())) {
+//					try {
+//						//发送注册优惠券
+//						fsUserCouponService.sendRegisterCoupon(user);
+//					} catch (Exception e) {
+//						logger.error("发送注册优惠券失败:{}",e.getMessage());
+//					}
+//				}
+				return R.ok(map);
+			} else {
+				if (org.apache.commons.lang3.StringUtils.isNotEmpty(param.getJpushId())) {
+					updateExistingUserJpushId(user, param.getJpushId());
+//					try {
+//						//发送注册优惠券
+//						fsUserCouponService.sendRegisterCoupon(user);
+//					} catch (Exception e) {
+//						logger.error("发送注册优惠券失败:{}",e.getMessage());
+//					}
+				}
+				if (org.apache.commons.lang3.StringUtils.isEmpty(user.getPhone())) {
+					map.put("isNew", true);
+					map.put("unionid",user.getUnionId());
+					return R.ok(map);
+				}
+			}
+			if (user.getStatus()==0&& org.apache.commons.lang3.StringUtils.isNotEmpty(param.getSource())&&!param.getSource().equals("iOS")){
+				return R.error("登录失败,账户被禁用");
+			}
+			int isFirstLogin = userNewTaskService.performTaskOne(user.getUserId());
+			String token = jwtUtils.generateToken(user.getUserId());
+			redisCache.setCacheObject("userToken:" + user.getUserId(), token, 604800, TimeUnit.SECONDS);
+			map.put("token", token);
+			map.put("user", user);
+			map.put("isFirst",isFirstLogin);
+			return R.ok(map);
+		}catch (Exception e){
+			logger.error("zyp 登录失败:{}", e.getMessage());
+			return R.error("登录失败");
+		}
+
+	}
+
+	@ApiOperation("绑定手机号")
+	@PostMapping("/setIPhoneNumber")
+	public R setIPhoneNumber(@Validated @RequestBody FsUserEditPhoneParam param) {
+		FsUser userMap = findUserByPhone(param.getPhone());
+		if (userMap != null) {
+			if (org.apache.commons.lang3.StringUtils.isNotEmpty(userMap.getAppleKey()) && !param.getAppleKey().equals(userMap.getAppleKey())) {
+				return R.error("该手机号已绑定其他账号");
+			}
+			if (param.getSimExist() == 0 && !Md5Utils.hash(param.getPassword()).equals(userMap.getPassword())) {
+				return R.error("密码不正确");
+			}
+		} else {
+			userMap = createNewAppleUser(param, param.getPhone());
+		}
+
+		userMap.setLoginDevice(param.getLoginDevice());
+		userMap.setSource(param.getSource());
+		if (userMap.getNickName().equals("匿名用户**")) {
+			userMap.setNickName("苹果用户" + param.getPhone().substring(param.getPhone().length() - 4));
+		}
+		userMap.setAppleKey(param.getAppleKey());
+		if (userService.updateFsUser(userMap)>0){
+			return generateTokenAndReturn(userMap);
+		}
+		return R.error("绑定手机号失败");
+	}
+
+	@ApiOperation("绑定手机号")
+	@PostMapping("/setPhone")
+	public R setPhone(@Validated @RequestBody FsUserEditPhoneParam param) {
+		FsUser user = userService.selectFsUserByUnionid(param.getUnionId());
+		if (user == null) {
+			return R.error("用户数据不存在");
+		}
+		FsUser userMap = findUserByPhone(param.getPhone());
+		if (userMap != null) {
+			return R.error("该手机号已绑定其他账号");
+		}
+		user.setPhone(param.getPhone());
+		user.setLoginDevice(param.getLoginDevice() != null ? param.getLoginDevice() : null );
+		user.setSource(param.getSource()!= null ? param.getSource() : null);
+		userMap = new FsUser();
+		userMap.setLoginDevice(param.getLoginDevice());
+		userMap.setSource(param.getSource());
+		if (user.getNickName().equals("匿名用户**")) {
+			userMap.setNickName("匿名用户" + param.getPhone().substring(param.getPhone().length() - 4));
+		}
+		userMap.setUserId(user.getUserId());
+		userMap.setPhone(param.getPhone());
+		if (userService.updateFsUser(userMap)>0){
+			return generateTokenAndReturn(user);
+		}
+		return R.error("绑定手机号失败");
+	}
+
 	private R handleLoginType1(FsUserLoginParam param) {
 
 		if (org.apache.commons.lang3.StringUtils.isEmpty(param.getPhone()) || org.apache.commons.lang3.StringUtils.isEmpty(param.getPassword())) {
@@ -231,8 +441,8 @@ public class UserController extends AppBaseController {
 		// 根据手机号查询用户
 		FsUser user = findUserByPhone(param.getPhone());
 		if (user == null) {
-			user = createNewUser(param);
-			//return R.ok().put("isNew",true).put("phone",encryptPhone(param.getPhone()));
+			createNewUser(param);
+			return R.ok().put("isNew",true).put("phone",encryptPhone(param.getPhone()));
 		} else {
 			if (user.getUnionId()==null){
 				if (user.getPhone().length()<=11){
@@ -242,7 +452,7 @@ public class UserController extends AppBaseController {
 					userMapper.updateFsUser(fsUser);
 					logger.info("zyp \n【手机加密】:{}",encryptPhone(param.getPhone()));
 				}
-				//return R.ok().put("isNew",true).put("phone",encryptPhone(param.getPhone()));
+				return R.ok().put("isNew",true).put("phone",encryptPhone(param.getPhone()));
 			}
 			/*if (org.apache.commons.lang3.StringUtils.isNotEmpty(param.getJpushId())) {
 				updateExistingUserJpushId(user, param.getJpushId());
@@ -251,6 +461,25 @@ public class UserController extends AppBaseController {
 		return generateTokenAndReturn(user);
 	}
 
+	private FsUser createNewAppleUser(FsUserEditPhoneParam param, String phoneNumber) {
+		FsUser newUser = new FsUser();
+		newUser.setLoginDevice(param.getLoginDevice()!=null ? param.getLoginDevice() : null);
+		newUser.setSource(param.getSource()!=null ? param.getSource() : null);
+		newUser.setAppleKey(param.getAppleKey());
+		newUser.setPhone(param.getPhone());
+		newUser.setPassword(Md5Utils.hash(param.getPassword()));
+		newUser.setNickName("苹果用户" + param.getPhone().substring(param.getPhone().length() - 4));
+		newUser.setCreateTime(new Date());
+		newUser.setStatus(1);
+		newUser.setAvatar("https://cos.his.cdwjyyh.com/fs/20240926/420728ee06e54575ba82665dedb4756b.png");
+		if (org.apache.commons.lang3.StringUtils.isNotEmpty(param.getJpushId())) {
+			newUser.setJpushId(param.getJpushId());
+		}
+		userService.insertFsUser(newUser);
+		return newUser;
+
+	}
+
 	private void updateExistingUserJpushId(FsUser user, String jpushId) {
 		FsUser userMap = new FsUser();
 		userMap.setUserId(user.getUserId());

+ 18 - 0
fs-live-app/src/main/java/com/fs/app/param/FsAddressParseParam.java

@@ -0,0 +1,18 @@
+package com.fs.app.param;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+@Getter
+@Setter
+public class FsAddressParseParam implements Serializable {
+
+
+    private String content;
+
+
+
+
+}

+ 59 - 0
fs-live-app/src/main/java/com/fs/app/param/FsUserAddressAddEditParam.java

@@ -0,0 +1,59 @@
+package com.fs.app.param;
+
+import com.fs.common.annotation.Excel;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+@Getter
+@Setter
+public class FsUserAddressAddEditParam implements Serializable {
+
+    /** ID */
+    private Long addressId;
+
+    /** 收货人姓名 */
+    @NotBlank(message = "收货人姓名不能为空")
+    private String realName;
+
+    /** 收货人电话 */
+    @NotBlank(message = "收货人电话不能为空")
+    @Pattern(regexp="^1[3456789]\\d{9}$",message="手机号格式不正确")
+    private String phone;
+
+    /** 收货人所在省 */
+    @NotBlank(message = "收货人地址不能为空")
+    private String province;
+
+    /** 收货人所在市 */
+    @NotBlank(message = "收货人地址不能为空")
+    private String city;
+
+    /** 收货人所在区 */
+    @NotBlank(message = "收货人地址不能为空")
+    private String district;
+
+    /** 城市IDS */
+    @Excel(name = "城市IDS")
+    private String cityIds;
+
+    /** 收货人详细地址 */
+    @NotBlank(message = "收货人详细地址不能为空")
+    private String detail;
+
+    /** 邮编 */
+    private String postCode;
+
+    /** 经度 */
+    private String longitude;
+
+    /** 纬度 */
+    private String latitude;
+
+    private Integer isDefault;
+
+
+}

+ 32 - 0
fs-live-app/src/main/java/com/fs/app/param/FsUserEditPhoneParam.java

@@ -0,0 +1,32 @@
+package com.fs.app.param;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+@Data
+public class FsUserEditPhoneParam implements Serializable {
+
+    @NotBlank(message = "手机号不能为空")
+    @Pattern(regexp="^1[3456789]\\d{9}$",message="手机号格式不正确")
+    private String phone;
+    @NotNull(message = "unionId不能为空")
+    private String unionId;
+
+    private String loginDevice; //当前登陆设备
+
+    private String jpushId;
+
+    private String source;
+
+    private String appleKey;
+
+    private String password;
+    /**
+     * 是否有SIM卡 0不存在 1存在
+     */
+    private Integer simExist;
+}

+ 19 - 0
fs-live-app/src/main/java/com/fs/app/param/FsUserLoginByWeChatParam.java

@@ -0,0 +1,19 @@
+package com.fs.app.param;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+@Data
+public class FsUserLoginByWeChatParam implements Serializable {
+    private String jpushId;
+
+    @NotBlank(message = "code参数缺失")
+    private String code;
+
+    private String loginDevice;//当前登陆设备
+
+    private String source; //app来源
+
+}

+ 85 - 0
fs-live-app/src/main/java/com/fs/app/utils/CityTreeUtil.java

@@ -0,0 +1,85 @@
+package com.fs.app.utils;
+import com.fs.app.vo.CityVO;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName 树形工具类
+ **/
+public class CityTreeUtil {
+    /**
+     * 获得指定节点下所有归档
+     *
+     * @param list
+     * @param parentId
+     * @return
+     */
+    public static List<CityVO> list2TreeConverter(List<CityVO> list, String parentId) {
+        List<CityVO> returnList = new ArrayList<>();
+
+        for (CityVO res : list) {
+            //判断对象是否为根节点
+
+            if (res.getPid().equals(parentId)) {
+                //该节点为根节点,开始递归
+
+                //通过递归为节点设置childList
+                recursionFn(list, res);
+
+                returnList.add(res);
+            }
+        }
+
+        return returnList;
+    }
+
+    /**
+     * 递归列表
+     * 通过递归,给指定t节点设置childList
+     *
+     * @param list
+     * @param t
+     */
+    public static void recursionFn(List<CityVO> list, CityVO t) {
+        //只能获取当前t节点的子节点集,并不是所有子节点集
+        List<CityVO> childsList = getChildList(list, t);
+
+        //设置他的子集对象集
+        t.setC(childsList);
+
+        //迭代子集对象集
+
+        //遍历完,则退出递归
+        for (CityVO nextChild : childsList) {
+
+            //判断子集对象是否还有子节点
+            if (!CollectionUtils.isEmpty(childsList)) {
+                //有下一个子节点,继续递归
+                recursionFn(list, nextChild);
+            }
+        }
+    }
+
+    /**
+     * 获得指定节点下的所有子节点
+     *
+     * @param list
+     * @param t
+     * @return
+     */
+    public static List<CityVO> getChildList(List<CityVO> list, CityVO t) {
+        List<CityVO> childsList = new ArrayList<>();
+        //遍历集合元素,如果元素的Parentid==指定元素的id,则说明是该元素的子节点
+        for (CityVO t1 : list) {
+            if (t1.getPid().equals(t.getV())) {
+                childsList.add(t1);
+            }
+        }
+
+        return childsList;
+    }
+
+
+}

+ 81 - 0
fs-live-app/src/main/java/com/fs/app/utils/WxUtil.java

@@ -0,0 +1,81 @@
+package com.fs.app.utils;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class WxUtil {
+    private static final Logger logger = LoggerFactory.getLogger(WxUtil.class);
+    private static final String getAccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token";
+    private static final String refreshTokenUrl = "https://api.weixin.qq.com/sns/oauth2/refresh_token";
+    private static final String getUserInfo = "https://api.weixin.qq.com/sns/userinfo";
+
+
+    /**
+     * 获取微信AccessToken
+     * @param code 用户code
+     * @return
+     */
+    public static Map<?, ?> getAccessToken(String code, String appid, String secret) {
+        StringBuffer url = new StringBuffer();
+        url.append(getAccessTokenUrl)
+                .append("?appid=")
+                .append(appid)
+                .append("&secret=")
+                .append(secret)
+                .append("&code=")
+                .append(code)
+                .append("&grant_type=authorization_code");
+        String rs = HttpUtil.get(url.toString());
+        Map map = JSONObject.parseObject(rs, Map.class);
+        if (null == map.get("errcode")) {
+            return map;
+        } else {
+            logger.info("获取access_token出错,错误信息:" + map);
+            throw new RuntimeException("获取access_token出错");
+        }
+    }
+
+    /**
+     * 刷新AccessToken
+     * @param refreshToken
+     * @return
+     */
+    public static Map refreshToken(String refreshToken,String appid) {
+        StringBuffer url = new StringBuffer();
+        url.append(refreshTokenUrl)
+                .append("?appid=")
+                .append(appid)
+                .append("&grant_type=refresh_token&refresh_token=")
+                .append(refreshToken);
+        String rs = HttpUtil.get(url.toString());
+        Map map = JSONObject.parseObject(rs, Map.class);
+        if (null == map.get("errcode")) {
+            return map;
+        } else {
+            throw new RuntimeException("刷新access_token出错");
+        }
+    }
+
+    /**
+     * 获取用户信息
+     * @param accessToken
+     * @param openid
+     * @return
+     */
+    public static Map getUserInfo(String accessToken, String openid) {
+        StringBuffer url = new StringBuffer();
+        url.append(getUserInfo)
+                .append("?access_token=")
+                .append(accessToken)
+                .append("&openid=")
+                .append(openid)
+                .append("&lang=zh_CN");
+        String rs = HttpUtil.get(url.toString());
+        Map map = JSONObject.parseObject(rs, Map.class);
+        return map;
+    }
+}

+ 23 - 0
fs-live-app/src/main/java/com/fs/app/vo/CityVO.java

@@ -0,0 +1,23 @@
+package com.fs.app.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Getter
+@Setter
+@ToString
+public class CityVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private String v; //id
+
+    private String n; //名称
+
+    private String pid;
+
+    private List<CityVO> c; //子集
+}

+ 13 - 0
fs-service/src/main/java/com/fs/course/param/FsUserLiveOrderPayUParam.java

@@ -0,0 +1,13 @@
+package com.fs.course.param;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+public class FsUserLiveOrderPayUParam implements Serializable {
+   private Long userId;
+   @NotNull(message = "orderId不能为空")
+   private Long orderId;
+}

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

@@ -146,6 +146,8 @@ public class FsUser extends BaseEntity
 
     private Long qwExtId;
 
+    private String appleKey; // 苹果key登陆验证
+
     /**
      * 企微销售ID
      * **/

+ 5 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrder.java

@@ -312,4 +312,9 @@ public class LiveOrder extends BaseParam {
     @Excel(name = "订单名称")
     @TableField(exist = false)
     private String productIntroduce;
+
+    /** 备注*/
+    @Excel(name = "订单key")
+    @TableField(exist = false)
+    private String orderKey;
 }

+ 4 - 4
fs-service/src/main/java/com/fs/live/domain/LiveOrderItem.java

@@ -16,11 +16,11 @@ import lombok.EqualsAndHashCode;
 public class LiveOrderItem{
 
     /** $column.columnComment */
-    private String itemId;
+    private Long itemId;
 
     /** 订单id */
     @Excel(name = "订单id")
-    private String orderId;
+    private Long orderId;
 
     /** 订单号 */
     @Excel(name = "订单号")
@@ -28,7 +28,7 @@ public class LiveOrderItem{
 
     /** 购物车ID */
     @Excel(name = "购物车ID")
-    private String cartId;
+    private Long cartId;
 
     /** 直播商品ID */
     @Excel(name = "直播商品ID")
@@ -36,7 +36,7 @@ public class LiveOrderItem{
 
     /** 商品ID */
     @Excel(name = "商品ID")
-    private String productId;
+    private Long productId;
 
     /** 商品规格ID */
     @Excel(name = "商品规格ID")

+ 120 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrderPayment.java

@@ -0,0 +1,120 @@
+package com.fs.live.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 支付明细对象 live_order_payment
+ *
+ * @author fs
+ * @date 2025-08-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class LiveOrderPayment extends BaseEntity{
+
+    /** ID */
+    private Long paymentId;
+
+    /** 支付订单号 */
+    @Excel(name = "支付订单号")
+    private String payCode;
+
+    /** 支付类型 weixin alipay */
+    @Excel(name = "支付类型 weixin alipay")
+    private String payTypeCode;
+
+    /** 支付金额 */
+    @Excel(name = "支付金额")
+    private BigDecimal payMoney;
+
+    /** 支付时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date payTime;
+
+    /** 外部订单号 */
+    @Excel(name = "外部订单号")
+    private String tradeNo;
+
+    /** 用户ID */
+    @Excel(name = "用户ID")
+    private Long userId;
+
+    /** OPENID */
+    @Excel(name = "OPENID")
+    private String openId;
+
+    /** 业务类型  */
+    @Excel(name = "业务类型 ")
+    private Integer businessType;
+
+    /** 关联业务ID */
+    @Excel(name = "关联业务ID")
+    private String businessId;
+
+    /** 状态 0未支付 1已支付 -1 已退款 */
+    @Excel(name = "状态 0未支付 1已支付 -1 已退款")
+    private Integer status;
+
+    /** 交易单号 */
+    @Excel(name = "交易单号")
+    private String bankTransactionId;
+
+    /** 银行流水号 */
+    @Excel(name = "银行流水号")
+    private String bankSerialNo;
+
+    /** 退款金额 */
+    @Excel(name = "退款金额")
+    private BigDecimal refundMoney;
+
+    /** 退款时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "退款时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date refundTime;
+
+    /** 店铺ID */
+    @Excel(name = "店铺ID")
+    private Long storeId;
+
+    /** 公司id */
+    @Excel(name = "公司id")
+    private Long companyId;
+
+    /** 员工id */
+    @Excel(name = "员工id")
+    private Long companyUserId;
+
+    /** 关联业务编号 */
+    @Excel(name = "关联业务编号")
+    private String businessCode;
+
+    /** 支付方式: zb tz wx */
+    @Excel(name = "支付方式: zb tz wx")
+    private String payMode;
+
+    /** 分账状态 0未分账 1已分账 */
+    @Excel(name = "分账状态 0未分账 1已分账")
+    private Integer shareStatus;
+
+    /** 分账单号 */
+    @Excel(name = "分账单号")
+    private String shareCode;
+
+    /** 分账金额 */
+    @Excel(name = "分账金额")
+    private BigDecimal shareMoney;
+
+    /** 是否分账 */
+    @Excel(name = "是否分账")
+    private Integer isShare;
+
+
+}

+ 38 - 0
fs-service/src/main/java/com/fs/live/domain/LiveOrderPaymentError.java

@@ -0,0 +1,38 @@
+package com.fs.live.domain;
+
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 错误表对象 live_order_payment_error
+ *
+ * @author fs
+ * @date 2024-01-05
+ */
+
+@Data
+public class LiveOrderPaymentError extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private Long id;
+
+    /** 外部单号 */
+    @Excel(name = "外部单号")
+    private String orderFlowNo;
+
+    /** 订单编号 */
+    @Excel(name = "订单编号")
+    private String orderNo;
+
+    /** 信息 */
+    @Excel(name = "信息")
+    private String msg;
+
+    /** 0未处理 1已处理 */
+    @Excel(name = "0未处理 1已处理")
+    private Integer status;
+
+}

+ 8 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveGoodsMapper.java

@@ -4,9 +4,11 @@ import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.his.domain.FsStoreProduct;
 import com.fs.live.domain.LiveGoods;
+import com.fs.live.domain.LiveOrder;
 import com.fs.live.vo.LiveGoodsListVo;
 import com.fs.live.vo.LiveGoodsVo;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 直播商品Mapper接口
@@ -104,4 +106,10 @@ public interface LiveGoodsMapper extends BaseMapper<LiveGoods>{
      * @return 批量删除结果
      */
     int deleteBatchList(@Param("listVo") LiveGoodsListVo listVo);
+
+
+    List<LiveGoodsVo> selectProductListByOrder(LiveOrder liveOrder);
+
+    @Select("select * from live_goods where live_id = #{liveId} and product_id = #{productId}")
+    LiveGoods selectLiveGoodsByProductId(@Param("liveId") Long liveId,@Param("productId") Long productId);
 }

+ 11 - 7
fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java

@@ -3,17 +3,18 @@ package com.fs.live.mapper;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.live.domain.LiveOrderItem;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 订单详情Mapper接口
- * 
+ *
  * @author fs
  * @date 2025-07-08
  */
 public interface LiveOrderItemMapper extends BaseMapper<LiveOrderItem>{
     /**
      * 查询订单详情
-     * 
+     *
      * @param itemId 订单详情主键
      * @return 订单详情
      */
@@ -21,7 +22,7 @@ public interface LiveOrderItemMapper extends BaseMapper<LiveOrderItem>{
 
     /**
      * 查询订单详情列表
-     * 
+     *
      * @param liveOrderItem 订单详情
      * @return 订单详情集合
      */
@@ -29,7 +30,7 @@ public interface LiveOrderItemMapper extends BaseMapper<LiveOrderItem>{
 
     /**
      * 新增订单详情
-     * 
+     *
      * @param liveOrderItem 订单详情
      * @return 结果
      */
@@ -37,7 +38,7 @@ public interface LiveOrderItemMapper extends BaseMapper<LiveOrderItem>{
 
     /**
      * 修改订单详情
-     * 
+     *
      * @param liveOrderItem 订单详情
      * @return 结果
      */
@@ -45,7 +46,7 @@ public interface LiveOrderItemMapper extends BaseMapper<LiveOrderItem>{
 
     /**
      * 删除订单详情
-     * 
+     *
      * @param itemId 订单详情主键
      * @return 结果
      */
@@ -53,9 +54,12 @@ public interface LiveOrderItemMapper extends BaseMapper<LiveOrderItem>{
 
     /**
      * 批量删除订单详情
-     * 
+     *
      * @param itemIds 需要删除的数据主键集合
      * @return 结果
      */
     int deleteLiveOrderItemByItemIds(String[] itemIds);
+
+    @Select("select * from live_order_item where order_id = #{orderId}")
+    List<LiveOrderItem> selectLiveOrderItemByOrderId(Long orderId);
 }

+ 8 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderMapper.java

@@ -3,8 +3,10 @@ package com.fs.live.mapper;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.live.domain.LiveOrder;
+import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderVo;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 订单Mapper接口
@@ -68,4 +70,10 @@ public interface LiveOrderMapper extends BaseMapper<LiveOrder>{
      * @return 订单集合
      */
     List<LiveOrder> getLiveOrderTimeGranularity(LiveOrderVo liveOrder);
+
+    @Select("select * from live_order where extend_order_id is null or extend_order_id = '' and status = 2")
+    List<LiveOrder> selectNotPushedLiveOrder();
+
+    @Select("select * from live_order where order_code = #{orderCode}")
+    LiveOrder selectFsUserVipOrderByOrderCode(String orderSn);
 }

+ 64 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderPaymentErrorMapper.java

@@ -0,0 +1,64 @@
+package com.fs.live.mapper;
+
+
+
+import com.fs.live.domain.LiveOrderPaymentError;
+
+import java.util.List;
+
+/**
+ * 错误表Mapper接口
+ *
+ * @author fs
+ * @date 2024-01-05
+ */
+public interface LiveOrderPaymentErrorMapper
+{
+    /**
+     * 查询错误表
+     *
+     * @param id 错误表主键
+     * @return 错误表
+     */
+    public LiveOrderPaymentError selectLiveOrderPaymentErrorById(Long id);
+
+    /**
+     * 查询错误表列表
+     *
+     * @param liveOrderPaymentError 错误表
+     * @return 错误表集合
+     */
+    public List<LiveOrderPaymentError> selectLiveOrderPaymentErrorList(LiveOrderPaymentError liveOrderPaymentError);
+
+    /**
+     * 新增错误表
+     *
+     * @param liveOrderPaymentError 错误表
+     * @return 结果
+     */
+    public int insertLiveOrderPaymentError(LiveOrderPaymentError liveOrderPaymentError);
+
+    /**
+     * 修改错误表
+     *
+     * @param liveOrderPaymentError 错误表
+     * @return 结果
+     */
+    public int updateLiveOrderPaymentError(LiveOrderPaymentError liveOrderPaymentError);
+
+    /**
+     * 删除错误表
+     *
+     * @param id 错误表主键
+     * @return 结果
+     */
+    public int deleteLiveOrderPaymentErrorById(Long id);
+
+    /**
+     * 批量删除错误表
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteLiveOrderPaymentErrorByIds(Long[] ids);
+}

+ 66 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderPaymentMapper.java

@@ -0,0 +1,66 @@
+package com.fs.live.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.live.domain.LiveOrderPayment;
+import org.apache.ibatis.annotations.Select;
+
+
+/**
+ * 支付明细Mapper接口
+ *
+ * @author fs
+ * @date 2025-08-07
+ */
+public interface LiveOrderPaymentMapper extends BaseMapper<LiveOrderPayment>{
+    /**
+     * 查询支付明细
+     *
+     * @param paymentId 支付明细主键
+     * @return 支付明细
+     */
+    LiveOrderPayment selectLiveOrderPaymentByPaymentId(Long paymentId);
+
+    /**
+     * 查询支付明细列表
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 支付明细集合
+     */
+    List<LiveOrderPayment> selectLiveOrderPaymentList(LiveOrderPayment liveOrderPayment);
+
+    /**
+     * 新增支付明细
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 结果
+     */
+    int insertLiveOrderPayment(LiveOrderPayment liveOrderPayment);
+
+    /**
+     * 修改支付明细
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 结果
+     */
+    int updateLiveOrderPayment(LiveOrderPayment liveOrderPayment);
+
+    /**
+     * 删除支付明细
+     *
+     * @param paymentId 支付明细主键
+     * @return 结果
+     */
+    int deleteLiveOrderPaymentByPaymentId(Long paymentId);
+
+    /**
+     * 批量删除支付明细
+     *
+     * @param paymentIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteLiveOrderPaymentByPaymentIds(Long[] paymentIds);
+
+    @Select("select * from live_order_payment where pay_code=#{payCode}")
+    LiveOrderPayment selectLiveOrderPaymentByPaymentCode(String payCode);
+}

+ 12 - 0
fs-service/src/main/java/com/fs/live/param/LiveOrderConfirmParam.java

@@ -0,0 +1,12 @@
+package com.fs.live.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class LiveOrderConfirmParam implements Serializable {
+    Long userId;
+
+
+}

+ 1 - 1
fs-service/src/main/java/com/fs/live/service/ILiveGoodsService.java

@@ -85,7 +85,7 @@ public interface ILiveGoodsService extends IService<LiveGoods>{
      * @return 直播商品集合
      */
     List<LiveGoodsVo> selectProductListByLiveId(LiveGoods liveGoods);
-    Map<String, Object> getStoreByLiveId(Long liveId);
+    R getStoreByLiveId(Long liveId);
 
     int insertLiveGoodsAdmin(Map<String, Object> payload, SysUser user);
 

+ 61 - 0
fs-service/src/main/java/com/fs/live/service/ILiveOrderPaymentService.java

@@ -0,0 +1,61 @@
+package com.fs.live.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.live.domain.LiveOrderPayment;
+
+/**
+ * 支付明细Service接口
+ *
+ * @author fs
+ * @date 2025-08-07
+ */
+public interface ILiveOrderPaymentService extends IService<LiveOrderPayment>{
+    /**
+     * 查询支付明细
+     *
+     * @param paymentId 支付明细主键
+     * @return 支付明细
+     */
+    LiveOrderPayment selectLiveOrderPaymentByPaymentId(Long paymentId);
+
+    /**
+     * 查询支付明细列表
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 支付明细集合
+     */
+    List<LiveOrderPayment> selectLiveOrderPaymentList(LiveOrderPayment liveOrderPayment);
+
+    /**
+     * 新增支付明细
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 结果
+     */
+    int insertLiveOrderPayment(LiveOrderPayment liveOrderPayment);
+
+    /**
+     * 修改支付明细
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 结果
+     */
+    int updateLiveOrderPayment(LiveOrderPayment liveOrderPayment);
+
+    /**
+     * 批量删除支付明细
+     *
+     * @param paymentIds 需要删除的支付明细主键集合
+     * @return 结果
+     */
+    int deleteLiveOrderPaymentByPaymentIds(Long[] paymentIds);
+
+    /**
+     * 删除支付明细信息
+     *
+     * @param paymentId 支付明细主键
+     * @return 结果
+     */
+    int deleteLiveOrderPaymentByPaymentId(Long paymentId);
+}

+ 71 - 1
fs-service/src/main/java/com/fs/live/service/ILiveOrderService.java

@@ -1,9 +1,14 @@
 package com.fs.live.service;
 
+import java.text.ParseException;
 import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.common.core.domain.R;
+import com.fs.course.param.FsUserLiveOrderPayUParam;
+import com.fs.live.domain.LiveGoods;
 import com.fs.live.domain.LiveOrder;
+import com.fs.live.param.LiveOrderConfirmParam;
+import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderVo;
 
 /**
@@ -56,7 +61,7 @@ public interface ILiveOrderService extends IService<LiveOrder>{
     /**
      * 删除订单信息
      *
-     * @param orderId 订单主键
+     * @param  订单主键
      * @return 结果
      */
     //int deleteLiveOrderByOrderId(String orderId);
@@ -70,4 +75,69 @@ public interface ILiveOrderService extends IService<LiveOrder>{
      * @param liveOrder
      */
     R getLiveOrderTimeGranularity(LiveOrderVo liveOrder);
+
+    /**
+     * 同步物流信息
+     * @param id
+     * @return
+     */
+    R syncExpress(Long id);
+
+    /**
+     * 确认收货
+     * @param orderId
+     * @return
+     */
+    int getGoods(Long orderId);
+
+    /**
+     * 修改物流信息
+     * @param orderId
+     * @param mailNo
+     * @param expressCode
+     * @param expressName
+     */
+    void updateDeliveryOrder(Long orderId, String mailNo, String expressCode, String expressName);
+
+    /**
+     * 获取订单商品列表
+     * @param orderId
+     * @return
+     */
+    List<LiveGoodsVo> selectLiveOrderItemList(String orderId);
+
+    /**
+     * 创建订单
+     * @param liveOrder
+     * @return
+     */
+    R createLiveOrder(LiveOrder liveOrder);
+
+    /**
+     * 订单确认
+     * @param param
+     * @return
+     */
+    R confirmOrder(LiveOrderConfirmParam param);
+
+    /**
+     * 获取未推送的订单
+     * @return
+     */
+    List<LiveOrder> selectNotPushedLiveOrder();
+
+    /**
+     * 推送订单
+     * @param liveOrder
+     */
+    void pushLiveOrder(LiveOrder liveOrder)  throws ParseException;
+
+    R aliPayment(FsUserLiveOrderPayUParam param);
+
+    R payConfirm(String orderSn,String payCode, String tradeNo,String payType,Integer type);
+
+    R wxPayment(FsUserLiveOrderPayUParam param);
+
+
+    int tuiOrder(Long orderId);
 }

+ 8 - 15
fs-service/src/main/java/com/fs/live/service/impl/LiveGoodsServiceImpl.java

@@ -118,21 +118,14 @@ public class LiveGoodsServiceImpl extends ServiceImpl<LiveGoodsMapper, LiveGoods
     }
 
     @Override
-    public Map<String, Object> getStoreByLiveId(Long liveId) {
-        Map<String, Object> map = new HashMap<>();
-        //获取店铺id
-        Long storeId = baseMapper.selectStoreIdByLiveId(liveId);
-        if(storeId == null)
-            return null;
-        //获取店铺信息
-        FsStore fsStore = fsStoreService.selectFsStoreByStoreId(storeId);
-        //获取店铺商品信息
-        FsStoreProduct fsStoreProduct = new FsStoreProduct();
-        fsStoreProduct.setStoreId(fsStore.getStoreId());
-        List<FsStoreProduct> fsStoreProducts = fsStoreProductService.selectFsStoreProductList(fsStoreProduct);
-        map.put("store",fsStore);
-        map.put("products",fsStoreProducts);
-        return map;
+    public R getStoreByLiveId(Long liveId) {
+        LiveGoods liveGoods = new LiveGoods();
+        liveGoods.setLiveId(liveId);
+        List<LiveGoodsVo> liveGoodsVos = baseMapper.selectProductListByLiveId(liveGoods);
+        if (liveGoodsVos.isEmpty()) {
+            return R.ok();
+        }
+        return R.ok().put("data", liveGoodsVos);
     }
 
 

+ 93 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderPaymentServiceImpl.java

@@ -0,0 +1,93 @@
+package com.fs.live.service.impl;
+
+import java.util.List;
+import com.fs.common.utils.DateUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.live.domain.LiveOrderPayment;
+import com.fs.live.mapper.LiveOrderPaymentMapper;
+import com.fs.live.service.ILiveOrderPaymentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 支付明细Service业务层处理
+ *
+ * @author fs
+ * @date 2025-08-07
+ */
+@Service
+public class LiveOrderPaymentServiceImpl extends ServiceImpl<LiveOrderPaymentMapper, LiveOrderPayment> implements ILiveOrderPaymentService {
+
+    /**
+     * 查询支付明细
+     *
+     * @param paymentId 支付明细主键
+     * @return 支付明细
+     */
+    @Override
+    public LiveOrderPayment selectLiveOrderPaymentByPaymentId(Long paymentId)
+    {
+        return baseMapper.selectLiveOrderPaymentByPaymentId(paymentId);
+    }
+
+    /**
+     * 查询支付明细列表
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 支付明细
+     */
+    @Override
+    public List<LiveOrderPayment> selectLiveOrderPaymentList(LiveOrderPayment liveOrderPayment)
+    {
+        return baseMapper.selectLiveOrderPaymentList(liveOrderPayment);
+    }
+
+    /**
+     * 新增支付明细
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 结果
+     */
+    @Override
+    public int insertLiveOrderPayment(LiveOrderPayment liveOrderPayment)
+    {
+        liveOrderPayment.setCreateTime(DateUtils.getNowDate());
+        return baseMapper.insertLiveOrderPayment(liveOrderPayment);
+    }
+
+    /**
+     * 修改支付明细
+     *
+     * @param liveOrderPayment 支付明细
+     * @return 结果
+     */
+    @Override
+    public int updateLiveOrderPayment(LiveOrderPayment liveOrderPayment)
+    {
+        return baseMapper.updateLiveOrderPayment(liveOrderPayment);
+    }
+
+    /**
+     * 批量删除支付明细
+     *
+     * @param paymentIds 需要删除的支付明细主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveOrderPaymentByPaymentIds(Long[] paymentIds)
+    {
+        return baseMapper.deleteLiveOrderPaymentByPaymentIds(paymentIds);
+    }
+
+    /**
+     * 删除支付明细信息
+     *
+     * @param paymentId 支付明细主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveOrderPaymentByPaymentId(Long paymentId)
+    {
+        return baseMapper.deleteLiveOrderPaymentByPaymentId(paymentId);
+    }
+}

+ 798 - 4
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -1,5 +1,9 @@
 package com.fs.live.service.impl;
 
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -8,21 +12,86 @@ import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.ip.IpUtils;
+import com.fs.company.domain.Company;
+import com.fs.company.domain.CompanyDept;
+import com.fs.company.domain.CompanyUser;
+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.WxPayProperties;
+import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsUserVipOrder;
+import com.fs.course.param.FsUserLiveOrderPayUParam;
+import com.fs.erp.domain.ErpOrder;
+import com.fs.erp.domain.ErpOrderItem;
+import com.fs.erp.domain.ErpOrderPayment;
+import com.fs.erp.dto.ErpOrderResponse;
+import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.*;
+import com.fs.his.dto.*;
+import com.fs.his.enums.FsStoreOrderLogEnum;
+import com.fs.his.enums.FsStoreOrderStatusEnum;
+import com.fs.his.enums.ShipperCodeEnum;
+import com.fs.his.mapper.FsStoreProductAttrValueMapper;
+import com.fs.his.mapper.FsUserMapper;
+import com.fs.his.service.IFsExpressService;
+import com.fs.his.service.IFsStoreProductService;
+import com.fs.his.service.IFsUserAddressService;
 import com.fs.his.service.IFsUserService;
-import com.fs.live.domain.Live;
-import com.fs.live.mapper.LiveMapper;
+import com.fs.his.utils.ConfigUtil;
+import com.fs.hisapi.param.CreateOrderParam;
+import com.fs.hisapi.param.RecipeDetailParam;
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.service.HuiFuService;
+import com.fs.live.domain.*;
+import com.fs.live.mapper.*;
+import com.fs.live.param.LiveOrderConfirmParam;
+import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderVo;
+import com.fs.qw.service.IQwExternalContactService;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.mapper.SysConfigMapper;
+import com.fs.system.service.ISysConfigService;
+import com.fs.tzBankPay.TzBankService.TzBankService;
+import com.fs.tzBankPay.doman.PayCreateOrder;
+import com.fs.tzBankPay.doman.PayCreateOrderResult;
+import com.fs.tzBankPay.doman.PayType;
+import com.fs.tzBankPay.doman.TzBankResult;
+import com.fs.ybPay.domain.CreateWxOrderResult;
+import com.fs.ybPay.dto.WxJspayDTO;
+import com.fs.ybPay.service.IPayService;
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
+import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.list.TreeList;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
-import com.fs.live.mapper.LiveOrderMapper;
-import com.fs.live.domain.LiveOrder;
 import com.fs.live.service.ILiveOrderService;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import static com.fs.his.utils.PhoneUtil.decryptPhone;
 
 /**
  * 订单Service业务层处理
@@ -31,13 +100,86 @@ import org.springframework.transaction.annotation.Transactional;
  * @date 2025-07-08
  */
 @Service
+@Slf4j
 public class LiveOrderServiceImpl extends ServiceImpl<LiveOrderMapper, LiveOrder> implements ILiveOrderService {
 
     private final RedisCache redisCache;
 
+
+
     @Autowired
     private LiveMapper liveMapper;
 
+    @Autowired
+    private WxPayProperties wxPayProperties;
+
+    @Autowired
+    private IPayService payService;
+
+    @Autowired
+    private WxPayService wxPayService;
+
+    @Autowired
+    private LiveGoodsMapper liveGoodsMapper;
+
+    @Autowired
+    private IFsExpressService expressService;
+
+    @Autowired
+    private LiveOrderItemMapper liveOrderItemMapper;
+
+    @Autowired
+    private IFsStoreProductService fsStoreProductService;
+
+    @Autowired
+    FsUserMapper userMapper;
+
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+    @Autowired
+    CloudHostProper cloudHostProper;
+
+    @Autowired
+    private ICompanyService companyService;
+
+    @Autowired
+    ICompanyUserService companyUserService;
+
+    @Autowired
+    private ICompanyDeptService companyDeptService;
+
+    @Autowired
+    private FsStoreProductAttrValueMapper fsStoreProductAttrValueMapper;
+
+    @Autowired
+    private IFsUserAddressService fsUserAddressService;
+
+    @Autowired
+    private ISysConfigService configService;
+
+    @Autowired
+    private LiveOrderPaymentMapper liveOrderPaymentMapper;
+
+    @Autowired
+    private TzBankService tzBankService;
+
+    @Autowired
+    private HuiFuService huiFuService;
+
+    @Autowired
+    private IQwExternalContactService qwExternalContactService;
+
+    @Autowired
+    private LiveOrderPaymentErrorMapper liveOrderPaymentErrorMapper;
+    @Autowired
+    private SysConfigMapper sysConfigMapper;
+
+
     public LiveOrderServiceImpl(RedisCache redisCache) {
         this.redisCache = redisCache;
     }
@@ -45,6 +187,480 @@ public class LiveOrderServiceImpl extends ServiceImpl<LiveOrderMapper, LiveOrder
     @Autowired
     private IFsUserService fsUserService;
 
+    @Override
+    public void pushLiveOrder(LiveOrder order) throws ParseException {
+        //判断是否开启erp
+        FsSysConfig sysConfig = configUtil.getSysConfig();
+        Integer erpOpen = sysConfig.getErpOpen();
+        if (erpOpen==null || erpOpen==0){
+            return;
+        }
+        IErpOrderService erpOrderService = gyOrderService;
+        if(order.getStatus()!=2) return;
+        ErpOrder erpOrder=new ErpOrder();
+        if (order.getCompanyId()!=null){
+            erpOrder.setVip_code(order.getUserId() +order.getCompanyId().toString());
+        }else {
+            erpOrder.setVip_code(order.getUserId());
+        }
+        erpOrder.setPlatform_code(order.getOrderCode());
+        erpOrder.setShop_code(sysConfig.getErpShopCode());
+        erpOrder.setSeller_memo(order.getRemark());
+
+        List<ErpOrderPayment> payments=new ArrayList<>();
+        ErpOrderPayment payment=new ErpOrderPayment();
+        payment.setPay_type_code("weixin");
+        payment.setPayment(order.getPayMoney().doubleValue());
+        if(order.getPayTime()!=null){
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String timeString = sdf.format(order.getPayTime());
+            Date date = sdf.parse(timeString); // 时间格式转为时间戳
+            long timeLong = date.getTime();
+            payment.setPaytime(new Timestamp(timeLong));
+        }
+        payments.add(payment);
+
+        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 {
+                        express=expressService.selectFsExpressByOmsCode("SF.0235469535");
+                    }
+                }else {
+                    express=expressService.selectFsExpressByOmsCode("SF.0235469535");
+                }
+                //物流代发互联网医院顺
+                erpOrder.setExpress_code(express.getOmsCode());
+                order.setDeliveryName(express.getName());
+                order.setDeliveryCode(express.getCode());
+                //物流代收金额
+                ErpOrderPayment codPayment = new ErpOrderPayment();
+                codPayment.setPay_type_code("cod");
+                BigDecimal toal = order.getPayRemain();
+                codPayment.setPayment(toal.doubleValue());
+                payments.add(codPayment);
+                erpOrder.setCod(true);
+            }
+        }
+
+        erpOrder.setPayments(payments);
+        if(order.getCompanyId()!=null){
+            Company company=companyService.selectCompanyById(order.getCompanyId());
+            if(company!=null){
+                erpOrder.setSeller_memo(company.getCompanyName());
+            }
+        }
+        if(order.getCompanyUserId()!=null){
+            CompanyUser companyUser=companyUserService.selectCompanyUserById(order.getCompanyUserId());
+            if(companyUser!=null){
+                CompanyDept dept=companyDeptService.selectCompanyDeptById(companyUser.getDeptId());
+                if(dept!=null){
+                    List<String> names=companyDeptService.selectCompanyDeptNamesByIds(dept.getAncestors());
+                    if(names!=null&&names.size()>0){
+                        //写备注
+                        erpOrder.setSeller_memo(erpOrder.getSeller_memo()+"-"+StringUtils.join(names, ",")+","+dept.getDeptName() );
+                    }
+                }
+                erpOrder.setSeller_memo(erpOrder.getSeller_memo()+"-"+companyUser.getNickName());
+            }
+        }
+
+        ErpRemarkDTO remarkDTO=new ErpRemarkDTO();
+        remarkDTO.setTotalPrice(order.getTotalPrice());
+        remarkDTO.setPayPrice(order.getPayPrice());
+        remarkDTO.setDeliveryMoney(order.getPayDelivery());
+        remarkDTO.setPayMoney(order.getPayMoney());
+        remarkDTO.setCouponMoney(order.getDiscountMoney());
+        remarkDTO.setOrderId(order.getOrderCode());
+        remarkDTO.setYdMoney(order.getPayPrice().subtract(order.getPayMoney().subtract(order.getPayDelivery())));
+
+        if(order.getPayTime()!=null){
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String format = sdf.format(order.getPayTime());
+            remarkDTO.setPayTime(format);
+        }
+
+        erpOrder.setSeller_memo(erpOrder.getSeller_memo()+JSONUtil.toJsonStr(remarkDTO));
+        erpOrder.setOrder_type_code("order");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        erpOrder.setDeal_datetime(sdf.format(new Date()));
+        FsStoreOrderItem itemMap=new FsStoreOrderItem();
+        itemMap.setOrderId(order.getOrderId());
+        List<LiveOrderItem> liveOrderItems = liveOrderItemMapper.selectLiveOrderItemByOrderId(order.getOrderId());
+        List<ErpOrderItem> details=new ArrayList<>();
+        for (LiveOrderItem liveOrderItem : liveOrderItems) {
+            FsStoreCartDTO cartDTO= JSONUtil.toBean(liveOrderItem.getJsonInfo(),FsStoreCartDTO.class);
+            ErpOrderItem item=new ErpOrderItem();
+            item.setItem_code(cartDTO.getBarCode().trim());
+            item.setPrice(cartDTO.getPrice().toString());
+            item.setQty(cartDTO.getNum());
+            item.setRefund(0);
+            details.add(item);
+        }
+        // todo yhq
+        erpOrder.setDetails(details);
+        erpOrder.setReceiver_name(order.getUserName().replaceAll("[^\\u4e00-\\u9fa5a-zA-Z0-9]", ""));
+        //2025.6.27 金牛要求erp推送电话可以设置默认 不影响其他推送
+        String phone = null;
+        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);
+        }
+        String[] address=order.getUserAddress().split(" ");
+        if (address.length<3){
+            String kdnAddress = fsUserAddressService.getKdnAddress(order.getUserAddress());
+            Map<String,Object> addDAta = (Map<String,Object>)JSON.parse(kdnAddress);
+            Map<String, String> add = (Map<String, String>)addDAta.get("Data");
+            erpOrder.setReceiver_province(add.get("ProvinceName"));
+            erpOrder.setReceiver_city(add.get("CityName"));
+            erpOrder.setReceiver_district(add.get("ExpAreaName"));
+            erpOrder.setReceiver_address(add.get("StreetName")+add.get("Address"));
+        }else {
+            erpOrder.setReceiver_province(address[0]);
+            erpOrder.setReceiver_city(address[1]);
+            erpOrder.setReceiver_district(address[2]);
+            //处理地址多空隔问题
+            if(address.length>3){
+                StringBuffer addrs=new StringBuffer();
+                for(int i=3;i<address.length;i++){
+                    addrs.append(address[i]);
+                }
+                erpOrder.setReceiver_address(addrs.toString());
+            }
+            else if(address.length==3){
+                erpOrder.setReceiver_address(address[2]);
+            }
+        }
+
+        erpOrder.setReceiver_address(erpOrder.getReceiver_address().replace("+","加"));
+        erpOrder.setReceiver_address(erpOrder.getReceiver_address().replace("\n",""));
+        ErpOrderResponse response= erpOrderService.addOrder(erpOrder);
+        log.info("ErpCreate:"+order.getOrderCode()+":"+JSONUtil.toJsonStr(response));
+        if(response.getSuccess()){
+
+            //支付成功后 将订单号写入待发货的REDIS中
+            redisCache.setCacheObject("delivery"+":"+response.getCode(),order.getOrderCode());
+            //写入外部订单号
+            order.setExtendOrderId(response.getCode());
+            baseMapper.updateLiveOrder(order);
+        }
+
+    }
+
+    @Override
+    public R aliPayment(FsUserLiveOrderPayUParam param) {
+        LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+        if (order == null) {
+            return R.error("订单不存在");
+        }
+        if (order.getStatus() != 1) {
+            return R.error("非法操作");
+        }
+        FsUser user = userMapper.selectFsUserByUserId(param.getUserId());
+        if(user!=null){
+            if(order.getPayMoney().compareTo(new BigDecimal(0))==1){
+                // todo yhq
+                String payCode =  OrderCodeUtils.getOrderSn();
+//                String payCode = String.valueOf(UUID.randomUUID());
+                if(StringUtils.isEmpty(payCode)){
+                    return R.error("订单生成失败,请重试");
+                }
+                String json = configService.selectConfigByKey("his.pay");
+                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+                LiveOrderPayment storePayment=new LiveOrderPayment();
+                storePayment.setStatus(0);
+                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setBusinessCode(order.getOrderCode());
+                storePayment.setPayCode(payCode);
+                // todo yhq
+//                storePayment.setPayMoney(order.getPayMoney());
+                storePayment.setPayMoney(new BigDecimal("0.01"));
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("alipay");
+                storePayment.setBusinessType(5);
+                storePayment.setRemark("直播订单支付");
+//                storePayment.setOpenId(user.getMpOpenId());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessId(order.getOrderId().toString());
+                if(liveOrderPaymentMapper.insertLiveOrderPayment(storePayment)>0){
+
+                    if (payConfigDTO.getType().equals("yb")) {
+                        return R.error("支付暂不可用!");
+                    } else if (payConfigDTO.getType().equals("tz")) {
+                        PayCreateOrder o = new PayCreateOrder();
+                        o.setOrderNo("appLive" + storePayment.getPayCode()); // 业务系统订单号
+                        o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
+                        o.setBusinessCstNo(order.getUserId().toString()); // 业务平台客户号
+                        String phone="";
+                        if (user.getPhone()!=null&&user.getPhone().length()>4){
+                            phone=user.getPhone().substring(user.getPhone().length()-4);
+                        }
+                        o.setPayerName("微信用户"+phone);
+                        o.setGoodsInfo("直播订单支付"); // 订单信息
+//                        o.setOpenId(user.getMpOpenId());
+                        o.setOrderType(5);
+                        o.setOrderId(order.getOrderId().toString());
+                        o.setPayType(Arrays.asList(PayType.支付宝条码支付.getCode()));
+                        TzBankResult<PayCreateOrderResult> result = tzBankService.createOrder(o);
+                        LiveOrderPayment mt=new LiveOrderPayment();
+                        mt.setPaymentId(storePayment.getPaymentId());
+                        mt.setTradeNo(result.getBody().getOrderFlowNo());
+                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                        return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
+                    }else if (payConfigDTO.getType().equals("hf")) {
+                        HuiFuCreateOrder o = new HuiFuCreateOrder();
+                        o.setTradeType("A_NATIVE");
+//                        o.setOpenid(user.getMaOpenId());
+                        o.setReqSeqId("appLive-"+storePayment.getPayCode());
+                        o.setTransAmt(storePayment.getPayMoney().toString());
+                        o.setGoodsDesc("直播订单支付");
+                        HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                        LiveOrderPayment mt=new LiveOrderPayment();
+                        mt.setPaymentId(storePayment.getPaymentId());
+                        mt.setTradeNo(result.getHf_seq_id());
+                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                        return R.ok().put("isPay", 0).put("data", result).put("type", "hf");
+                    }
+                }
+            }
+            else{
+                this.payConfirm(order.getOrderCode(),"","","",2);
+                return R.ok().put("isPay",1);
+            }
+        }
+        else{
+            return R.error("用户不存在");
+        }
+        return R.error();
+
+    }
+
+    @Override
+    @Transactional
+    public R payConfirm(String orderSn, String payCode, String tradeNo, String payType, Integer type) {
+        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+        try {
+            LiveOrder order=null;
+            if(type.equals(1)){
+                LiveOrderPayment storePayment = liveOrderPaymentMapper.selectLiveOrderPaymentByPaymentCode(payCode);
+                if (storePayment!=null){
+                    if(storePayment.getStatus().equals(0)){
+                        LiveOrderPayment paymentMap=new LiveOrderPayment();
+                        paymentMap.setPaymentId(storePayment.getPaymentId());
+                        paymentMap.setStatus(1);
+                        paymentMap.setPayTime(new Date());
+                        paymentMap.setTradeNo(tradeNo);
+                        if(payType.equals(PayType.微信小程序支付.getCode())){
+                            paymentMap.setPayTypeCode(PayType.微信小程序支付.name());
+                        }
+                        else if(payType.equals(PayType.支付宝条码支付.getCode())){
+                            paymentMap.setPayTypeCode(PayType.支付宝条码支付.name());
+                        }
+                        liveOrderPaymentMapper.updateLiveOrderPayment(paymentMap);
+                        order=baseMapper.selectFsUserVipOrderByOrderCode(storePayment.getBusinessId());
+                    }
+                }
+                else{
+                    log.info("支付单号不存在:"+payCode);
+                    return R.error("支付单号不存在");
+                }
+            }
+            else if(type.equals(2)){
+                order=baseMapper.selectFsUserVipOrderByOrderCode(orderSn);
+            }
+            if(order.getStatus()!=0){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return R.error("非法操作");
+            }
+            order.setStatus(2);
+            order.setPayTime(new Date());
+            baseMapper.updateLiveOrder(order);
+            return R.ok();
+        }catch (Exception e){
+            log.info("支付错误:"+e.getMessage());
+            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+            LiveOrderPaymentError err = new LiveOrderPaymentError();
+            err.setOrderNo(orderSn);
+            err.setOrderFlowNo(tradeNo);
+            err.setStatus(0);
+            err.setMsg(e.getMessage());
+            err.setCreateTime(DateUtils.getNowDate());
+            liveOrderPaymentErrorMapper.insertLiveOrderPaymentError(err);
+            return R.error();
+        }
+    }
+
+    @Override
+    public R wxPayment(FsUserLiveOrderPayUParam param) {
+        LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
+        if (order == null) {
+            return R.error("订单不存在");
+        }
+        if (order.getStatus()!=1){
+            return R.error("非法操作");
+        }
+        FsUser user = userMapper.selectFsUserByUserId(param.getUserId());
+        if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())) {
+            if (order.getPayMoney().compareTo(new BigDecimal(0)) == 0) {
+                this.payConfirm(order.getOrderCode(), "", "", "", 2);
+                return R.ok().put("isPay", 1);
+            } else {
+                String json = configService.selectConfigByKey("his.pay");
+                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+                payConfigDTO.setType("wx");
+                // todo yhq
+                String payCode =  OrderCodeUtils.getOrderSn();
+//                String payCode = String.valueOf(UUID.randomUUID());
+                payCode = payCode.substring(0, payCode.lastIndexOf('-'));
+                if(StringUtils.isEmpty(payCode)){
+                    return R.error("订单生成失败,请重试");
+                }
+                LiveOrderPayment storePayment = new LiveOrderPayment();
+                storePayment.setStatus(0);
+                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setBusinessCode(order.getOrderCode());
+                storePayment.setPayCode(payCode);
+                // todo yhq
+                storePayment.setPayMoney(order.getPayMoney());
+                storePayment.setPayMoney(new BigDecimal("0.01"));
+                storePayment.setCreateTime(new Date());
+                storePayment.setPayTypeCode("weixin");
+                storePayment.setBusinessType(5);
+                storePayment.setRemark("直播商品订单支付");
+                storePayment.setOpenId(user.getMaOpenId());
+                storePayment.setUserId(user.getUserId());
+                storePayment.setBusinessId(order.getOrderId().toString());
+                if (liveOrderPaymentMapper.insertLiveOrderPayment(storePayment) > 0) {
+                    if (payConfigDTO.getType().equals("wx")) {
+                        //创建微信订单
+                        WxPayConfig payConfig = new WxPayConfig();
+                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
+                        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+                        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(wxPayProperties.getNotifyUrl());
+                        wxPayService.setConfig(payConfig);
+                        WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                        orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
+                        orderRequest.setBody("直播商品订单支付");
+                        orderRequest.setOutTradeNo("appLive-" + 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);
+                            log.info("订单结果:"+orderResult);
+                            return R.ok().put("data", orderResult).put("type", "wx").put("isPay", 0);
+                        } catch (WxPayException e) {
+                            e.printStackTrace();
+                            throw new CustomException("支付失败" + e.getMessage());
+                        }
+                    } else if (payConfigDTO.getType().equals("yb")) {
+                        WxJspayDTO p = new WxJspayDTO();
+                        // 使用setter方法为对象赋值
+                        p.setPayMoney(storePayment.getPayMoney().toString());
+                        p.setLowOrderId("appLive-" + storePayment.getPayCode());
+                        p.setBody("直播商品订单支付");
+                        p.setIsMinipg("1");
+                        p.setOpenId(user.getMaOpenId());
+                        p.setAttach("");
+                        p.setStoreid("0");
+                        CreateWxOrderResult wxOrder = payService.createWxOrder(p);
+                        if (wxOrder.getStatus().equals("100")) {
+                            LiveOrderPayment mt = new LiveOrderPayment();
+                            mt.setPaymentId(storePayment.getPaymentId());
+                            mt.setTradeNo(wxOrder.getUpOrderId());
+                            liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                            return R.ok().put("isPay", 0).put("data", wxOrder).put("type", "yb");
+                        } else {
+                            throw new CustomException("支付失败");
+                        }
+                    } else if (payConfigDTO.getType().equals("tz")) {
+                        PayCreateOrder o = new PayCreateOrder();
+                        o.setOrderNo("appLive" + storePayment.getPayCode()); // 业务系统订单号
+                        o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
+                        o.setBusinessCstNo(order.getUserId().toString()); // 业务平台客户号
+                        String phone = "";
+                        if (user.getPhone() != null && user.getPhone().length() > 4) {
+                            phone = user.getPhone().substring(user.getPhone().length() - 4);
+                        }
+                        o.setPayerName("微信用户" + phone);
+                        o.setGoodsInfo("直播商品订单支付"); // 订单信息
+                        o.setOpenId(user.getMaOpenId());
+                        o.setOrderType(5);
+                        o.setOrderId(order.getOrderId().toString());
+                        TzBankResult<PayCreateOrderResult> result = tzBankService.createOrder(o);
+                        LiveOrderPayment mt = new LiveOrderPayment();
+                        mt.setPaymentId(storePayment.getPaymentId());
+                        mt.setTradeNo(result.getBody().getOrderFlowNo());
+                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                        return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
+                    } else if (payConfigDTO.getType().equals("hf")) {
+                        HuiFuCreateOrder o = new HuiFuCreateOrder();
+                        o.setTradeType("T_MINIAPP");
+                        o.setOpenid(user.getMaOpenId());
+                        o.setReqSeqId("appLive-" + storePayment.getPayCode());
+                        o.setTransAmt(storePayment.getPayMoney().toString());
+                        o.setGoodsDesc("直播商品订单支付");
+                        HuifuCreateOrderResult result = huiFuService.createOrder(o);
+                        LiveOrderPayment mt = new LiveOrderPayment();
+                        mt.setPaymentId(storePayment.getPaymentId());
+                        mt.setTradeNo(result.getHf_seq_id());
+                        liveOrderPaymentMapper.updateLiveOrderPayment(mt);
+                        return R.ok().put("isPay", 0).put("data", result).put("type", "hf");
+                    }
+                } else {
+                    return R.error("用户OPENID不存在");
+                }
+            }
+        }
+        return R.error();
+    }
+
+    @Override
+    public int tuiOrder(Long orderId) {
+        LiveOrder liveOrder = new LiveOrder();
+        liveOrder.setOrderId(orderId);
+        try {
+            pushLiveOrder(liveOrder);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return 1;
+    }
+
     /**
      * 查询订单
      *
@@ -194,6 +810,184 @@ public class LiveOrderServiceImpl extends ServiceImpl<LiveOrderMapper, LiveOrder
 
     }
 
+    @Override
+    @Transactional
+    public R syncExpress(Long id) {
+        LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(id));
+        String lastFourNumber = "";
+        if (order.getDeliveryCode().equals(ShipperCodeEnum.SF.getValue())) {
+            lastFourNumber = order.getUserPhone();
+            if (lastFourNumber.length() == 11) {
+                lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+            }else if(lastFourNumber.length() >11){
+                String jm = decryptPhone(lastFourNumber);
+                lastFourNumber = StrUtil.sub(jm, jm.length(), -4);
+            }
+        }
+        ExpressInfoDTO dto=expressService.getExpressInfo(order.getOrderCode(),order.getDeliveryCode(),order.getDeliverySn(),lastFourNumber);
+        log.info("快递鸟查询dto:{}", JSONUtil.toJsonStr(dto));
+        if (!dto.isSuccess()){
+            return R.error(dto.getReason());
+        }
+        if("0".equals(dto.getStateEx())&&"0".equals(dto.getState())){
+            lastFourNumber = "19923690275";
+            if (order.getDeliveryCode().equals(ShipperCodeEnum.SF.getValue())) {
+                lastFourNumber = order.getUserPhone();
+                if (lastFourNumber.length() == 11) {
+                    lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+                }
+            }
+            dto=expressService.getExpressInfo(order.getOrderCode(),order.getDeliveryCode(),order.getDeliverySn(),lastFourNumber);
+        }
+        LiveOrder updateEntity = new LiveOrder();
+        updateEntity.setOrderId(order.getOrderId());
+        updateEntity.setDeliveryStatus(Integer.parseInt(dto.getState()));
+        updateEntity.setDeliveryType(dto.getStateEx());
+        baseMapper.updateLiveOrder(updateEntity);
+        //如果是正常签收,更新订单状态
+        if(dto.getState().equals("3")&&(dto.getStateEx().equals("301")||dto.getStateEx().equals("302")||dto.getStateEx().equals("304")||dto.getStateEx().equals("311"))){
+            this.getGoods(order.getOrderId());
+        }
+        return R.ok();
+    }
+
+    @Override
+    public int getGoods(Long orderId) {
+        // todo yhq
+        LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
+        if (order==null)throw new CustomException("订单不存在");
+        if (order.getStatus()!= FsStoreOrderStatusEnum.STATUS_3.getValue())throw new CustomException("非法更改");
+        LiveOrder updateEntity = new LiveOrder();
+        updateEntity.setOrderId(order.getOrderId());
+        updateEntity.setUpdateTime(new DateTime());
+        updateEntity.setFinishTime(new Date());
+        updateEntity.setStatus(FsStoreOrderStatusEnum.STATUS_4.getValue());
+        log.info("确认收货:"+orderId);
+//        logger.info("确认收货:"+orderId);
+//        if (order.getCompanyId()!=null&&order.getTuiMoneyStatus()==0&&order.getPayType()==1){
+//            logger.info("分佣:"+orderId);
+//            companyService.addCompanyMoney(order);
+//            o1.setTuiMoneyTime(new Date());
+//        }
+//        fsUserWatchService.addUserWatch(order);
+//        int i = fsStoreOrderMapper.updateFsStoreOrder(o1);
+//        fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.FINISH_ORDER.getValue(),
+//                FsStoreOrderLogEnum.FINISH_ORDER.getDesc());
+
+        int i = baseMapper.updateLiveOrder(updateEntity);
+
+        return i;
+    }
+
+    @Override
+    public void updateDeliveryOrder(Long orderId, String deliveryId, String deliverCode, String expressName) {
+        LiveOrder existOrder = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
+        if (existOrder != null) {
+            FsExpress fsExpress = expressService.selectFsExpressByOmsCode(deliverCode);
+            if (fsExpress != null) {
+                LiveOrder updateEntity = new LiveOrder();
+                updateEntity.setOrderId(existOrder.getOrderId());
+                updateEntity.setDeliveryName(expressName);
+                updateEntity.setDeliverySn(deliveryId);
+                updateEntity.setDeliverySendTime(new Date());
+                baseMapper.updateLiveOrder(updateEntity);
+                // 订阅物流回调
+                String lastFourNumber = "";
+                if (fsExpress.getCode().equals(ShipperCodeEnum.SF.getValue())) {
+                    lastFourNumber = existOrder.getUserPhone();
+                    if (lastFourNumber.length() == 11) {
+                        lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
+                    }
+                }
+                expressService.subscribeEspress(existOrder.getOrderCode(),fsExpress.getCode(),deliveryId,lastFourNumber);
+            }
+        }
+    }
+
+    @Override
+    public List<LiveGoodsVo> selectLiveOrderItemList(String orderId) {
+        LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(orderId);
+        return liveGoodsMapper.selectProductListByOrder(liveOrder);
+    }
+
+    @Override
+    @Transactional
+    public R createLiveOrder(LiveOrder liveOrder) {
+//        FsUser user=userMapper.selectFsUserByUserId(Long.valueOf(liveOrder.getUserId()));
+//        if(user.getStatus()!=1){
+//            return R.error("非法用户操作");
+//        }
+        String orderKey= redisCache.getCacheObject("orderKey:"+liveOrder.getOrderKey());
+        if (StringUtils.isEmpty(orderKey)) {
+            return R.error("订单已过期");
+        }
+        if(liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
+        if(liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
+        if(liveOrder.getUserName() == null) return R.error("用户名不能为空");
+        if(liveOrder.getUserPhone() == null) return R.error("用户手机号不能为空");
+        if(liveOrder.getUserAddress() == null) return R.error("用户地址不能为空");
+        if(liveOrder.getTotalNum() == null) return R.error("商品数量不能为空");
+
+        Live live = liveMapper.selectLiveByLiveId(liveOrder.getLiveId());
+        if(live == null) return R.error("直播不存在");
+        FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductByProductId(liveOrder.getProductId());
+        LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
+        if(fsStoreProduct == null || goods == null) return R.error("商品不存在");
+        if(fsStoreProduct.getIsShow() == 0 || goods.getStatus() == 0) return R.error("商品已下架");
+
+//        liveOrderItemMapper
+
+
+        //todo yhq
+        liveOrder.setOrderCode(OrderCodeUtils.getOrderSn());
+
+//        liveOrder.setOrderCode(String.valueOf(UUID.randomUUID()));
+        liveOrder.setCreateTime(new Date());
+        liveOrder.setUpdateTime(new Date());
+        liveOrder.setStatus(FsStoreOrderStatusEnum.STATUS_1.getValue());
+        liveOrder.setPayType("1");
+        liveOrder.setTotalPrice(fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum())));
+        liveOrder.setPayMoney(liveOrder.getTotalPrice());
+        try {
+            if (baseMapper.insertLiveOrder(liveOrder) > 0) {
+                FsStoreOrderItemDTO dto=new FsStoreOrderItemDTO();
+                dto.setImage(fsStoreProduct.getImgUrl());
+                dto.setSku(String.valueOf(fsStoreProduct.getStoreId()));
+                dto.setBarCode(fsStoreProduct.getBarCode());
+                dto.setPrice(fsStoreProduct.getPrice());
+                dto.setNum(Long.valueOf(liveOrder.getTotalNum()));
+
+                LiveOrderItem liveOrderItem = new LiveOrderItem();
+                liveOrderItem.setOrderCode(liveOrder.getOrderCode());
+                liveOrderItem.setOrderId(liveOrder.getOrderId());
+                liveOrderItem.setProductId(liveOrder.getProductId());
+                liveOrderItem.setNum(Long.valueOf(liveOrder.getTotalNum()));
+                liveOrderItem.setJsonInfo(JSON.toJSONString(dto));
+                liveOrderItemMapper.insertLiveOrderItem(liveOrderItem);
+                return R.ok("下单成功").put("order",liveOrder);
+            } else {
+                return R.error("订单创建失败");
+            }
+        } catch (Exception e) {
+            // 异常处理
+            return R.error("订单创建失败:" + e.getMessage());
+        }
+    }
+
+    @Override
+    public R confirmOrder(LiveOrderConfirmParam param) {
+        String uuid = IdUtil.randomUUID();
+        redisCache.setCacheObject("orderKey:"+uuid,uuid,200, TimeUnit.MINUTES);
+        return R.ok().put("orderKey",uuid);
+    }
+
+    @Override
+    public List<LiveOrder> selectNotPushedLiveOrder() {
+        return baseMapper.selectNotPushedLiveOrder();
+    }
+
+
+
     /**
      * 订单操作记录
      * */

+ 3 - 0
fs-service/src/main/java/com/fs/live/vo/LiveGoodsVo.java

@@ -1,6 +1,7 @@
 package com.fs.live.vo;
 
 
+import com.fs.common.annotation.Excel;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 
@@ -16,4 +17,6 @@ public class LiveGoodsVo {
     private Integer stock;
     private Integer status;
     private Integer sales;
+    private Long productId;
+    private BigDecimal otPrice;
 }

+ 15 - 2
fs-service/src/main/resources/mapper/live/LiveGoodsMapper.xml

@@ -159,12 +159,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectProductListByLiveId" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
 
-        select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales,lg.status from live_goods lg
+        select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales,lg.status,sp.product_id,sp.ot_price
+        from live_goods lg
         INNER JOIN fs_store_product sp
         ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
 
         <where>
-            live_id = #{liveId}
+            live_id = #{liveId} and lg.status=1 and sp.is_show = 1
             <if test="companyId != null "> and company_id = #{companyId}</if>
             <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
             <if test="storeId != null "> and store_id = #{storeId}</if>
@@ -193,4 +194,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+    <select id="selectProductListByOrder" parameterType="com.fs.live.domain.LiveOrder" resultType="com.fs.live.vo.LiveGoodsVo">
+
+        select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales,lg.status,sp.product_id,sp.ot_price
+        from live_goods lg
+        INNER JOIN fs_store_product sp
+        ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
+
+        <where>
+            lg.live_id = #{liveId} and lg.product_id = #{productId}
+        </where>
+    </select>
+
 </mapper>

+ 1 - 1
fs-service/src/main/resources/mapper/live/LiveMapper.xml

@@ -187,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <update id="updateBatchLiveList" parameterType="com.fs.live.vo.LiveListVo">
-        update live set is_show = #{liveVo.isShow} where company_id = #{liveVo.companyId} and company_user_id = #{liveVo.companyUserId} and live_id in
+        update live set is_show = #{liveVo.isShow},status = 3,finish_time = NOW() where company_id = #{liveVo.companyId} and company_user_id = #{liveVo.companyUserId} and live_id in
         <foreach item="liveId" collection="liveVo.liveIds" open="(" separator="," close=")">
             #{liveId}
         </foreach>

+ 2 - 2
fs-service/src/main/resources/mapper/live/LiveOrderMapper.xml

@@ -395,7 +395,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getLiveOrderTimeGranularity" parameterType="com.fs.live.vo.LiveOrderVo" resultMap="LiveOrderResult">
         <include refid="selectLiveOrderVo"/>
         where 1=1
-        <if test="timeOptions != 'all'">and create_time >= #{createTime}</if>
-        <if test="liveId != null">and live_id = #{liveId}</if>
+        <if test="timeOptions != 'all'">and a.create_time >= #{createTime}</if>
+        <if test="liveId != null">and a.live_id = #{liveId}</if>
     </select>
 </mapper>

+ 77 - 0
fs-service/src/main/resources/mapper/live/LiveOrderPaymentErrorMapper.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.his.mapper.LiveOrderPaymentErrorMapper">
+
+    <resultMap type="LiveOrderPaymentError" id="LiveOrderPaymentErrorResult">
+        <result property="id"    column="id"    />
+        <result property="orderFlowNo"    column="order_flow_no"    />
+        <result property="orderNo"    column="order_no"    />
+        <result property="msg"    column="msg"    />
+        <result property="status"    column="status"    />
+        <result property="createTime"    column="create_time"    />
+    </resultMap>
+
+    <sql id="selectLiveOrderPaymentErrorVo">
+        select id, order_flow_no, order_no, msg, status, create_time from fs_store_payment_error
+    </sql>
+
+    <select id="selectLiveOrderPaymentErrorList" parameterType="LiveOrderPaymentError" resultMap="LiveOrderPaymentErrorResult">
+        <include refid="selectLiveOrderPaymentErrorVo"/>
+        <where>
+            <if test="orderFlowNo != null  and orderFlowNo != ''"> and order_flow_no = #{orderFlowNo}</if>
+            <if test="orderNo != null  and orderNo != ''"> and order_no = #{orderNo}</if>
+            <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
+            <if test="status != null "> and status = #{status}</if>
+        </where>
+    </select>
+
+    <select id="selectLiveOrderPaymentErrorById" parameterType="Long" resultMap="LiveOrderPaymentErrorResult">
+        <include refid="selectLiveOrderPaymentErrorVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertLiveOrderPaymentError" parameterType="LiveOrderPaymentError">
+        insert into fs_store_payment_error
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="orderFlowNo != null">order_flow_no,</if>
+            <if test="orderNo != null">order_no,</if>
+            <if test="msg != null">msg,</if>
+            <if test="status != null">status,</if>
+            <if test="createTime != null">create_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="orderFlowNo != null">#{orderFlowNo},</if>
+            <if test="orderNo != null">#{orderNo},</if>
+            <if test="msg != null">#{msg},</if>
+            <if test="status != null">#{status},</if>
+            <if test="createTime != null">#{createTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateLiveOrderPaymentError" parameterType="LiveOrderPaymentError">
+        update fs_store_payment_error
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="orderFlowNo != null">order_flow_no = #{orderFlowNo},</if>
+            <if test="orderNo != null">order_no = #{orderNo},</if>
+            <if test="msg != null">msg = #{msg},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteLiveOrderPaymentErrorById" parameterType="Long">
+        delete from fs_store_payment_error where id = #{id}
+    </delete>
+
+    <delete id="deleteLiveOrderPaymentErrorByIds" parameterType="String">
+        delete from fs_store_payment_error where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 174 - 0
fs-service/src/main/resources/mapper/live/LiveOrderPaymentMapper.xml

@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.live.mapper.LiveOrderPaymentMapper">
+
+    <resultMap type="LiveOrderPayment" id="LiveOrderPaymentResult">
+        <result property="paymentId"    column="payment_id"    />
+        <result property="payCode"    column="pay_code"    />
+        <result property="payTypeCode"    column="pay_type_code"    />
+        <result property="payMoney"    column="pay_money"    />
+        <result property="payTime"    column="pay_time"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="tradeNo"    column="trade_no"    />
+        <result property="userId"    column="user_id"    />
+        <result property="openId"    column="open_id"    />
+        <result property="businessType"    column="business_type"    />
+        <result property="businessId"    column="business_id"    />
+        <result property="status"    column="status"    />
+        <result property="remark"    column="remark"    />
+        <result property="bankTransactionId"    column="bank_transaction_id"    />
+        <result property="bankSerialNo"    column="bank_serial_no"    />
+        <result property="refundMoney"    column="refund_money"    />
+        <result property="refundTime"    column="refund_time"    />
+        <result property="storeId"    column="store_id"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
+        <result property="businessCode"    column="business_code"    />
+        <result property="payMode"    column="pay_mode"    />
+        <result property="shareStatus"    column="share_status"    />
+        <result property="shareCode"    column="share_code"    />
+        <result property="shareMoney"    column="share_money"    />
+        <result property="isShare"    column="is_share"    />
+    </resultMap>
+
+    <sql id="selectLiveOrderPaymentVo">
+        select payment_id, pay_code, pay_type_code, pay_money, pay_time, create_time, trade_no, user_id, open_id, business_type, business_id, status, remark, bank_transaction_id, bank_serial_no, refund_money, refund_time, store_id, company_id, company_user_id, business_code, pay_mode, share_status, share_code, share_money, is_share from live_order_payment
+    </sql>
+
+    <select id="selectLiveOrderPaymentList" parameterType="LiveOrderPayment" resultMap="LiveOrderPaymentResult">
+        <include refid="selectLiveOrderPaymentVo"/>
+        <where>
+            <if test="payCode != null  and payCode != ''"> and pay_code = #{payCode}</if>
+            <if test="payTypeCode != null  and payTypeCode != ''"> and pay_type_code = #{payTypeCode}</if>
+            <if test="payMoney != null "> and pay_money = #{payMoney}</if>
+            <if test="payTime != null "> and pay_time = #{payTime}</if>
+            <if test="tradeNo != null  and tradeNo != ''"> and trade_no = #{tradeNo}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="openId != null  and openId != ''"> and open_id = #{openId}</if>
+            <if test="businessType != null "> and business_type = #{businessType}</if>
+            <if test="businessId != null  and businessId != ''"> and business_id = #{businessId}</if>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="bankTransactionId != null  and bankTransactionId != ''"> and bank_transaction_id = #{bankTransactionId}</if>
+            <if test="bankSerialNo != null  and bankSerialNo != ''"> and bank_serial_no = #{bankSerialNo}</if>
+            <if test="refundMoney != null "> and refund_money = #{refundMoney}</if>
+            <if test="refundTime != null "> and refund_time = #{refundTime}</if>
+            <if test="storeId != null "> and store_id = #{storeId}</if>
+            <if test="companyId != null "> and company_id = #{companyId}</if>
+            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+            <if test="businessCode != null  and businessCode != ''"> and business_code = #{businessCode}</if>
+            <if test="payMode != null  and payMode != ''"> and pay_mode = #{payMode}</if>
+            <if test="shareStatus != null "> and share_status = #{shareStatus}</if>
+            <if test="shareCode != null  and shareCode != ''"> and share_code = #{shareCode}</if>
+            <if test="shareMoney != null "> and share_money = #{shareMoney}</if>
+            <if test="isShare != null "> and is_share = #{isShare}</if>
+        </where>
+    </select>
+
+    <select id="selectLiveOrderPaymentByPaymentId" parameterType="Long" resultMap="LiveOrderPaymentResult">
+        <include refid="selectLiveOrderPaymentVo"/>
+        where payment_id = #{paymentId}
+    </select>
+
+    <insert id="insertLiveOrderPayment" parameterType="LiveOrderPayment" useGeneratedKeys="true" keyProperty="paymentId">
+        insert into live_order_payment
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="payCode != null">pay_code,</if>
+            <if test="payTypeCode != null">pay_type_code,</if>
+            <if test="payMoney != null">pay_money,</if>
+            <if test="payTime != null">pay_time,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="tradeNo != null">trade_no,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="openId != null">open_id,</if>
+            <if test="businessType != null">business_type,</if>
+            <if test="businessId != null">business_id,</if>
+            <if test="status != null">status,</if>
+            <if test="remark != null">remark,</if>
+            <if test="bankTransactionId != null">bank_transaction_id,</if>
+            <if test="bankSerialNo != null">bank_serial_no,</if>
+            <if test="refundMoney != null">refund_money,</if>
+            <if test="refundTime != null">refund_time,</if>
+            <if test="storeId != null">store_id,</if>
+            <if test="companyId != null">company_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="businessCode != null">business_code,</if>
+            <if test="payMode != null">pay_mode,</if>
+            <if test="shareStatus != null">share_status,</if>
+            <if test="shareCode != null">share_code,</if>
+            <if test="shareMoney != null">share_money,</if>
+            <if test="isShare != null">is_share,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="payCode != null">#{payCode},</if>
+            <if test="payTypeCode != null">#{payTypeCode},</if>
+            <if test="payMoney != null">#{payMoney},</if>
+            <if test="payTime != null">#{payTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="tradeNo != null">#{tradeNo},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="openId != null">#{openId},</if>
+            <if test="businessType != null">#{businessType},</if>
+            <if test="businessId != null">#{businessId},</if>
+            <if test="status != null">#{status},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="bankTransactionId != null">#{bankTransactionId},</if>
+            <if test="bankSerialNo != null">#{bankSerialNo},</if>
+            <if test="refundMoney != null">#{refundMoney},</if>
+            <if test="refundTime != null">#{refundTime},</if>
+            <if test="storeId != null">#{storeId},</if>
+            <if test="companyId != null">#{companyId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="businessCode != null">#{businessCode},</if>
+            <if test="payMode != null">#{payMode},</if>
+            <if test="shareStatus != null">#{shareStatus},</if>
+            <if test="shareCode != null">#{shareCode},</if>
+            <if test="shareMoney != null">#{shareMoney},</if>
+            <if test="isShare != null">#{isShare},</if>
+         </trim>
+    </insert>
+
+    <update id="updateLiveOrderPayment" parameterType="LiveOrderPayment">
+        update live_order_payment
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="payCode != null">pay_code = #{payCode},</if>
+            <if test="payTypeCode != null">pay_type_code = #{payTypeCode},</if>
+            <if test="payMoney != null">pay_money = #{payMoney},</if>
+            <if test="payTime != null">pay_time = #{payTime},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="tradeNo != null">trade_no = #{tradeNo},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="openId != null">open_id = #{openId},</if>
+            <if test="businessType != null">business_type = #{businessType},</if>
+            <if test="businessId != null">business_id = #{businessId},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="bankTransactionId != null">bank_transaction_id = #{bankTransactionId},</if>
+            <if test="bankSerialNo != null">bank_serial_no = #{bankSerialNo},</if>
+            <if test="refundMoney != null">refund_money = #{refundMoney},</if>
+            <if test="refundTime != null">refund_time = #{refundTime},</if>
+            <if test="storeId != null">store_id = #{storeId},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="businessCode != null">business_code = #{businessCode},</if>
+            <if test="payMode != null">pay_mode = #{payMode},</if>
+            <if test="shareStatus != null">share_status = #{shareStatus},</if>
+            <if test="shareCode != null">share_code = #{shareCode},</if>
+            <if test="shareMoney != null">share_money = #{shareMoney},</if>
+            <if test="isShare != null">is_share = #{isShare},</if>
+        </trim>
+        where payment_id = #{paymentId}
+    </update>
+
+    <delete id="deleteLiveOrderPaymentByPaymentId" parameterType="Long">
+        delete from live_order_payment where payment_id = #{paymentId}
+    </delete>
+
+    <delete id="deleteLiveOrderPaymentByPaymentIds" parameterType="String">
+        delete from live_order_payment where payment_id in
+        <foreach item="paymentId" collection="array" open="(" separator="," close=")">
+            #{paymentId}
+        </foreach>
+    </delete>
+</mapper>

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/TzPayController.java

@@ -11,6 +11,7 @@ import com.fs.his.domain.FsPayConfig;
 import com.fs.his.service.IFsInquiryOrderService;
 import com.fs.his.service.IFsPackageOrderService;
 import com.fs.his.service.IFsStoreOrderService;
+import com.fs.live.service.ILiveOrderService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
 import com.fs.tzBankPay.config.TzBankConfig;
@@ -41,6 +42,8 @@ public class TzPayController extends BaseController
 
     @Autowired
     private IFsUserVipOrderService userVipOrderService;
+    @Autowired
+    private ILiveOrderService liveOrderService;
     @RequestMapping(value = "/payNotify",method = RequestMethod.POST)
     public String payNotify(@RequestBody String  decryptForm) throws Exception {
         SysConfigMapper sysConfigMapper= SpringUtils.getBean(SysConfigMapper.class);
@@ -67,6 +70,9 @@ public class TzPayController extends BaseController
             else if(tzBankOrderDecrypt.getOrderNo().indexOf("appvip")>-1){
                 userVipOrderService.payConfirm("",tzBankOrderDecrypt.getOrderNo().substring(6),tzBankOrderDecrypt.getOrderFlowNo(),tzBankOrderDecrypt.getPayType(),1);
             }
+            else if(tzBankOrderDecrypt.getOrderNo().indexOf("appLive")>-1){
+                liveOrderService.payConfirm("",tzBankOrderDecrypt.getOrderNo().substring(6),tzBankOrderDecrypt.getOrderFlowNo(),tzBankOrderDecrypt.getPayType(),1);
+            }
         }
         return decrypt;
     }

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/WxPayController.java

@@ -16,6 +16,7 @@ import com.fs.his.service.IFsInquiryOrderService;
 import com.fs.his.service.IFsPackageOrderService;
 import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.service.IFsStorePaymentService;
+import com.fs.live.service.ILiveOrderService;
 import com.fs.sop.service.ISopUserLogsInfoService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
@@ -73,6 +74,9 @@ public class WxPayController {
     @Autowired
     private ISopUserLogsInfoService iSopUserLogsInfoService;
 
+    @Autowired
+    private ILiveOrderService liveOrderService;
+
 
     /**
      * 微信回调
@@ -107,6 +111,8 @@ public class WxPayController {
                         courseOrderService.payConfirm("",orderId[1],tradeNo,"",1);
                     case "appvip":
                         userVipOrderService.payConfirm("",orderId[1],tradeNo,"",1);
+                    case "appLive":
+                        liveOrderService.payConfirm("",orderId[1],tradeNo,"",1);
                 }
                 return WxPayNotifyResponse.success("处理成功!");
             }else{

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/YbPayController.java

@@ -10,6 +10,7 @@ import com.fs.his.service.IFsInquiryOrderService;
 import com.fs.his.service.IFsPackageOrderService;
 import com.fs.his.service.IFsStoreOrderService;
 
+import com.fs.live.service.ILiveOrderService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
 import com.fs.ybPay.domain.OrderCallback;
@@ -43,6 +44,8 @@ public class YbPayController extends BaseController
     private IFsUserCourseOrderService courseOrderService;
     @Autowired
     private IFsUserVipOrderService userVipOrderService;
+    @Autowired
+    private ILiveOrderService liveOrderService;
     @PostMapping("/payNotify")
     public String payNotify(@RequestBody Map<String, String> params, @RequestBody OrderCallback o) {
         System.out.println("支付回调");
@@ -72,6 +75,9 @@ public class YbPayController extends BaseController
             case "appvip":
                 userVipOrderService.payConfirm("",orderId[1],o.getUpOrderId(),"",1);
                 break;
+            case "appLive":
+                liveOrderService.payConfirm("",orderId[1],o.getUpOrderId(),"",1);
+                break;
         }
         System.out.println(o);
         return "SUCCESS";