wzp
2025-05-05 6eddbbc337d8ab1de6daaa5afda2699179e3e8db
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TbOrdersController.java
@@ -13,17 +13,14 @@
import com.ruoyi.common.utils.civilAviation.ServiceOrderUtil;
import com.ruoyi.system.domain.SysClientApp;
import com.ruoyi.system.service.ISysClientAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@@ -40,6 +37,7 @@
 * @author wzp
 * @date 2025-05-01
 */
@Api("订单管理")
@RestController
@RequestMapping("/system/orders")
public class TbOrdersController extends BaseController
@@ -50,9 +48,7 @@
    @Autowired
    private ISysClientAppService clientAppService;
    /**
     * 查询orders列表
     */
    @ApiOperation("查询订单列表")
    @PreAuthorize("@ss.hasPermi('system:orders:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbOrders tbOrders)
@@ -62,9 +58,7 @@
        return getDataTable(list);
    }
    /**
     * 导出orders列表
     */
    @ApiOperation("导出订单列表")
    @PreAuthorize("@ss.hasPermi('system:orders:export')")
    @Log(title = "orders", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
@@ -75,9 +69,8 @@
        util.exportExcel(response, list, "orders数据");
    }
    /**
     * 获取orders详细信息
     */
    @ApiOperation("获取订单详细信息")
    @ApiImplicitParam(name = "OrderID", value = "订单ID", required = true, dataType = "Long", paramType = "path")
    @PreAuthorize("@ss.hasPermi('system:orders:query')")
    @GetMapping(value = "/{OrderID}")
    public AjaxResult getInfo(@PathVariable("OrderID") Long OrderID)
@@ -93,6 +86,22 @@
//    @Anonymous(needSign = true)
    @Anonymous
//    @Log(title = "orders", businessType = BusinessType.INSERT)
    @ApiOperation("新增订单")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "orderID", value = "订单ID", dataType = "Long"),
        @ApiImplicitParam(name = "typeCode", value = "订单类型", dataType = "Integer"),
        @ApiImplicitParam(name = "linkTel", value = "联系电话", dataType = "String"),
        @ApiImplicitParam(name = "linkPerson", value = "联系人", dataType = "String"),
        @ApiImplicitParam(name = "bookingDate", value = "预约时间", dataType = "Date"),
        @ApiImplicitParam(name = "patientName", value = "患者姓名", dataType = "String"),
        @ApiImplicitParam(name = "age", value = "年龄", dataType = "Integer"),
        @ApiImplicitParam(name = "sex", value = "性别", dataType = "Integer"),
        @ApiImplicitParam(name = "localAddress", value = "转出医院", dataType = "String"),
        @ApiImplicitParam(name = "sendAddress", value = "转入医院", dataType = "String"),
        @ApiImplicitParam(name = "complaint", value = "诊断信息", dataType = "String"),
        @ApiImplicitParam(name = "remark", value = "备注", dataType = "String"),
        @ApiImplicitParam(name = "bookingPrice", value = "报价", dataType = "BigDecimal")
    })
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TbOrders tbOrders) {
        try {
@@ -116,7 +125,7 @@
//        model.setCoTies("家属"); // 随机设置客户联系人与患者关系
            // 设置预约时间为一天后
            Calendar calendar = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd%20HH:mm");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            model.setApptDate(sdf.format(tbOrders.getBookingDate())); // 格式化预约运送时间
            model.setPtName(tbOrders.getPatientName()); // 患者姓名
@@ -130,12 +139,12 @@
            model.setCondition(tbOrders.getRemark()); // 设置备注信息
//        model.setDoctor("医生" + (int) (Math.random() * 10)); // 随机设置患者医生
//        model.setDoctorPhone("13" + (int) (Math.random() * 900000000 + 100000000)); // 随机生成患者医生电话
            model.setOfferPrice(tbOrders.getBookingPrice().doubleValue()); // 随机生成报价
            model.setOfferPrice(tbOrders.getBookingPrice().doubleValue()); // 生成报价
//        model.setReferrals("推介人" + (int) (Math.random() * 10)); // 随机设置推介人信息
//        model.setUnitRemarks("商户随机备注信息"); // 随机设置商户备注
//        model.setPayQRcodeURL("https://example.com/qrcode/" + (int) (Math.random() * 100)); // 随机生成外部支付二维码链接
          model.setPayQRcodeURL(scApp.getPayUrl());
            ServiceOrderAppResultVo result = ServiceOrderUtil.CreateServiceOrder(model);
            ServiceOrderAppResultVo result = ServiceOrderUtil.CreateServiceOrder(model,scApp.getMinAppSecret());
            if (result.getResult() == 1) {
                tbOrders.setOrderID(tbOrders.getOrderID());
@@ -154,9 +163,8 @@
        }
    }
    /**
     * 重新发送订单
     */
    @ApiOperation("重新发送订单")
    @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType = "path")
    @PostMapping("/resend/{orderId}")
    public AjaxResult resendOrder(@PathVariable Long orderId) {
@@ -168,7 +176,7 @@
            return AjaxResult.error("订单状态已取消");
        }
        SysClientApp scApp = clientAppService.selectSysClientAppByAppId(1L);
        SysClientApp scApp = clientAppService.selectSysClientAppByAppKey("appId1");
        ServiceOrderAppVo model = new ServiceOrderAppVo();
@@ -180,7 +188,7 @@
//        model.setCoTies("家属"); // 随机设置客户联系人与患者关系
        // 设置预约时间为一天后
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd%20HH:mm");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        model.setApptDate(sdf.format(tbOrders.getBookingDate())); // 格式化预约运送时间
        model.setPtName(tbOrders.getPatientName()); // 患者姓名
@@ -197,9 +205,9 @@
        model.setOfferPrice(tbOrders.getBookingPrice().doubleValue()); // 报价
//        model.setReferrals("推介人")); // 设置推介人信息--没有推介人信息
//        model.setUnitRemarks("商户备注信息"); // 设置商户备注--没有商户备注
//        model.setPayQRcodeURL("https://example.com/qrcode/")); // 外部支付二维码链接--用不到
       model.setPayQRcodeURL(scApp.getPayUrl());
        ServiceOrderAppResultVo result = ServiceOrderUtil.CreateServiceOrder(model);
        ServiceOrderAppResultVo result = ServiceOrderUtil.CreateServiceOrder(model,scApp.getMinAppSecret());
        if (result.getResult() == 1) {
            tbOrders.setOrderID(tbOrders.getOrderID());
@@ -217,6 +225,12 @@
    @ApiOperation("取消订单")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "orderID", value = "订单ID", required = true, dataType = "Long"),
        @ApiImplicitParam(name = "thirdOrderNo", value = "第三方订单号", required = true, dataType = "String"),
        @ApiImplicitParam(name = "reason", value = "取消原因", required = true, dataType = "String")
    })
    @Anonymous
    @PostMapping("/cancelOrder")
    public AjaxResult cancelOrder(@RequestBody OrderCancelVo cancelVo)
@@ -235,7 +249,7 @@
            model.setServiceOrdID(cancelVo.getThirdOrderNo()); // 设置第三方订单号
            model.setDELRemarks(cancelVo.getReason()); // 设置取消原因
            ServiceOrderAppResultVo result = ServiceOrderUtil.CancelServiceOrder(model);
            ServiceOrderAppResultVo result = ServiceOrderUtil.CancelServiceOrder(model,scApp.getMinAppSecret());
            if (result.getResult() == 1) {
                // 更新本地订单状态
@@ -252,9 +266,22 @@
        }
    }
    /**
     * 修改orders
     */
    @ApiOperation("修改订单")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "orderID", value = "订单ID", required = true, dataType = "Long"),
        @ApiImplicitParam(name = "typeCode", value = "订单类型", dataType = "Integer"),
        @ApiImplicitParam(name = "linkTel", value = "联系电话", dataType = "String"),
        @ApiImplicitParam(name = "linkPerson", value = "联系人", dataType = "String"),
        @ApiImplicitParam(name = "bookingDate", value = "预约时间", dataType = "Date"),
        @ApiImplicitParam(name = "patientName", value = "患者姓名", dataType = "String"),
        @ApiImplicitParam(name = "age", value = "年龄", dataType = "Integer"),
        @ApiImplicitParam(name = "sex", value = "性别", dataType = "Integer"),
        @ApiImplicitParam(name = "localAddress", value = "转出医院", dataType = "String"),
        @ApiImplicitParam(name = "sendAddress", value = "转入医院", dataType = "String"),
        @ApiImplicitParam(name = "complaint", value = "诊断信息", dataType = "String"),
        @ApiImplicitParam(name = "remark", value = "备注", dataType = "String"),
        @ApiImplicitParam(name = "bookingPrice", value = "报价", dataType = "BigDecimal")
    })
    @PreAuthorize("@ss.hasPermi('system:orders:edit')")
    @Log(title = "orders", businessType = BusinessType.UPDATE)
    @PutMapping
@@ -263,12 +290,11 @@
        return toAjax(tbOrdersService.updateTbOrders(tbOrders));
    }
    /**
     * 删除orders
     */
    @ApiOperation("删除订单")
    @ApiImplicitParam(name = "OrderIDs", value = "订单ID数组", required = true, dataType = "Long[]", paramType = "path")
    @PreAuthorize("@ss.hasPermi('system:orders:remove')")
    @Log(title = "orders", businessType = BusinessType.DELETE)
   @DeleteMapping("/{OrderIDs}")
    @DeleteMapping("/{OrderIDs}")
    public AjaxResult remove(@PathVariable Long[] OrderIDs)
    {
        return toAjax(tbOrdersService.deleteTbOrdersByOrderIDs(OrderIDs));