|
@@ -0,0 +1,150 @@
|
|
|
+package com.jpsoft.prices.modules.open;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.prices.modules.base.entity.Destination;
|
|
|
+import com.jpsoft.prices.modules.base.entity.Invoice;
|
|
|
+import com.jpsoft.prices.modules.base.entity.InvoiceInfo;
|
|
|
+import com.jpsoft.prices.modules.base.service.DestinationService;
|
|
|
+import com.jpsoft.prices.modules.base.service.InvoiceInfoService;
|
|
|
+import com.jpsoft.prices.modules.base.service.InvoiceService;
|
|
|
+import com.jpsoft.prices.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.prices.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.prices.modules.common.utils.PojoUtils;
|
|
|
+import com.jpsoft.prices.modules.sys.entity.User;
|
|
|
+import com.jpsoft.prices.modules.sys.service.UserService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.util.Internal;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("open/invoiceApi")
|
|
|
+@Api(description = "invoice")
|
|
|
+public class InvoiceApiController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+ @Autowired
|
|
|
+ private DestinationService destinationService;
|
|
|
+ @Autowired
|
|
|
+ private InvoiceService invoiceService;
|
|
|
+ @Autowired
|
|
|
+ private InvoiceInfoService invoiceInfoService;
|
|
|
+
|
|
|
+ @ApiOperation(value="写入发运单")
|
|
|
+ @RequestMapping(value = "addInvoice",method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="keyId", value="keyId", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="keySecret", value="keySecret", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="destinationName", value="目的地", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="shipment", value="发货日期", required=true, paramType="query", dataType="date"),
|
|
|
+ @ApiImplicitParam(name="recipient", value="收货人", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="telephone", value="联系电话", required=true, paramType="query", dataType="int"),
|
|
|
+ @ApiImplicitParam(name="company", value="收货单位", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="address", value="收货地址", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="goodsValue", value="货值", required=true, paramType="query", dataType="int"),
|
|
|
+ })
|
|
|
+ public MessageResult addInvoice(String keyId, String keySecret, String destinationName, Date shipment, String recipient, String telephone, String company, String address, Integer goodsValue){
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ User user = userService.findByUserName(keyId);
|
|
|
+ if(user.getPassword().equals(keySecret)) {
|
|
|
+ Destination destination = destinationService.getByName(destinationName);
|
|
|
+ if(destination != null) {
|
|
|
+ Invoice invoice = new Invoice();
|
|
|
+ invoice.setId(UUID.randomUUID().toString());
|
|
|
+ invoice.setDestinationId(destination.getId());
|
|
|
+ invoice.setShipment(shipment);
|
|
|
+ invoice.setRecipient(recipient);
|
|
|
+ invoice.setRecipientTelephone(telephone);
|
|
|
+ invoice.setRecipientEntity(company);
|
|
|
+ invoice.setRecipientAddress(address);
|
|
|
+ invoice.setGoodsValue(goodsValue);
|
|
|
+ invoice.setStatus(false);
|
|
|
+ invoice.setDelFlag(false);
|
|
|
+ invoice.setCreateTime(new Date());
|
|
|
+ invoice.setCreateBy(user.getId());
|
|
|
+ invoiceService.insert(invoice);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(invoice.getId());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("未收录的目的地。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("无效的令牌。");
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="写入发运单详情")
|
|
|
+ @RequestMapping(value = "addInvoiceInfo",method = RequestMethod.POST)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="keyId", value="keyId", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="keySecret", value="keySecret", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="invoiceId", value="发运单编号", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="orderNumber", value="订单号", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="name", value="名称", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="type", value="类别", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="barCode", value="条形码", required=true, paramType="query"),
|
|
|
+ @ApiImplicitParam(name="boxLength", value="长(CM)", required=true, paramType="query", dataType="int"),
|
|
|
+ @ApiImplicitParam(name="boxWidth", value="宽(CM)", required=true, paramType="query", dataType="int"),
|
|
|
+ @ApiImplicitParam(name="boxHight", value="高(CM)", required=true, paramType="query", dataType="int"),
|
|
|
+ @ApiImplicitParam(name="netWeight", value="净重(KG)", required=true, paramType="query", dataType="float"),
|
|
|
+ @ApiImplicitParam(name="grossWeight", value="毛重(KG)", required=true, paramType="query", dataType="float"),
|
|
|
+ })
|
|
|
+ public MessageResult addInvoiceInfo(String keyId, String keySecret, String invoiceId, String orderNumber, String name, String type, String barCode,
|
|
|
+ Integer boxLength, Integer boxWidth, Integer boxHight, BigDecimal netWeight, BigDecimal grossWeight){
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ User user = userService.findByUserName(keyId);
|
|
|
+ if(user.getPassword().equals(keySecret)) {
|
|
|
+ Invoice invoice = invoiceService.get(invoiceId);
|
|
|
+ if(invoice != null) {
|
|
|
+ InvoiceInfo invoiceInfo = new InvoiceInfo();
|
|
|
+ invoiceInfo.setId(UUID.randomUUID().toString());
|
|
|
+ invoiceInfo.setInvoiceId(invoiceId);
|
|
|
+ invoiceInfo.setOrderNumber(orderNumber);
|
|
|
+ invoiceInfo.setName(name);
|
|
|
+ invoiceInfo.setType(type);
|
|
|
+ invoiceInfo.setBarCode(barCode);
|
|
|
+ invoiceInfo.setBoxLength(boxLength);
|
|
|
+ invoiceInfo.setBoxWidth(boxWidth);
|
|
|
+ invoiceInfo.setBoxHight(boxHight);
|
|
|
+ invoiceInfo.setNetWeight(netWeight);
|
|
|
+ invoiceInfo.setGrossWeight(grossWeight);
|
|
|
+ invoiceInfo.setDelFlag(false);
|
|
|
+ invoiceInfo.setCreateTime(new Date());
|
|
|
+ invoiceInfo.setCreateBy(user.getId());
|
|
|
+ invoiceInfoService.insert(invoiceInfo);
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("未收录的发运单。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("无效的令牌。");
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+}
|