| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import com.ruoyi.common.core.domain.entity.ServiceOrderAppResultVo; |
| | | import com.ruoyi.common.core.domain.entity.ServiceOrderAppVo; |
| | | import com.ruoyi.common.core.domain.entity.ServiceOrderDelVo; |
| | | 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.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.validation.annotation.Validated; |
| | | 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; |
| | |
| | | import com.ruoyi.system.service.ITbOrdersService; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.domain.entity.OrderCancelVo; |
| | | |
| | | /** |
| | | * ordersController |
| | |
| | | * @author wzp |
| | | * @date 2025-05-01 |
| | | */ |
| | | @Api("订单管理") |
| | | @RestController |
| | | @RequestMapping("/system/orders") |
| | | public class TbOrdersController extends BaseController |
| | |
| | | @Autowired |
| | | private ITbOrdersService tbOrdersService; |
| | | |
| | | /** |
| | | * 查询orders列表 |
| | | */ |
| | | @Autowired |
| | | private ISysClientAppService clientAppService; |
| | | |
| | | @ApiOperation("查询订单列表") |
| | | @PreAuthorize("@ss.hasPermi('system:orders:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(TbOrders tbOrders) |
| | |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 导出orders列表 |
| | | */ |
| | | @ApiOperation("导出订单列表") |
| | | @PreAuthorize("@ss.hasPermi('system:orders:export')") |
| | | @Log(title = "orders", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | |
| | | 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) |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新增orders |
| | | * 提供外部接口可以调用 |
| | | * @param tbOrders |
| | | * @return |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:orders:add')") |
| | | @Log(title = "orders", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody TbOrders tbOrders) |
| | | { |
| | | return toAjax(tbOrdersService.insertTbOrders(tbOrders)); |
| | | @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,String appId) { |
| | | try { |
| | | if (tbOrders == null || tbOrders.getOrderID() == null) { |
| | | return AjaxResult.error("传输数据为空!"); |
| | | } |
| | | |
| | | if(appId ==null|| Objects.equals(appId, "")) |
| | | { |
| | | return AjaxResult.error("appid不能为空!"); |
| | | } |
| | | |
| | | tbOrders.setAppId(appId); |
| | | tbOrders.setCreateTime(new Date()); |
| | | |
| | | tbOrdersService.insertTbOrders(tbOrders); |
| | | |
| | | |
| | | SysClientApp scApp = clientAppService.selectSysClientAppByAppKey(tbOrders.getAppId()); |
| | | |
| | | |
| | | |
| | | ServiceOrderAppVo model = new ServiceOrderAppVo(); |
| | | model.setMethod("ServiceOrder_APP"); // 设置接口名称 |
| | | model.setAppId(scApp.getMinAppId()); // 设置商户 APPID |
| | | model.setOrdType(tbOrders.getTypeCode().intValue()); |
| | | model.setCoPhone(tbOrders.getLinkTel()); // 客户联系电话 |
| | | model.setCoName(tbOrders.getLinkPerson()); // 客户姓名 |
| | | // model.setCoTies("家属"); // 随机设置客户联系人与患者关系 |
| | | // 设置预约时间为一天后 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | model.setApptDate(sdf.format(tbOrders.getBookingDate())); // 格式化预约运送时间 |
| | | |
| | | model.setPtName(tbOrders.getPatientName()); // 患者姓名 |
| | | model.setPtAge(tbOrders.getAge()); // 随机生成患者年龄 |
| | | model.setPtSex(tbOrders.getSex() == 1 ? "男" : "女"); // 随机生成患者性别 |
| | | // model.setPtNat("中国"); // 设置患者国籍 |
| | | model.setOutHosp(tbOrders.getLocalAddress()); // 设置转出医院 |
| | | model.setInHosp(tbOrders.getSendAddress()); // 设置转入医院 |
| | | // model.setPtServices("科室" + (int) (Math.random() * 10)); // 随机设置患者所在科室 |
| | | model.setPtDiagnosis(tbOrders.getComplaint()); // 设置诊断信息 |
| | | model.setCondition(tbOrders.getRemark()); // 设置备注信息 |
| | | // model.setDoctor("医生" + (int) (Math.random() * 10)); // 随机设置患者医生 |
| | | // model.setDoctorPhone("13" + (int) (Math.random() * 900000000 + 100000000)); // 随机生成患者医生电话 |
| | | model.setOfferPrice(tbOrders.getBookingPrice().doubleValue()); // 生成报价 |
| | | // model.setReferrals("推介人" + (int) (Math.random() * 10)); // 随机设置推介人信息 |
| | | // model.setUnitRemarks("商户随机备注信息"); // 随机设置商户备注 |
| | | model.setPayQRcodeURL(scApp.getPayUrl()); |
| | | |
| | | ServiceOrderAppResultVo result = ServiceOrderUtil.CreateServiceOrder(model,scApp.getMinAppSecret()); |
| | | |
| | | if (result.getResult() == 1) { |
| | | tbOrders.setOrderID(tbOrders.getOrderID()); |
| | | tbOrders.setServiceOrdID(result.getServiceOrdID()); |
| | | tbOrders.setServiceOrdNo(result.getServiceOrdNo()); |
| | | tbOrders.setThirdPartyResult(result.getResult()); |
| | | tbOrders.setUpdateTime(new Date()); |
| | | tbOrders.setOrderStatus(1); |
| | | tbOrdersService.updateTbOrders(tbOrders); |
| | | return AjaxResult.success(result); |
| | | } else { |
| | | return AjaxResult.error("提交失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | return AjaxResult.error("提交失败:"+e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改orders |
| | | */ |
| | | @ApiOperation("重新发送订单") |
| | | @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType = "path") |
| | | @PostMapping("/resend/{orderId}") |
| | | public AjaxResult resendOrder(@PathVariable Long orderId) { |
| | | |
| | | TbOrders tbOrders = tbOrdersService.selectTbOrdersByOrderID(orderId); |
| | | if (tbOrders == null) { |
| | | return AjaxResult.error("订单不存在"); |
| | | } |
| | | if (tbOrders.getOrderStatus() == 2) { |
| | | return AjaxResult.error("订单状态已取消"); |
| | | } |
| | | |
| | | SysClientApp scApp = clientAppService.selectSysClientAppByAppKey("appId1"); |
| | | |
| | | |
| | | ServiceOrderAppVo model = new ServiceOrderAppVo(); |
| | | model.setMethod("ServiceOrder_APP"); // 设置接口名称 |
| | | model.setAppId(scApp.getMinAppId()); // 设置商户 APPID |
| | | model.setOrdType(tbOrders.getTypeCode().intValue()); |
| | | model.setCoPhone(tbOrders.getLinkTel()); // 客户联系电话 |
| | | model.setCoName(tbOrders.getLinkPerson()); // 客户姓名 |
| | | // model.setCoTies("家属"); // 随机设置客户联系人与患者关系 |
| | | // 设置预约时间为一天后 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | model.setApptDate(sdf.format(tbOrders.getBookingDate())); // 格式化预约运送时间 |
| | | |
| | | model.setPtName(tbOrders.getPatientName()); // 患者姓名 |
| | | model.setPtAge(tbOrders.getAge()); // 随机生成患者年龄 |
| | | model.setPtSex(tbOrders.getSex() == 1 ? "男" : "女"); // 随机生成患者性别 |
| | | // model.setPtNat("中国"); // 设置患者国籍--默认中国,不需要设置 |
| | | model.setOutHosp(tbOrders.getLocalAddress()); // 设置转出医院 |
| | | model.setInHosp(tbOrders.getSendAddress()); // 设置转入医院 |
| | | // model.setPtServices("科室")); // 设置患者所在科室 |
| | | model.setPtDiagnosis(tbOrders.getComplaint()); // 设置诊断信息 |
| | | model.setCondition(tbOrders.getRemark()); // 设置备注信息 |
| | | // model.setDoctor("医生")); // 设置患者医生--没有医生信息 |
| | | // model.setDoctorPhone("")); // 设置患者医生电话--没有医生电话 |
| | | model.setOfferPrice(tbOrders.getBookingPrice().doubleValue()); // 报价 |
| | | // model.setReferrals("推介人")); // 设置推介人信息--没有推介人信息 |
| | | // model.setUnitRemarks("商户备注信息"); // 设置商户备注--没有商户备注 |
| | | model.setPayQRcodeURL(scApp.getPayUrl()); |
| | | |
| | | ServiceOrderAppResultVo result = ServiceOrderUtil.CreateServiceOrder(model,scApp.getMinAppSecret()); |
| | | |
| | | if (result.getResult() == 1) { |
| | | tbOrders.setOrderID(tbOrders.getOrderID()); |
| | | tbOrders.setServiceOrdID(result.getServiceOrdID()); |
| | | tbOrders.setServiceOrdNo(result.getServiceOrdNo()); |
| | | tbOrders.setThirdPartyResult(result.getResult()); |
| | | tbOrders.setUpdateTime(new Date()); |
| | | tbOrders.setOrderStatus(1); |
| | | tbOrdersService.updateTbOrders(tbOrders); |
| | | return AjaxResult.success(result); |
| | | } else { |
| | | return AjaxResult.error("提交失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @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) |
| | | { |
| | | try { |
| | | if (cancelVo == null || cancelVo.getOrderID() == null || |
| | | cancelVo.getThirdOrderNo() == null || cancelVo.getReason() == null) { |
| | | return AjaxResult.error("必要参数不能为空!"); |
| | | } |
| | | |
| | | SysClientApp scApp = clientAppService.selectSysClientAppByAppId(1L); |
| | | |
| | | ServiceOrderDelVo model = new ServiceOrderDelVo(); |
| | | model.setMethod("ServiceOrder_DEL"); // 设置接口名称 |
| | | model.setAPPID(scApp.getMinAppId()); // 设置商户 APPID |
| | | model.setServiceOrdID(cancelVo.getThirdOrderNo()); // 设置第三方订单号 |
| | | model.setDELRemarks(cancelVo.getReason()); // 设置取消原因 |
| | | |
| | | ServiceOrderAppResultVo result = ServiceOrderUtil.CancelServiceOrder(model,scApp.getMinAppSecret()); |
| | | |
| | | if (result.getResult() == 1) { |
| | | // 更新本地订单状态 |
| | | TbOrders tbOrders = new TbOrders(); |
| | | tbOrders.setOrderID(cancelVo.getOrderID()); |
| | | tbOrders.setOrderStatus(2); // 2是取消 |
| | | tbOrdersService.updateTbOrders(tbOrders); |
| | | return AjaxResult.success(result); |
| | | } else { |
| | | return AjaxResult.error("取消订单失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | return AjaxResult.error("取消订单失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @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 |
| | |
| | | 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)); |