|
@ -0,0 +1,127 @@
|
|
|
package com.yihu.wlyy.web.patient.express;
|
|
|
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
|
|
|
import com.yihu.wlyy.service.app.express.SFExpressService;
|
|
|
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.web.BaseController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
* 顺丰速运相关接口
|
|
|
* Created by huangwenjie on 2017/8/1.
|
|
|
*/
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/patient/sfexpress")
|
|
|
@Api(description = "顺丰速运相关接口")
|
|
|
public class SFExpressController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private SFExpressService sfexpressService;
|
|
|
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageService prescriptionExpressageService;
|
|
|
|
|
|
@RequestMapping(value = "/SFOrderFilterService", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
@ApiOperation("查询派送地址是否属于顺丰的派送范围")
|
|
|
public String SFOrderFilterService(
|
|
|
@ApiParam(name = "d_address", value = "派送地址", defaultValue = "福建省厦门市思明区软件园二期望海路55号")
|
|
|
@RequestParam(value = "d_address", required = true) String d_address){
|
|
|
try {
|
|
|
|
|
|
boolean result = sfexpressService.getSFOrderFilterService(d_address);
|
|
|
|
|
|
if(result){
|
|
|
return write(200, "请求成功,地址可派送!");
|
|
|
}else{
|
|
|
return write(-1, "请求失败,地址不可派送!");
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
//日志文件中记录异常信息
|
|
|
error(e);
|
|
|
//返回接口异常信息处理结果
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value="/SFOrderService",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
@ApiOperation("向顺丰快递下订单")
|
|
|
public String SFOrderService(
|
|
|
@ApiParam(name="prescriptionCode", value="订单编号(处方编号)") @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode
|
|
|
// @ApiParam(name="j_company", value="寄件方公司名称") @RequestParam(value = "j_company") String j_company,
|
|
|
// @ApiParam(name="j_contact", value="寄件方联系人") @RequestParam(value = "j_contact") String j_contact,
|
|
|
// @ApiParam(name="j_tel", value="寄件方联系电话") @RequestParam(value = "j_tel") String j_tel,
|
|
|
// @ApiParam(name="j_mobile", value="寄件方手机") @RequestParam(value = "j_mobile") String j_mobile,
|
|
|
// @ApiParam(name="j_province", value="寄件方所在省份") @RequestParam(value = "j_province") String j_province,
|
|
|
// @ApiParam(name="j_city", value="寄件方所在城市名称") @RequestParam(value = "j_city") String j_city,
|
|
|
// @ApiParam(name="j_county", value="寄件人所在县/区") @RequestParam(value = "j_county") String j_county,
|
|
|
// @ApiParam(name="j_address", value="寄件方详细地址,不包括省市区") @RequestParam(value = "j_address") String j_address,
|
|
|
// @ApiParam(name="d_company", value="到件方公司名称") @RequestParam(value = "d_company") String d_company,
|
|
|
// @ApiParam(name="d_contact", value="到件方联系人") @RequestParam(value = "d_contact") String d_contact,
|
|
|
// @ApiParam(name="d_tel", value="到件方联系电话") @RequestParam(value = "d_tel") String d_tel,
|
|
|
// @ApiParam(name="d_mobile", value="到件方手机") @RequestParam(value = "d_mobile") String d_mobile,
|
|
|
// @ApiParam(name="d_province", value="到件方所在省份") @RequestParam(value = "d_province") String d_province,
|
|
|
// @ApiParam(name="d_city", value="到件方所在城市名称") @RequestParam(value = "d_city") String d_city,
|
|
|
// @ApiParam(name="d_county", value="到件方所在县/区") @RequestParam(value = "d_county") String d_county,
|
|
|
// @ApiParam(name="d_address", value="到件方完整的详细地址") @RequestParam(value = "d_address") String d_address
|
|
|
){
|
|
|
|
|
|
try {
|
|
|
PrescriptionExpressage sfexpress_obj = prescriptionExpressageService.findByPrescriptionCode(prescriptionCode);
|
|
|
|
|
|
if(sfexpress_obj == null){
|
|
|
return write(-1, "顺丰快递下单失败,未找到该处方的派送地址!");
|
|
|
}
|
|
|
|
|
|
boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
|
|
|
|
|
|
//先判断地址是否可派送
|
|
|
if(delivery){
|
|
|
// sfexpress_obj.setCode("SF"+UUID.randomUUID().toString().replace("-",""));
|
|
|
// sfexpress_obj.setPrescriptionCode(prescriptionCode);
|
|
|
// sfexpress_obj.setName(sfexpress_obj.getName());
|
|
|
// sfexpress_obj.setPhone(sfexpress_obj.getPhone());
|
|
|
// sfexpress_obj.setMobile(d_mobile);
|
|
|
// sfexpress_obj.setProvinceName(d_province);
|
|
|
// sfexpress_obj.setCityName(d_city);
|
|
|
// sfexpress_obj.setTownName(d_county);
|
|
|
// sfexpress_obj.setAddress(d_address);
|
|
|
// sfexpress_obj.setHospitalName("顺丰速递");
|
|
|
// sfexpress_obj.setOneselfPickupFlg(0);//是否自取 1是 0否
|
|
|
// sfexpress_obj.setCreateTime(DateUtil.getNowDate());
|
|
|
|
|
|
//请求顺丰接口下单,成功下单后,返回快递单号
|
|
|
sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
|
|
|
|
|
|
//保存处方物流记录
|
|
|
prescriptionExpressageService.addPrescriptionExpressage(sfexpress_obj,getUID());
|
|
|
|
|
|
return write(200, "顺丰快递下单成功!");
|
|
|
}else{
|
|
|
return write(-1, "顺丰快递下单失败,地址不可派送!");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
//日志文件中记录异常信息
|
|
|
error(e);
|
|
|
//返回接口异常信息处理结果
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|