浏览代码

电子发票打印

wangxiaoming 6 年之前
父节点
当前提交
80beed761f

+ 1 - 1
watero-rst-core/src/main/java/com.iamberry.rst.core/ei/Billing.java

@@ -49,7 +49,7 @@ public class Billing  implements  Serializable{
     private String billBankBranchName;
     //姓名
     private String billPersonalName;
-    //状态 0:未开票; 1:开票中; 2为开票成功 3:开票失败;
+    //状态 0:未开票; 1:开票中; 2为开票成功 3:开票失败; 4:已推送
     private Integer billStatus;
     //开票流水号 开票成功,诺诺平台流水号
     private String billInvoiceSerialNum;

+ 1 - 4
watero-rst-service/src/main/java/com/iamberry/rst/service/ei/mapper/billingMapper.xml

@@ -85,7 +85,7 @@
                 AND t.bill_type = #{billType}
             </if >
             <if test="billCompanyName != null and billCompanyName != ''">
-                AND t.bill_company_name  like  CONCAT ('%',#{billCompanyName},'%')
+                AND (t.bill_company_name  like  CONCAT ('%',#{billCompanyName},'%') OR t.bill_personal_name  like  CONCAT ('%',#{billPersonalName},'%'))
             </if >
             <if test="billTaxNumber != null and billTaxNumber != ''">
                 AND t.bill_tax_number  like  CONCAT ('%',#{billTaxNumber},'%')
@@ -96,9 +96,6 @@
             <if test="billAddress != null and billAddress != ''">
                 AND t.bill_address  like  CONCAT ('%',#{billAddress},'%')
             </if >
-            <if test="billPersonalName != null and billPersonalName != ''">
-                AND t.bill_personal_name  like  CONCAT ('%',#{billPersonalName},'%')
-            </if >
             <if test="billStatus != null ">
                 AND t.bill_status = #{billStatus}
             </if >

+ 88 - 14
watero-rst-web/src/main/java/com/iamberry/rst/controllers/ei/BillingController.java

@@ -15,6 +15,7 @@ import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.util.JdServiceUtil;
 import com.iamberry.rst.utils.AdminUtils;
 import com.iamberry.rst.utils.StitchAttrUtil;
+import com.iamberry.rst.utils.UploadFileUtils;
 import com.iamberry.wechat.tools.NameUtils;
 import com.iamberry.wechat.tools.ResponseJson;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -25,10 +26,15 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.Date;
 import java.util.List;
+import java.util.Random;
+import java.util.UUID;
 
 /**
  * 发票管理
@@ -64,17 +70,18 @@ public class BillingController {
                                           @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
         ModelAndView mv = new ModelAndView("ei/ei_billing_list");
 
+        Admin admin = AdminUtils.getLoginAdmin();
+        Integer adminDept = admin.getAdminDept();   // 1:技术组 2:销售组(销售部) 3:客服组(客服运营部) 4:运营组 5:财务部  6工厂生产部 7.管理部8工厂仓库部
+
         PagedResult<Billing> pagedResult = billingService.getBillingPage(pageNO, pageSize, billing, totalNum == 0);
         if (totalNum != 0) {
             pagedResult.setTotal(totalNum);
         }
 
-//        String path = request.getSession().getServletContext().getRealPath("/");
-//        boolean flag = nuoNuoServiceUtil.invoGetByNuoNuo(path);
-
         StitchAttrUtil.getSa()
                 .addDatePro("yyyy-MM-dd HH:mm:ss","startDate","endDate")
                 .setModelAndView(billing, mv, "/admin/customerBasic/listCustomerBasic", pagedResult);
+        mv.addObject("adminDept",adminDept);
         return mv;
     }
 
@@ -195,32 +202,94 @@ public class BillingController {
         return  new ResponseJson(200, "添加成功", 200);
     }
 
+
+    /**
+     *  to发票上传
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping("/to_upload")
+    @RequiresPermissions("ei:billing:add")
+    public ModelAndView toUpload(HttpServletRequest request,Integer billId) throws Exception {
+        ModelAndView mv = new ModelAndView("ei/ei_billing_upload");
+        mv.addObject("billId",billId);
+        return mv;
+    }
+
+
     /**
-     * 重新开票
+     * 发票上传
      * @param request
      * @return
      * @throws Exception
      */
     @ResponseBody
-    @RequestMapping("/re_invoice")
+    @RequestMapping("/upload_invoice")
     @RequiresPermissions("ei:billing:add")
-    public ResponseJson reInvoice(HttpServletRequest request,Integer billId) throws Exception {
+    public ResponseJson uploadInvoice(HttpServletRequest request,Integer billId, @RequestParam("file") CommonsMultipartFile file)  {
         ResponseJson rj = new ResponseJson();
         Billing billing = billingService.getBillingById(billId);
-        PlatformInfo platformInfo = platformInfoService.getPlatformInfoById(billing.getPlatId());
-        if(platformInfo == null){
-            rj = new ResponseJson(500, "查询所属平台失败", 500);
+        if(billing == null){
+            rj = new ResponseJson(500, "未查询到该发票信息", 500);
             return rj;
         }
-        BillingItem billingItem = new BillingItem();
-        billingItem.setBillId(billId);
-        List<BillingItem> billingItemList =  billingItemService.getBillingItemList(billingItem);
-        billing.setBillingItemList(billingItemList);
+        if(billing.getBillStatus() == 4){
+            rj = new ResponseJson(500, "该发票已推送,无法重新上传。", 500);
+            return rj;
+        }
+
+        String uuid = UUID.randomUUID().toString().substring(0,5);
 
-        rj = new ResponseJson(500, "查询所属平台失败", 500);
+        String realPath = request.getSession().getServletContext().getRealPath("/");
+
+        String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().toString().lastIndexOf("."));
+        String name = billing.getBillOrderNo()+"-"+uuid+suffix;
+        String path = "";
+        try{
+            path = UploadFileUtils.eiUploadFile(realPath,name,file);
+        }catch (Exception e){
+            e.printStackTrace();
+            return  new ResponseJson(500, "上传PDF失败", 500);
+        }
+        rj = new ResponseJson(200, "上传发票成功", 200);
+        rj.addResponseKeyValue("path",path);
+        return rj;
+    }
+
+    /**
+     * 发票上传
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @ResponseBody
+    @RequestMapping("/update_file")
+    @RequiresPermissions("ei:billing:add")
+    public ResponseJson updateFile(HttpServletRequest request,Billing bl)  {
+        ResponseJson rj = new ResponseJson();
+        Billing billing = billingService.getBillingById(bl.getBillId());
+        if(bl.getBillInvoiceFileUrl() == null || "".equals(bl.getBillInvoiceFileUrl())){
+            rj = new ResponseJson(500, "上传路径为空", 500);
+            return rj;
+        }
+
+        if(billing.getBillStatus() == 4){
+            rj = new ResponseJson(500, "该发票已推送,无法重新上传。", 500);
+            return rj;
+        }
+
+        bl.setBillStatus(2);
+        Integer flag = billingService.update(bl);
+
+        if(flag < 1){
+            return  new ResponseJson(500, "修改发票信息失败", 500);
+        }
+        rj = new ResponseJson(200, "上传发票成功", 200);
         return rj;
     }
 
+
     /**
      *  查询发票详情
      * @param request
@@ -276,9 +345,14 @@ public class BillingController {
                 break;
         }
         if(jdPushLog.getPushLogStatus() == 1){
+            Billing billing = new Billing();
+            billing.setBillId(pushLog.getBillId());
+            billing.setBillStatus(4);
+            Integer flag = billingService.update(billing);
             return new ResponseJson(200, "上传发票成功", 200);
         }else{
             return new ResponseJson(500, "上传发票失败,"+jdPushLog.getPushLogResultMsg(), 500);
         }
     }
+
 }

+ 15 - 0
watero-rst-web/src/main/java/com/iamberry/rst/utils/UploadFileUtils.java

@@ -19,6 +19,7 @@ public class UploadFileUtils {
 
     private UploadFileUtils(){
         map.put("scmOrder","scmOrder");
+        map.put("eiInvo","eiInvo");
     };
 
     /**
@@ -86,6 +87,7 @@ public class UploadFileUtils {
 
     /**
      * 上朵牙刷定制的图片上传
+     * path  : common/upload/yyyyMMdd/
      * @param name
      * @param file
      * @return
@@ -97,4 +99,17 @@ public class UploadFileUtils {
         return path;
     }
 
+    /**
+     * 发票上传
+     * path  : common/pdf/
+     * @param name
+     * @param file
+     * @return
+     */
+    public static String eiUploadFile(String rootPathh, String name, CommonsMultipartFile file){
+        String soonPath = "/pdf/";
+        String path = UploadFileUtils.getUf().upload("eiInvo",rootPathh,soonPath,name,file);
+        return path;
+    }
+
 }

+ 2 - 2
watero-rst-web/src/main/webapp/WEB-INF/views/cm/customer/add_customer.ftl

@@ -864,12 +864,12 @@ f<!DOCTYPE HTML>
                 $("#openTheLock").show();
                 promethodUlc.setUlcById(0,2);
             }
-        })
+        });
 
         /*监听问题类型 选择事件*/
         $("[name='complaintId']").change(function(){
             initComplaintSmallClassInfo($(this).val());
-        })
+        });
 
         /*监听问题关键字搜索*/
         $(document).on('click', '#search_button', function() {

+ 28 - 11
watero-rst-web/src/main/webapp/WEB-INF/views/ei/ei_add_billing.ftl

@@ -222,26 +222,43 @@
 
 
 <script type="text/javascript">
+
     $(function(){
+        $("input[name='billType']").on('ifChecked', function(event){
+            var billType = $("input[name='billType']:checked").val();
+            if(billType == 1){   //企业
+                $("#billCompany").show();
+                $("#billPersonal").hide();
+            }else{
+                $("#billCompany").hide();
+                $("#billPersonal").show();
+            }
+        });
+
+
         $('.skin-minimal input').iCheck({
             checkboxClass: 'icheckbox-blue',
             radioClass: 'iradio-blue',
             increaseArea: '20%'
         });
 
-        $("input[name='billType']").change(function (){
-            var billType = $(this).val()
-           if(billType == 1){   //企业
-                $("#billCompany").show();
-                $("#billPersonal").hide();
-           }else{
-               $("#billCompany").hide();
-               $("#billPersonal").show();
-           }
-        })
-    });
 
+//        $("input[name='billType']").change(function (){
+//            var billType = $(this).val();
+//           if(billType == 1){   //企业
+//                $("#billCompany").show();
+//                $("#billPersonal").hide();
+//           }else{
+//               $("#billCompany").hide();
+//               $("#billPersonal").show();
+//           }
+//        })
 
+//        $(document).on('change', "input[name='billType']", function() {
+//
+//        });
+
+    });
 </script>
 
 

文件差异内容过多而无法显示
+ 47 - 52
watero-rst-web/src/main/webapp/WEB-INF/views/ei/ei_billing_list.ftl


+ 196 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/ei/ei_billing_upload.ftl

@@ -0,0 +1,196 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="renderer" content="webkit|ie-comp|ie-stand">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport"
+          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
+    <meta http-equiv="Cache-Control" content="no-siteapp"/>
+    <#include "/base/add_base.ftl">
+
+    <style>
+        .tit{position: relative;text-align: left;font-size: 16px;padding-left: 10px;}
+        .tit:after{content: '';position: absolute;left: 0;top: 20%;height: 60%;width: 3px;background-color: #32a3d8;}
+        .tit-2{position: relative;text-align: left;font-size: 16px;padding-left: 10px;}
+        .tit-2:after{content: '';position: absolute;left: 0;top: 20%;height: 60%;width: 3px;background-color: #32a3d8;}
+        #province select{margin-right:10px; width:100px;height: 31px;-webkit-appearance:none !important;appearance:none;background: url(${path}/common/images/cm/select-1.png) right center no-repeat;background-size: auto 100%;padding-left:3px;padding-right: 25px;}
+        .ac_results li a {white-space: nowrap;text-decoration:none;display:block;color:#05a;padding:1px 3px}
+        .ac_results li {border:1px solid #fff}
+        .ac_results li a span {float:right}
+        .select-box{background: url(${path}/common/images/cm/select-1.png) right center no-repeat;background-size: auto 100%;}
+        .select-box select{-webkit-appearance:none !important;background-color: transparent; appearance:none;padding-right: 25px;}
+        .dalog-ask{position: absolute;left:60%;top:0;-webkit-transform: translateY(-30%);transform: translateY(-30%);display: none;background-color: #fff;z-index: 10;}
+        .tag{ width:300px; min-height:300px; border:1px solid #32a3d8; position:relative;background-color: #fff;line-height: 1.5;padding: 10px 12px;}
+        .tag em{display:block; border-width:15px; position:absolute; top:30%; left:-30px;border-style:solid dashed dashed; border-color:transparent  #32a3d8 transparent transparent;font-size:0; line-height:0;}
+        .time-line-list{list-style: none;width: 100%;margin-left: -20px;}
+        .time-line-list>li{position: relative;float: left; text-align: center;width: 100px;overflow: hidden;white-space: nowrap;word-break: break-all;padding: 2px 0;}
+        .time-line-list .number{display: inline-block; padding: 2px; background: #32a3d8;border: 2px solid #fff;box-shadow:0 0 0 1px #32a3d8;width: 20px;height: 20px;color: #fff;line-height: 20px;border-radius: 50%;}
+        .time-line-list>li:before{content:'';position: absolute;height: 1px;width: 30%;right:0;top: 15px; background-color: #32a3d8;}
+        .time-line-list>li:after{content: '';position: absolute;height: 1px;width: 30%;left: 0;top: 15px;background:#32a3d8;}
+        .time-line-list>li:first-child:after,.time-line-list>li:last-child:before{display: none;}
+        .time-line-list .arrow{border-width:7px; position:absolute; left:25%; top:9px;border-style:solid dashed dashed; border-color:transparent  transparent  transparent #32a3d8;font-size:0; line-height:0;}
+        .time-line-list>li:first-child .arrow{display: none;}
+        .table-bg th{background-color: #e2f6ff;}
+        .update-parts>span{margin-right: 10px;padding: 3px 4px;background-color: #effaff;border: 1px solid #32a3d8;}
+        .msg-phone{height: 35px;line-height: 35px;}
+        .col-sm-1{width: 150px;}
+
+        .all_down{text-decoration: underline;color: #00c;}
+    </style>
+    <title>发票上传 - 发票管理 - RST</title>
+</head>
+<body>
+
+<article class="page-container" style="padding: 10px;">
+    <div class="pd-20 cl">
+        <form action="${path}/admin/ei_billing/update_file" method="post" class="form form-horizontal" id="form-order-add"  onkeydown="if(event.keyCode==13)return false;">
+
+        <input type="hidden" id="billId" name="billId" value="${billId}">
+            <input type="hidden" id="billInvoiceFileUrl" name="billInvoiceFileUrl" value="">
+
+            <div class="row cl">
+                <label class="form-label col-1 col-sm-1" style="float: left;text-align: right;"><span class="c-red">*</span>PDF文件:</label>
+                <div class="formControls col-8 col-sm-8" style="margin-top: 3px;float: left;">
+                    <div class="select_invo" style="display: none;float: left;"><a href="javascript:void(0)" class=" all_down"  onclick="toReadPdf()">查看发票</a></div>
+                    <input type="file" class="up_file" name="file" upload_type="file" id="upload_file_pdf" style="display: none">
+                    <div class="upload_file" style="margin-left: 10px;float: left;"><a href="javascript:void(0)" class=" all_down"  onclick="fileOnclick(this)">点击上传发票</a></div>
+                </div>
+            </div>
+
+            <div class="row cl" id="" style="">
+                <label class="form-label col-1 col-sm-1" style="float: left;text-align: right;">发票代码 :</label>
+                <div class="formControls col-5 col-sm-5" style="float: left;">
+                    <input type="text" class="input-text trim_input" value="" placeholder="发票代码" id="billInvoiceCode" datatype="/^.{0,50}$/" name="billInvoiceCode" >
+                </div>
+            </div>
+
+            <div class="row cl" id="" style="">
+                <label class="form-label col-1 col-sm-1" style="float: left;text-align: right;">发票号码 :</label>
+                <div class="formControls col-5 col-sm-5" style="float: left;">
+                    <input type="text" class="input-text trim_input" value="" placeholder="发票号码" id="billInvoiceNum" datatype="/^.{0,50}$/" name="billInvoiceNum" >
+                </div>
+            </div>
+
+            <div class="row cl" id="" style="">
+                <label class="form-label col-1 col-sm-1" style="float: left;text-align: right;">开票日期 :</label>
+                <div class="formControls col-5 col-sm-5" style="float: left;">
+                    <input type="text" placeholder="开票日期" id="billInvoiceDate"  name="billInvoiceDate" datatype="*" class="input-text Wdate" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate: '%y-%M-%d'})"  readonly="readonly">
+                </div>
+            </div>
+
+            <div class="row cl" id="" style="margin-top: 50px;">
+                <div class="formControls col-11 col-sm-11" style="text-align: center;">
+                    <input type="submit" class="btn btn-primary add-order-button"  value="确定上传" >
+                </div>
+            </div>
+
+        </form>
+    </div>
+</article>
+
+<script type="text/javascript">
+    var url_path = "${path}";
+</script>
+<script type="text/javascript" src="${path}/common/lib/jquery/1.9.1/ajaxfileupload.js"></script>
+<script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
+
+
+<script type="text/javascript">
+    var billId = "${billId}";
+    var FILE_URL = "";
+
+    $(function(){
+        $("#upload_file_pdf").change(function() {
+            fileUpload("upload_file_pdf");
+        });
+    });
+
+    function fileOnclick(node){
+        $(node).parent().siblings('.up_file').click();
+    }
+
+    /***
+     * 发票上传
+     */
+    function fileUpload(idValue) {
+        $.ajaxFileUpload({
+            url:"/admin/ei_billing/upload_invoice?billId="+billId,
+            secureuri:false,
+            fileElementId : idValue,//文件选择框的id属性/名称
+            dataType: 'json',   //json
+            success: function (data) {
+                if(data.returnCode == 200){
+                    $("#billInvoiceFileUrl").val(data.returnMsg.path);
+                    FILE_URL = data.returnMsg.path;
+                    $(".select_invo").show();
+                    $(".upload_file").find("a").eq(0).html("重新上传发票");
+                }else{
+                    layer.msg('上传文件失败,请重试!',{icon: 5,time:2000});
+                }
+                $("#upload_file_pdf").change(function() {
+                    fileUpload("upload_file_pdf");
+                });
+            }
+        });
+    }
+
+    $(function(){
+        var loadIndex = 0;
+        $("#form-order-add").Validform({
+            tiptype: function (msg, o, cssctl) {
+                if (o.type == 3) {//失败
+                    layer.msg(msg, {icon: 5, time: 3000});
+                    $(window).scrollTop(o.obj.offset().top - 40);
+                }
+            },
+            datatype: {//自定义验证类型
+            },
+            ignoreHidden: true,
+            tipSweep: true, //若为true,则只在表单提交时验证
+            ajaxPost: true, //异步提交
+            beforeCheck: function (curform) {  //验证通过之前执行的函数
+                var flag = false;
+            },
+            beforeSubmit: function (curform) {  //验证通过之后执行的函数
+                var billInvoiceFileUrl = $("#billInvoiceFileUrl").val();
+                if(!isEmpty(billInvoiceFileUrl)){
+                    layer.msg("请上传发票文件!", {icon: 5, time: 3000});
+                    return false;
+                }
+                loadIndex = layer.load(1, {
+                    shade: [0.5,'#fff'] //0.1透明度的白色背景
+                });
+            },
+            callback: function (data) {//异步回调函数
+                if (data) {
+                    if (data.resultCode == 200) {
+                        layer.msg(data.resultMsg,{icon: 5,time:3000});
+                        parent.layer.close(parent.layer.getFrameIndex(window.name));
+                    }else {
+                        layer.msg("上传发票失败!", {icon: 5, time: 3000});
+                    }
+                    if(loadIndex != 0 ){
+                        layer.close(loadIndex);
+                    }
+                }
+                return false;
+            }
+        });
+    });
+
+    /**
+     * 查看pdf
+     * @param url
+     */
+    function toReadPdf() {
+        window.open("/"+FILE_URL);
+    }
+
+
+
+</script>
+
+
+</body>
+</html>