Преглед на файлове

Merge remote-tracking branch 'origin/0727' into 0727

zhoujiangyuan преди 4 години
родител
ревизия
3b486e4f11
променени са 24 файла, в които са добавени 701 реда и са изтрити 93 реда
  1. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java
  2. 403 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/DESDZFP.java
  3. 47 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/RandomUtil.java
  4. 31 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java
  5. 1 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayChargeSurveyMapper.java
  6. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/archives/PayBaseCustomerandmeterrelaMapper.java
  7. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayChargeSurveyDto.java
  8. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayInvoiceOrderDto.java
  9. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintInvoiceData.java
  10. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/UserServiceImpl.java
  11. 5 5
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/BaseClosingAccountInfoServiceImpl.java
  12. 54 29
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java
  13. 51 21
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayChargeSurveyServiceImpl.java
  14. 21 16
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java
  15. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayReceivableServiceImpl.java
  16. 12 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/IssueElectronicInvoiceService.java
  17. 3 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayChargeSurveyService.java
  18. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/PayBaseCustomerandmeterrelaService.java
  19. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java
  20. 25 0
      smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml
  21. 12 4
      smart-city-platform/src/main/resources/mapper/pay/PayChargeSurveyMapper.xml
  22. 3 1
      smart-city-platform/src/main/resources/mapper/pay/PayInvoiceMapper.xml
  23. 6 9
      smart-city-platform/src/main/resources/mapper/pay/PayPayReceivedMapper.xml
  24. 5 4
      smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java

@@ -65,7 +65,7 @@ public enum ResultStatus {
     OPERATE_RECORD_NOT_EXIT(-704,"未查询到有效记录"),
     ClOSING_ACCCOUNT_ERROR_EXIT(-705,"添加失败:账期已存在,不允许重复添加"),
     ClOSING_ACCCOUNT_ERROR_NOT_EXIT(-706,"结账失败:账期不存在"),
-    PAYFEE_TRANSAMOUNT_BELOW_ZERO(-707,"客户预存账户余额不足"),
+    PAYFEE_TRANSAMOUNT_BELOW_ZERO(-707,"交易金额必须大于零"),
     PAYFEE_QUERY_NO_CUSTOMER(-708,"未查询到有效客户信息"),
     WATER_PROPERTY_EDIT_EXIT(-709,"该用水性质已被应用,无法编辑"),
     WATER_PROPERTY_DELETE_EXIT(-709,"该用水性质已被应用,无法删除"),

+ 403 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/DESDZFP.java

@@ -0,0 +1,403 @@
+package com.bz.smart_city.commom.util;
+
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+/**
+ * 功能描述
+ * 加密常用类
+ */
+public class DESDZFP {
+	// 密钥是16位长度的byte[]进行Base64转换后得到的字符串
+	public static String key = "LmMGStGtOpF4xNyvYt54EQ==";
+
+	/**
+	 * <li>
+	 * 方法名称:encrypt</li> <li>
+	 * 加密方法
+	 * @param xmlStr
+	 *            需要加密的消息字符串
+	 * @return 加密后的字符串
+	 */
+	public static String encrypt(String xmlStr) {
+		byte[] encrypt = {};
+
+		try {
+			// 取需要加密内容的utf-8编码。
+			if(xmlStr != null){
+				encrypt = xmlStr.getBytes("utf-8");
+			}
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		// 取MD5Hash码,并组合加密数组
+		byte[] md5Hasn = null;
+		try {
+			md5Hasn = DESDZFP.MD5Hash(encrypt, 0, encrypt.length);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		// 组合消息体
+		byte[] totalByte = DESDZFP.addMD5(md5Hasn, encrypt);
+
+		// 取密钥和偏转向量
+		byte[] key = new byte[8];
+		byte[] iv = new byte[8];
+		getKeyIV(DESDZFP.key, key, iv);
+		SecretKeySpec deskey = new SecretKeySpec(key, "DES");
+		IvParameterSpec ivParam = new IvParameterSpec(iv);
+
+		// 使用DES算法使用加密消息体
+		byte[] temp = null;
+		try {
+			temp = DESDZFP.DES_CBC_Encrypt(totalByte, deskey, ivParam);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		// 使用Base64加密后返回
+		return new BASE64Encoder().encode(temp);
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:encrypt</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 解密方法
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param xmlStr
+	 *            需要解密的消息字符串
+	 * @return 解密后的字符串
+	 * @throws Exception
+	 */
+	public static String decrypt(String xmlStr) throws Exception {
+		// base64解码
+		BASE64Decoder decoder = new BASE64Decoder();
+		byte[] encBuf = null;
+		try {
+			if(xmlStr != null){
+				xmlStr = xmlStr.replaceAll(" ", "+");//解决URL里加号变空格
+			}
+			encBuf = decoder.decodeBuffer(xmlStr);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		// 取密钥和偏转向量
+		byte[] key = new byte[8];
+		byte[] iv = new byte[8];
+		getKeyIV(DESDZFP.key, key, iv);
+
+		SecretKeySpec deskey = new SecretKeySpec(key, "DES");
+		IvParameterSpec ivParam = new IvParameterSpec(iv);
+
+		// 使用DES算法解密
+		byte[] temp = null;
+		try {
+			temp = DESDZFP.DES_CBC_Decrypt(encBuf, deskey, ivParam);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		// 进行解密后的md5Hash校验
+		byte[] md5Hash = null;
+		try {
+			md5Hash = DESDZFP.MD5Hash(temp, 16, temp.length - 16);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		// 进行解密校检
+		for (int i = 0; i < md5Hash.length; i++) {
+			if (md5Hash[i] != temp[i]) {
+				// System.out.println(md5Hash[i] + "MD5校验错误。" + temp[i]);
+				throw new Exception("MD5校验错误。");
+			}
+		}
+
+		// 返回解密后的数组,其中前16位MD5Hash码要除去。
+		return new String(temp, 16, temp.length - 16, "utf-8");
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:TripleDES_CBC_Encrypt</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 经过封装的三重DES/CBC加密算法,如果包含中文,请注意编码。
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param sourceBuf
+	 *            需要加密内容的字节数组。
+	 * @param deskey
+	 *            KEY 由24位字节数组通过SecretKeySpec类转换而成。
+	 * @param ivParam
+	 *            IV偏转向量,由8位字节数组通过IvParameterSpec类转换而成。
+	 * @return 加密后的字节数组
+	 * @throws Exception
+	 */
+	public static byte[] TripleDES_CBC_Encrypt(byte[] sourceBuf,
+			SecretKeySpec deskey, IvParameterSpec ivParam) throws Exception {
+		byte[] cipherByte;
+		// 使用DES对称加密算法的CBC模式加密
+		Cipher encrypt = Cipher.getInstance("TripleDES/CBC/PKCS5Padding");
+
+		encrypt.init(Cipher.ENCRYPT_MODE, deskey, ivParam);
+
+		cipherByte = encrypt.doFinal(sourceBuf, 0, sourceBuf.length);
+		// 返回加密后的字节数组
+		return cipherByte;
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:TripleDES_CBC_Decrypt</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 经过封装的三重DES / CBC解密算法
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param sourceBuf
+	 *            需要解密内容的字节数组
+	 * @param deskey
+	 *            KEY 由24位字节数组通过SecretKeySpec类转换而成。
+	 * @param ivParam
+	 *            IV偏转向量,由6位字节数组通过IvParameterSpec类转换而成。
+	 * @return 解密后的字节数组
+	 * @throws Exception
+	 */
+	public static byte[] TripleDES_CBC_Decrypt(byte[] sourceBuf,
+			SecretKeySpec deskey, IvParameterSpec ivParam) throws Exception {
+
+		byte[] cipherByte;
+		// 获得Cipher实例,使用CBC模式。
+		Cipher decrypt = Cipher.getInstance("TripleDES/CBC/PKCS5Padding");
+		// 初始化加密实例,定义为解密功能,并传入密钥,偏转向量
+		decrypt.init(Cipher.DECRYPT_MODE, deskey, ivParam);
+
+		cipherByte = decrypt.doFinal(sourceBuf, 0, sourceBuf.length);
+		// 返回解密后的字节数组
+		return cipherByte;
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:DES_CBC_Encrypt</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 经过封装的DES/CBC加密算法,如果包含中文,请注意编码。
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param sourceBuf
+	 *            需要加密内容的字节数组。
+	 * @param deskey
+	 *            KEY 由8位字节数组通过SecretKeySpec类转换而成。
+	 * @param ivParam
+	 *            IV偏转向量,由8位字节数组通过IvParameterSpec类转换而成。
+	 * @return 加密后的字节数组
+	 * @throws Exception
+	 */
+	public static byte[] DES_CBC_Encrypt(byte[] sourceBuf,
+			SecretKeySpec deskey, IvParameterSpec ivParam) throws Exception {
+		byte[] cipherByte;
+		// 使用DES对称加密算法的CBC模式加密
+		Cipher encrypt = Cipher.getInstance("DES/CBC/PKCS5Padding");
+
+		encrypt.init(Cipher.ENCRYPT_MODE, deskey, ivParam);
+
+		cipherByte = encrypt.doFinal(sourceBuf, 0, sourceBuf.length);
+		// 返回加密后的字节数组
+		return cipherByte;
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:DES_CBC_Decrypt</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 经过封装的DES/CBC解密算法。
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param sourceBuf
+	 *            需要解密内容的字节数组
+	 * @param deskey
+	 *            KEY 由8位字节数组通过SecretKeySpec类转换而成。
+	 * @param ivParam
+	 *            IV偏转向量,由6位字节数组通过IvParameterSpec类转换而成。
+	 * @return 解密后的字节数组
+	 * @throws Exception
+	 */
+	public static byte[] DES_CBC_Decrypt(byte[] sourceBuf,
+			SecretKeySpec deskey, IvParameterSpec ivParam) throws Exception {
+
+		byte[] cipherByte;
+		// 获得Cipher实例,使用CBC模式。
+		Cipher decrypt = Cipher.getInstance("DES/CBC/PKCS5Padding");
+		// 初始化加密实例,定义为解密功能,并传入密钥,偏转向量
+		decrypt.init(Cipher.DECRYPT_MODE, deskey, ivParam);
+
+		cipherByte = decrypt.doFinal(sourceBuf, 0, sourceBuf.length);
+		// 返回解密后的字节数组
+		return cipherByte;
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:MD5Hash</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * MD5,进行了简单的封装,以适用于加,解密字符串的校验。
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param buf
+	 *            需要MD5加密字节数组。
+	 * @param offset
+	 *            加密数据起始位置。
+	 * @param length
+	 *            需要加密的数组长度。
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] MD5Hash(byte[] buf, int offset, int length)
+			throws Exception {
+		MessageDigest md = MessageDigest.getInstance("MD5");
+		md.update(buf, offset, length);
+		return md.digest();
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:byte2hex</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 字节数组转换为二行制表示
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param inStr
+	 *            需要转换字节数组。
+	 * @return 字节数组的二进制表示。
+	 */
+	public static String byte2hex(byte[] inStr) {
+		String stmp;
+		StringBuffer out = new StringBuffer(inStr.length * 2);
+
+		for (int n = 0; n < inStr.length; n++) {
+			// 字节做"与"运算,去除高位置字节 11111111
+			stmp = Integer.toHexString(inStr[n] & 0xFF);
+			if (stmp.length() == 1) {
+				// 如果是0至F的单位字符串,则添加0
+				out.append("0" + stmp);
+			} else {
+				out.append(stmp);
+			}
+		}
+		return out.toString();
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:addMD5</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * MD校验码 组合方法,前16位放MD5Hash码。 把MD5验证码byte[],加密内容byte[]组合的方法。
+	 * </pre>
+	 * 
+	 * </li>
+	 * 
+	 * @param md5Byte
+	 *            加密内容的MD5Hash字节数组。
+	 * @param bodyByte
+	 *            加密内容字节数组
+	 * @return 组合后的字节数组,比加密内容长16个字节。
+	 */
+	public static byte[] addMD5(byte[] md5Byte, byte[] bodyByte) {
+		int length = bodyByte.length + md5Byte.length;
+		byte[] resutlByte = new byte[length];
+
+		// 前16位放MD5Hash码
+		for (int i = 0; i < length; i++) {
+			if (i < md5Byte.length) {
+				resutlByte[i] = md5Byte[i];
+			} else {
+				resutlByte[i] = bodyByte[i - md5Byte.length];
+			}
+		}
+
+		return resutlByte;
+	}
+
+	/**
+	 * <li>
+	 * 方法名称:getKeyIV</li> <li>
+	 * 功能描述:
+	 * 
+	 * <pre>
+	 * 
+	 * </pre>
+	 * </li>
+	 * 
+	 * @param encryptKey
+	 * @param key
+	 * @param iv
+	 */
+	public static void getKeyIV(String encryptKey, byte[] key, byte[] iv) {
+		// 密钥Base64解密
+		BASE64Decoder decoder = new BASE64Decoder();
+		byte[] buf = null;
+		try {
+			buf = decoder.decodeBuffer(encryptKey);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		// 前8位为key
+		int i;
+		for (i = 0; i < key.length; i++) {
+			key[i] = buf[i];
+		}
+		// 后8位为iv向量
+		for (i = 0; i < iv.length; i++) {
+			iv[i] = buf[i + 8];
+		}
+	}
+	
+	public static void main(String[] args) throws Exception {
+		String str="{\"identity\":\"B8FB14CA1C6D7C93D9154E2262FF0F9DD796B180A2A7690A\",\"order\":{\"orderno\":\"No.20160308151221\",\"saletaxnum\":\"110101MXB6CK9Q6\",\"saleaddress\":\"万塘路30号\",\"salephone\":\"0571-1234567\",\"saleaccount\":\"工商银行6222222222222\",\"clerk\":\"sa\",\"payee\":\"sa\",\"checker\":\"sa\",\"invoicedate\":\"2016-03-08 15:12:21\",\"ordertotal\":\"8.00\",\"kptype\":\"1\",\"taxtotal\":\"1.16\",\"bhtaxtotal\":\"6.84\",\"address\":\"浙江杭州 0571-123456789\",\"phone\":\"0571-123456789\",\"taxnum\":\"339900000000004\",\"buyername\":\"浙江爱信诺航天信息有限公司\",\"account\":\"工商-123456789浙江爱信诺航天信息有限公司\",\"message\":\"浙江爱信诺航天信息有限公司\",\"fpdm\":\"\",\"fphm\":\"\",\"detail\":[{\"goodsname\":\"1\",\"spec\":\"1\",\"unit\":\"1\",\"hsbz\":\"1\",\"num\":\"1\",\"price\":\"4\",\"taxrate\":\"0.17\"},{\"goodsname\":\"2\",\"spec\":\"2\",\"unit\":\"2\",\"hsbz\":\"1\",\"num\":\"1\",\"price\":\"4\",\"taxrate\":\"0.17\"}]}}";
+		str=encrypt(str);
+		System.out.println(str);
+		str=decrypt(str);
+		System.out.println(str);
+	}
+}

+ 47 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/RandomUtil.java

@@ -0,0 +1,47 @@
+package com.bz.smart_city.commom.util;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+/**
+ * @ClassName RandomUtil
+ * @Description: 随机数
+ * @Author :WYY
+ * @Date 2020/8/10
+ * @Version V1.0
+ **/
+public class RandomUtil {
+    /**
+     * 获取6-10 的随机位数数字
+     *
+     * @param length 想要生成的长度
+     * @return result
+     */
+    public static String getRandom620(Integer length) {
+        String result = "";
+        Random rand = new Random();
+        int n = 20;
+        if (null != length && length > 0) {
+            n = length;
+        }
+        int randInt = 0;
+        for (int i = 0; i < n; i++) {
+            randInt = rand.nextInt(10);
+            result += randInt;
+        }
+        return result;
+    }
+
+    public static String getRandomString() {
+        //格式化当前时间
+        SimpleDateFormat sfDate = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+        String strDate = sfDate.format(new Date());
+        //为了防止高并发重复,再获取3个随机数
+        String random = getRandom620(3);
+
+        //最后得到20位订单编号。
+        return (strDate + random);
+
+    }
+}

+ 31 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java

@@ -0,0 +1,31 @@
+package com.bz.smart_city.controller.pay;
+
+import com.bz.smart_city.service.pay.IssueElectronicInvoiceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @ClassName PayPrintInvoiceController
+ * @Description: TODO
+ * @Author :WYY
+ * @Date 2020/8/7
+ * @Version V1.0
+ **/
+@RestController
+@RequestMapping(value = "printinvoice")
+@Api(tags = "计费系统-收费管理-发票管理")
+public class PayPrintInvoiceController {
+    @Autowired
+    private IssueElectronicInvoiceService issueElectronicInvoiceService;
+
+    @ApiOperation(value = "请求打印")
+    @GetMapping(value = "/printRequest")
+    public void printInoice()
+    {
+        issueElectronicInvoiceService.requestPrint("1","0460000003","C046000000301200522155950402");
+    }
+}

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayChargeSurveyMapper.java

@@ -13,7 +13,7 @@ import java.util.List;
 @Mapper
 public interface PayChargeSurveyMapper {
 
-    public Integer getAccountCount();
+    public Integer getAccountCount(@Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 
     public PayAccountSurvey getlastNumber(@Param("year")Integer year, @Param("month")Integer month,
                                           @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/archives/PayBaseCustomerandmeterrelaMapper.java

@@ -97,4 +97,6 @@ public interface PayBaseCustomerandmeterrelaMapper {
     public Integer queryMeterState( @Param("customerId")Integer customerId,@Param("accountId")BigInteger accountId);
 
     public Organization getParentOfficeId( @Param("siteId")Integer siteId,@Param("id")Integer id,@Param("name") String name);
+
+    public PayBaseCustomerandmeterrela findAccountByAccountNumber(@Param("siteId") Integer siteId, @Param("customerId")Integer customerId,@Param("accountnumber")String accountnumber);
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayChargeSurveyDto.java

@@ -32,6 +32,10 @@ public class PayChargeSurveyDto {
     //饼状图
     @ApiModelProperty(value = "开户率")
     private String customerRate;
+    @ApiModelProperty(value = "较上月开户率")
+    private String lastCMRate;
+    @ApiModelProperty(value = "开户较上月 0下降 1上升")
+    private Integer lastCMIsUp;
 
     //统计折线图
     @ApiModelProperty(value = "折线图-按月")

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayInvoiceOrderDto.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.dto.pay;
 
+import com.alibaba.fastjson.annotation.JSONField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -34,6 +35,7 @@ public class PayInvoiceOrderDto {
     private String orderno;
     @ApiModelProperty(name = "开票时间",notes = "必填")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
     private LocalDateTime invoicedate;
     @ApiModelProperty(name = "开票员",notes = "必填,最大长度20")
     private String clerk;

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintInvoiceData.java

@@ -22,6 +22,8 @@ public class PrintInvoiceData {
 
     @ApiModelProperty(value = "收据类型:1充值 2缴费")
     private Integer printType ;
+    @ApiModelProperty(value = "客户名称(水司名称)")
+    private String customerName ;
     @ApiModelProperty(value = "交易流水号")
     private String payseriesno ;
     @ApiModelProperty(value = "票据号码")

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/UserServiceImpl.java

@@ -554,6 +554,7 @@ public class UserServiceImpl implements UserService {
             loginUser.setSiteType(site.getType());
 
             loginUser.setCustomerId(site.getCustomerId());
+            loginUser.setCustomerName(site.getCustomerName());
             loginUser.setOrgId(siteUser.getOrganId());
             tokenService.saveToken(loginUser);
             //保存redis

+ 5 - 5
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/BaseClosingAccountInfoServiceImpl.java

@@ -123,7 +123,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
             //1.先判断客户概况表是否存在记录,如果不存在则按账期月去卡旧数据的客户总数、水表总数、开户总数
             //2.根据历史账期对旧数据进行入库保存
             //查看记录表是否已经存在数据,为NULL则代表没有存在历史数据
-            Integer count = payChargeSurveyMapper.getAccountCount();
+            Integer count = payChargeSurveyMapper.getAccountCount(BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
             if(count <= 0){
                 //按账期月卡旧数据
                 List<BaseClosingAccountInfoDto> list = baseClosingAccountInfoMapper.getListNumber(null,null,
@@ -215,13 +215,13 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
 
             //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
             Integer accountNumber = payChargeSurveyMapper.getAccountNumber
-                    (strarDate,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                    (null,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
             //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
             Integer meterNumber = payChargeSurveyMapper.getMeterNumber
-                    (strarDate,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                    (null,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
             //根据账期查找历史开户数(仅统计状态为正常的开户总数)
             Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
-                    (strarDate,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+                    (null,endDate,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
 
             //上一账期汇总
             PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
@@ -406,7 +406,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
             lastBankIncome = lastBankIncome.add(recelastBankIncome);
             lastCashIncome = lastCashIncome.add(recelastCashIncome);
 
-            transactionSurver.setLastAlipayIncome(lastCashIncome);
+            transactionSurver.setLastAlipayIncome(lastAlipayIncome);
             transactionSurver.setLastWechatIncome(lastWechatIncome);
             transactionSurver.setLastBankIncome(lastBankIncome);
             transactionSurver.setLastCashIncome(lastCashIncome);

+ 54 - 29
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java

@@ -1,22 +1,26 @@
 package com.bz.smart_city.service.impl.pay;
 
+import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.util.DESDZFP;
+import com.bz.smart_city.commom.util.HttpClientUtils;
+import com.bz.smart_city.commom.util.RandomUtil;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.entity.pay.PayBaseAccount;
 import com.bz.smart_city.entity.pay.PayInvoiceParam;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
-import com.bz.smart_city.service.pay.PayBaseAccountService;
-import com.bz.smart_city.service.pay.PayBaseConfigService;
-import com.bz.smart_city.service.pay.PayInvoiceParamService;
-import com.bz.smart_city.service.pay.PayPayReceivedService;
+import com.bz.smart_city.service.pay.*;
+import com.bz.smart_city.service.pay.archives.PayBaseCustomerandmeterrelaService;
+import com.google.gson.JsonObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.time.LocalDateTime;
 import java.util.*;
 
 /**
@@ -27,7 +31,7 @@ import java.util.*;
  * @Version V1.0
  **/
 @Service
-public class IssueElectronicInvoiceServiceImpl {
+public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoiceService {
     @Autowired
     PayBaseConfigService payBaseConfigService;
     @Autowired
@@ -36,6 +40,8 @@ public class IssueElectronicInvoiceServiceImpl {
     PayBaseAccountService payBaseAccountService;
     @Autowired
     PayPayReceivedService payPayReceivedService;
+    @Autowired
+    PayBaseCustomerandmeterrelaService payBaseCustomerandmeterrelaService;
 
     private Map<String, String> getPrintParam() {
         Map<String, String> map = new HashMap<>();
@@ -43,7 +49,7 @@ public class IssueElectronicInvoiceServiceImpl {
         Pagination<PayBaseConfigDto> payBaseConfigDtoPagination = payBaseConfigService.getAll("PRINT_", 1, 15);
         List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigDtoPagination.getList();
         for (PayBaseConfigDto item : payBaseConfigDtos) {
-            switch (item.getName()) {
+            switch (item.getName().trim()) {
                 case "PRINT_INVOICE_ADDRESS":
                     map.put("saleAddress", item.getValue());
                     break;
@@ -78,14 +84,17 @@ public class IssueElectronicInvoiceServiceImpl {
         }
         return map;
     }
-    public BigDecimal saveTwoDecimal(BigDecimal d){
-        BigDecimal a =d.setScale(2,BigDecimal.ROUND_HALF_UP);
+
+    public BigDecimal saveTwoDecimal(BigDecimal d) {
+        BigDecimal a = d.setScale(2, BigDecimal.ROUND_HALF_UP);
         return a;
     }
-    public BigDecimal saveEightDecimal(BigDecimal d){
-        BigDecimal a =d.setScale(8,BigDecimal.ROUND_HALF_UP);
+
+    public BigDecimal saveEightDecimal(BigDecimal d) {
+        BigDecimal a = d.setScale(8, BigDecimal.ROUND_HALF_UP);
         return a;
     }
+
     /**
      * @MethodName:
      * @Description: TODO
@@ -94,8 +103,7 @@ public class IssueElectronicInvoiceServiceImpl {
      * @Author:
      * @Date: 2020/7/28
      **/
-    @Async
-    public void requestPrint(String kpType,String userCode,String payseriesno) {
+    public void requestPrint(String kpType, String userCode, String payseriesno) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String name = loginUser.getName();//操作员姓名
         BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
@@ -113,12 +121,18 @@ public class IssueElectronicInvoiceServiceImpl {
         payInvoiceOrderDto.setSaleaddress(invoiceParam.get("saleAddress"));//销方地址
         payInvoiceOrderDto.setSaletaxnum(invoiceParam.get("saleCode"));//销方税号
         payInvoiceOrderDto.setChecker(invoiceParam.get("saleChecker"));//复核人
-        payInvoiceOrderDto.setClerk(name);//开票人
-        payInvoiceOrderDto.setPayee(name);//收款人
+        if(name.length()>4) {
+            name = "*" + name.substring(name.length() - 3, name.length());
+            payInvoiceOrderDto.setClerk(name);//开票人
+            payInvoiceOrderDto.setPayee(name);//收款人
+        }
+
         payInvoiceOrderDto.setKptype(kpType);//开票类型
         payInvoiceOrderDto.setTsfs("2");//推送方式
+        payInvoiceOrderDto.setInvoicedate(LocalDateTime.now());
+        payInvoiceOrderDto.setOrderno(RandomUtil.getRandomString());
         //查询购方相关信息
-        PayBaseCustomerandmeterrela payBaseAccount = new PayBaseCustomerandmeterrela();
+        PayBaseCustomerandmeterrela payBaseAccount = payBaseCustomerandmeterrelaService.findAccountByAccountNumber(userCode);
         payInvoiceOrderDto.setBuyername(payBaseAccount.getAccountname());//购方名称
         payInvoiceOrderDto.setPhone(payBaseAccount.getTelephone());//电话
         payInvoiceOrderDto.setAddress(payBaseAccount.getAddress());//地址
@@ -127,9 +141,9 @@ public class IssueElectronicInvoiceServiceImpl {
 
         List<PayInvoiceOrderDetailDto> orderDetailDtos = new ArrayList<>();
         //循环加入明细
-        List<PayReceivedInvoiceDto> payReceivedInvoiceDtos = payPayReceivedService.findInvoiceReceivedByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
+        List<PayReceivedInvoiceDto> payReceivedInvoiceDtos = payPayReceivedService.findInvoiceReceivedByPayseriesno(payseriesno, loginUser.getSiteId(), loginUser.getCustomerId());
         //将水费分开,其他类型水费合并todo
-        for (PayReceivedInvoiceDto item:payReceivedInvoiceDtos) {
+        for (PayReceivedInvoiceDto item : payReceivedInvoiceDtos) {
             PayInvoiceOrderDetailDto orderDetailDto = new PayInvoiceOrderDetailDto();
             PayInvoiceParam payInvoiceParam = invoiceMap.get(item.getFeetype());
             orderDetailDto.setGoodsname(item.getFeetypename());
@@ -138,22 +152,22 @@ public class IssueElectronicInvoiceServiceImpl {
             //含税标志为0 不含税,税额=round((数量*不含税单价)*税率),2),含税金额=不含税金额+税额
             BigDecimal taxAmount = new BigDecimal(0);//税额
             BigDecimal receAmount = item.getReceivedamount();//实收金额
-            BigDecimal rate =new BigDecimal(payInvoiceParam.getTaxrate());//税率
-            if(payInvoiceParam.getPricetax().equals("1"))
-            {
-                taxAmount = saveTwoDecimal(receAmount.multiply(rate).divide(rate.add(BigDecimal.valueOf(1))));
-
-            }else
-            {
+            BigDecimal rate = new BigDecimal(payInvoiceParam.getTaxrate());//税率
+            if (payInvoiceParam.getPricetax().equals("1")) {
+                taxAmount = saveTwoDecimal(receAmount.multiply(rate).divide(rate.add(BigDecimal.valueOf(1)),2, BigDecimal.ROUND_HALF_UP));
+                orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
+                orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.subtract(taxAmount))));//不含税金额
+            } else {
                 taxAmount = saveTwoDecimal(receAmount.multiply(rate));
+                orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
+                orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount))));//不含税金额
             }
-            orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
-            orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.subtract(taxAmount))));//不含税金额
-            if(item.getPrice()!=null) {
+
+            if (item.getPrice() != null) {
                 orderDetailDto.setPrice(String.valueOf(saveTwoDecimal(item.getPrice())));
-                orderDetailDto.setNum(String.valueOf(saveEightDecimal(receAmount.subtract(taxAmount).divide(saveTwoDecimal(item.getPrice())))));
+                orderDetailDto.setNum(String.valueOf(receAmount.divide(saveTwoDecimal(item.getPrice()), 8, BigDecimal.ROUND_HALF_UP)));
             }
-            if(!payInvoiceParam.getZerotax().equals("0")) {
+            if (!payInvoiceParam.getZerotax().equals("0")) {
                 orderDetailDto.setLslbs(payInvoiceParam.getZerotax());//零税率标志
             }
             orderDetailDto.setZzstsgl(payInvoiceParam.getOthermanger());//增值税特殊管理
@@ -170,6 +184,17 @@ public class IssueElectronicInvoiceServiceImpl {
             orderDetailDtos.add(orderDetailDto);
         }
         payInvoiceOrderDto.setDetail(orderDetailDtos);
+        payInvoiceOrderDto.setEmail("wangyangyang@hxiswater.com");
         payEleInvoiceDto.setOrder(payInvoiceOrderDto);
+        //发送开票请求
+        String jsonsString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceDto));
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("order", jsonsString);
+        try {
+            String returnString = HttpClientUtils.doPost("http://nnfpbox.nuonuocs.cn/shop/buyer/allow/cxfKp/cxfServerKpOrderSync.action", map);
+            System.out.println("returnString:" + returnString);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 }

+ 51 - 21
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayChargeSurveyServiceImpl.java

@@ -32,8 +32,8 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
     private BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
 
 
-    public Integer getAccountCount(){
-        return payChargeSurveyMapper.getAccountCount();
+    public Integer getAccountCount(BigInteger siteId,BigInteger customerId){
+        return payChargeSurveyMapper.getAccountCount(siteId,customerId);
     }
 
     public static void main(String[] args) {
@@ -110,7 +110,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
             //上一账期汇总
             String lastDate = list.get(1).getYear() +"-"+String.format("%02d", list.get(1).getMonth())+"-01";
-            PayAccountSurvey accountSurvey = payChargeSurveyMapper.getlastAccount(null,siteId,customerId);
+            PayAccountSurvey accountSurvey = payChargeSurveyMapper.getlastAccount(lastDate,siteId,customerId);
 
             //客户总数计算
             //当前账期以内客户总数
@@ -173,10 +173,35 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
             //开户率
             String customerRate = "0.0";
-            num =((float)sumCustomer/(sumMeter != null && sumMeter != 0 ? sumMeter : 1)*100);
-            customerRate = df.format(num);
+            float customernum =((float)sumCustomer/(sumMeter != null && sumMeter != 0 ? sumMeter : 1)*100);
+            customerRate = df.format(customernum);
             customerRate = customerRate.contains("-") ? customerRate.split("-")[1] : customerRate;
-            payChargeSurveyDto.setCustomerRate(customerRate != null && customerRate != "" ? customerRate : "0.0");
+
+            //较上月开户率
+            float lastcustomernum =((float)sumLastCustomer/(sumLastMeter != null && sumLastMeter != 0 ? sumLastMeter : 1)*100);
+            String lastCMRate = "-";
+            Integer lastCMIsUp = 0;
+            if(lastcustomernum >0){
+                if(customernum - lastcustomernum <=0){
+                    //本期减上期持平显示→
+                    lastCMIsUp = 2;
+                    lastCMRate = "→";
+                }else{
+                    num = customernum - lastcustomernum;
+                    lastCMRate = df.format(num);
+                    lastCMIsUp = num > 0  ? 1 : 0;
+                    //截取字符串
+                    lastCMRate = lastCMRate.contains("-") ? lastCMRate.split("-")[1] : lastCMRate;
+                }
+            }else{
+                //小于=0不计算增长率
+                //0下降  1上升 2不计算
+                lastCMIsUp = 2;
+                lastCMRate = "-";
+            }
+            payChargeSurveyDto.setCustomerRate(customerRate);
+            payChargeSurveyDto.setLastCMRate(lastCMRate != null && lastCMRate != "" ? lastCMRate : "0.0");
+            payChargeSurveyDto.setLastCMIsUp(lastCMIsUp);
 
 
             //折线图统计,取最近一年
@@ -191,9 +216,9 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
             List<PayChangePeriodDto> accountList2 = new ArrayList<PayChangePeriodDto>();
             periodDto.setYear(list.get(0).getYear());
             periodDto.setMonth(list.get(0).getMonth());
-            periodDto.setAccountNumber(sumCurrentAccount);
-            periodDto.setCustomerNumber(sumCurrentCustomer);
-            periodDto.setMeterNumber(sumCurrentMeter);
+            periodDto.setAccountNumber(sumAccount);
+            periodDto.setCustomerNumber(sumCustomer);
+            periodDto.setMeterNumber(sumMeter);
             accountList2.add(periodDto);
             accountList2.addAll(accoutList);
             //填补缺失月
@@ -344,7 +369,9 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
                 payTransactionSurveyDto = this.tranCompute(payTransactionSurvey);
             }else {
                 //查询交易记录表
-                PayTransactionSurvey transactionSurver = payChargeSurveyMapper.getLastTranRocord(year,month,siteId,customerId);
+                PayTransactionSurvey transactionSurver = new PayTransactionSurvey();
+                transactionSurver = payChargeSurveyMapper.getLastTranRocord(year,month,siteId,customerId);
+                transactionSurver = transactionSurver != null ? transactionSurver : new PayTransactionSurvey();
                 transactionSurver.setYear(year);
                 transactionSurver.setMonth(month);
                 payTransactionSurveyDto = this.tranCompute(transactionSurver);
@@ -380,8 +407,10 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         String lastAlipayRate = "";//支付宝比率
         String lastBankRate = "";//银行比率
         try {
-            BigDecimal currentIncome = transactionSurver.getIncomeNumber();//本月收入总数
-            BigDecimal lastIncome = transactionSurver.getLastIncomeNumber();//上月收入总数
+            //本月收入总数
+            BigDecimal currentIncome = transactionSurver != null && transactionSurver.getIncomeNumber() != null ? transactionSurver.getIncomeNumber() : defc;
+            //上月收入总数
+            BigDecimal lastIncome = transactionSurver != null && transactionSurver.getLastIncomeNumber() != null ? transactionSurver.getLastIncomeNumber() : defc;
 
             RecordInfo info = this.calculationRate(currentIncome,lastIncome);
             BigDecimal income = info.getIncome();
@@ -390,17 +419,18 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
 
             //按支付方式
-            cashIncome = transactionSurver.getCashIncome();//本账期现金收入
-            lastcashIncome = transactionSurver.getLastCashIncome();//上期现金收入
+            cashIncome = transactionSurver != null && transactionSurver.getCashIncome() != null ? transactionSurver.getCashIncome() : defc;//本账期现金收入
+
+            lastcashIncome = transactionSurver != null && transactionSurver.getLastCashIncome() != null ? transactionSurver.getLastCashIncome() : defc;//上期现金收入
 
-            wechatIncome = transactionSurver.getWechatIncome();//本账期微信
-            lastwechatIncome = transactionSurver.getLastWechatIncome();//上期微信
+            wechatIncome = transactionSurver != null && transactionSurver.getWechatIncome() != null ? transactionSurver.getWechatIncome() : defc;//本账期微信
+            lastwechatIncome = transactionSurver != null && transactionSurver.getLastWechatIncome() != null ? transactionSurver.getLastWechatIncome() : defc;//上期微信
 
-            alipayIncome = transactionSurver.getAlipayIncome();//本账期支付宝
-            lastalipayIncome = transactionSurver.getLastAlipayIncome();//上期支付宝
+            alipayIncome = transactionSurver != null && transactionSurver.getAlipayIncome() != null ? transactionSurver.getAlipayIncome() : defc;//本账期支付宝
+            lastalipayIncome = transactionSurver != null && transactionSurver.getLastAlipayIncome() != null ? transactionSurver.getLastAlipayIncome() : defc;//上期支付宝
 
-            bankIncome = transactionSurver.getBankIncome();//本账期银行
-            lastbankIncome = transactionSurver.getLastBankIncome();//上期银行
+            bankIncome = transactionSurver != null && transactionSurver.getBankIncome() != null ? transactionSurver.getBankIncome() : defc;//本账期银行
+            lastbankIncome = transactionSurver != null && transactionSurver.getLastBankIncome() != null ? transactionSurver.getLastBankIncome() : defc;//上期银行
 
 
             info = this.calculationRate(cashIncome,lastcashIncome);
@@ -761,7 +791,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         BigDecimal defb = new BigDecimal("1.0");
         DecimalFormat df = new DecimalFormat("0.0");
         try{
-            if(lastIncome.compareTo(BigDecimal.ZERO) == 1){
+            if(lastIncome != null && lastIncome.compareTo(BigDecimal.ZERO) == 1){
                 if(currentIncome.subtract(lastIncome).compareTo(BigDecimal.ZERO) == 0){
                     //本期减上期持平显示→
                     lastIncomeIsUp = 2;

+ 21 - 16
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java

@@ -52,6 +52,10 @@ public class PayFeeServiceImp implements PayFeeService {
     BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
 
     public PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype){
+        //交易金额不可为负数
+        if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
+        }
 //        String result="";   //执行结果描述
         String result="<br>实收金额:"+String.format("%.2f",transAmount)+"元";
         BigDecimal fees=BigDecimal.ZERO;    //抵扣金额
@@ -101,10 +105,7 @@ public class PayFeeServiceImp implements PayFeeService {
         //如果传入时间则用传入的时间做交易时间
         LocalDateTime localDateTime=LocalDateTime.now();
 
-        //交易金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)==-1){
-            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
-        }
+
 
         //生成批次号
         // 微信:W  现金、预存账户:C 银行:B 支付宝:A
@@ -273,6 +274,10 @@ public class PayFeeServiceImp implements PayFeeService {
     */
    @Transactional(rollbackFor = Exception.class)
     public String payFee(String accountnumber, String metercode, BigDecimal transAmount, Integer payway , LocalDateTime transTime, List<BigInteger> receivableIds,Integer siteId,Integer customerId,Integer userId) {
+       //交易金额不可为负数
+       if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+           throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
+       }
         LoginUser loginUser = UserUtil.getCurrentUser();
         if(loginUser !=null){
             if(siteId==null  )
@@ -346,10 +351,7 @@ public class PayFeeServiceImp implements PayFeeService {
         if(transTime != null){
             localDateTime=transTime;
         }
-        //交易金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)==-1){
-            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
-        }
+
 
         //生成批次号
        // 微信:W  现金、预存账户:C 银行:B 支付宝:A
@@ -514,6 +516,11 @@ public class PayFeeServiceImp implements PayFeeService {
      */
     @Transactional(rollbackFor = Exception.class)
     public PayfeeResult rechargefeeCounter(String  accountId , BigDecimal transAmount, Integer payway ){
+
+        //交易金额不可为负数
+        if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
+        }
         LoginUser loginUser = UserUtil.getCurrentUser();
 
         Integer siteId = loginUser.getSiteId();
@@ -535,10 +542,7 @@ public class PayFeeServiceImp implements PayFeeService {
         //如果传入时间则用传入的时间做交易时间
         LocalDateTime localDateTime=LocalDateTime.now();
 
-        //交易金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)==-1){
-            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
-        }
+
 
         //根据客户id
         PayCustomRechargeDto payCustomRechargeDto = null;
@@ -576,6 +580,10 @@ public class PayFeeServiceImp implements PayFeeService {
      */
     @Transactional(rollbackFor = Exception.class)
     public String rechargefee(String accountnumber, String metercode, BigDecimal transAmount, Integer payway , LocalDateTime transTime,Integer siteId,Integer customerId,Integer userId){
+        //交易金额不可为负数
+        if(transAmount.compareTo(BigDecimal.ZERO)!=1){
+            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
+        }
         LoginUser loginUser = UserUtil.getCurrentUser();
         if(loginUser !=null) {
             if (siteId == null) {
@@ -603,10 +611,7 @@ public class PayFeeServiceImp implements PayFeeService {
         if(transTime != null){
             localDateTime=transTime;
         }
-        //交易金额不可为负数
-        if(transAmount.compareTo(BigDecimal.ZERO)==-1){
-            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
-        }
+
 
         //根据客编或者水编获取客户信息
         PayCustomRechargeDto payCustomRechargeDto = null;

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayReceivableServiceImpl.java

@@ -108,6 +108,8 @@ public class PayReceivableServiceImpl implements PayReceivableService {
         dto.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
         dto.setBeginDate(beginDate);
         dto.setEndDate(endDate);
+        dto.setYear(year);
+        dto.setMonth(month);
         dto.setState(state);
         return payPayReceivableMapper.findListInfo(dto);
     }

+ 12 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/IssueElectronicInvoiceService.java

@@ -0,0 +1,12 @@
+package com.bz.smart_city.service.pay;
+
+/**
+ * @ClassName IssueElectronicInvoiceService
+ * @Description: TODO
+ * @Author :WYY
+ * @Date 2020/8/7
+ * @Version V1.0
+ **/
+public interface IssueElectronicInvoiceService {
+    void requestPrint(String kpType, String userCode, String payseriesno);
+}

+ 3 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayChargeSurveyService.java

@@ -5,8 +5,10 @@ import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
 import com.bz.smart_city.dto.pay.PayFeeSueveyDto;
 import com.bz.smart_city.dto.pay.PayTransactionSurveyDto;
 
+import java.math.BigInteger;
+
 public interface PayChargeSurveyService {
-    public Integer getAccountCount();
+    public Integer getAccountCount(BigInteger siteId,BigInteger customerId);
 
     public PayChargeSurveyDto accountSurvey();
 

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/PayBaseCustomerandmeterrelaService.java

@@ -6,6 +6,7 @@ import com.bz.smart_city.dto.pay.PayCustomerDto;
 import com.bz.smart_city.dto.pay.PaySaveCustomerDto;
 import com.bz.smart_city.entity.pay.PayPayRechargeaccount;
 import com.bz.smart_city.entity.pay.archives.*;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
@@ -53,5 +54,5 @@ public interface PayBaseCustomerandmeterrelaService {
     public Pagination<CustomerListInfo> selectAccountnumberList(String accountnumber,int pageNum, int pageSize);
 
     public List<PayBaseCustomerandmeterrelaDto> getResetLadderList(Integer siteId,Integer customerId);
-
+    public PayBaseCustomerandmeterrela findAccountByAccountNumber(String accountnumber);
 }

+ 6 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/archives/impl/PayBaseCustomerandmeterrelaServiceImpl.java

@@ -160,6 +160,12 @@ public class PayBaseCustomerandmeterrelaServiceImpl implements PayBaseCustomeran
         return payBaseCustomerandmeterrelaMapper.getResetLadderList(siteId,customerId);
     }
 
+    @Override
+    public PayBaseCustomerandmeterrela findAccountByAccountNumber(String accountnumber) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return payBaseCustomerandmeterrelaMapper.findAccountByAccountNumber(loginUser.getSiteId(),loginUser.getCustomerId(),accountnumber);
+    }
+
     /**
      * 水表档案号搜索
      * @return

+ 25 - 0
smart-city-platform/src/main/resources/mapper/PayBaseCustomerandmeterrelaMapper.xml

@@ -606,4 +606,29 @@
     <select id="getParentOfficeId" resultType="com.bz.smart_city.entity.Organization">
         select id from sc_organization where site_id =#{siteId} and parent_id =#{id} and name =#{name}
     </select>
+    <select id="findAccountByAccountNumber" resultType="com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela">
+        select
+        account.id as "accountId",
+        account.accountnumber as "accountnumber",
+        account.name as "accountname",
+        customer.invoicetitle as "invoicetitle",
+        account.telephone as "telephone",
+        account.address as "address",
+        customer.vatno as "vatno",
+        customer.bankaccount as "bankaccount"
+        from pay_base_customerandmeterrela customer
+        left join pay_base_account account on customer.account_id = account.id
+        <where>
+            <if test="siteId != null">
+                and customer.site_id = #{siteId}
+            </if>
+            <if test="customerId != null">
+                and  customer.customer_id = #{customerId}
+            </if>
+            <if test="accountnumber != null">
+                and  customer.accountnumber = #{accountnumber}
+            </if>
+        </where>
+        limit 1
+    </select>
 </mapper>

+ 12 - 4
smart-city-platform/src/main/resources/mapper/pay/PayChargeSurveyMapper.xml

@@ -3,7 +3,15 @@
 <mapper namespace="com.bz.smart_city.dao.pay.PayChargeSurveyMapper">
 
     <select id="getAccountCount" resultType="java.lang.Integer">
-        select count(a.id) from pay_account_survey a
+        select count(a.id) as number from pay_account_survey a
+        <where>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
     </select>
 
     <select id="getlastNumber" resultType="com.bz.smart_city.entity.pay.PayAccountSurvey">
@@ -169,9 +177,9 @@
 
     <select id="getlastAccount" resultType="com.bz.smart_city.entity.pay.PayAccountSurvey">
         select
-            IFNULL(sum(a.account_number),0) as "accountNumber",
-            IFNULL(sum(a.meter_number),0) as "meterNumber",
-            IFNULL(sum(a.customer_number),0) as "customerNumber"
+            IFNULL(a.account_number,0) as "accountNumber",
+            IFNULL(a.meter_number,0) as "meterNumber",
+            IFNULL(a.customer_number,0) as "customerNumber"
         from pay_account_survey a
         <where>
             <if test="periodDate != null">

+ 3 - 1
smart-city-platform/src/main/resources/mapper/pay/PayInvoiceMapper.xml

@@ -178,6 +178,7 @@
             ,account.accountnumber
             ,account.address
             ,u.name AS "createBy"
+            ,(select  customer_name from sc_customer where id=#{customerId}) as "customerName"
         from pay_pay_transactiondetails a
         left join pay_base_account account on account.id=a.account_id
         left join sc_user u on u.id=a.create_by
@@ -204,7 +205,8 @@
             max(amount.reading) as "reading",
             min(amount.lastreading) as "lastreading",
             max(reced.create_date) as "createDate",
-            (select name from sc_user where id=max(reced.create_by)) as "createBy"
+            (select name from sc_user where id=max(reced.create_by)) as "createBy",
+            (select  customer_name from sc_customer where id=#{customerId}) as "customerName"
         from pay_pay_received reced
         left join pay_pay_receivable rece on reced.receivable_id=rece.id
         left join pay_amount_waterusedamount amount on amount.id=rece.usedamount_id

+ 6 - 9
smart-city-platform/src/main/resources/mapper/pay/PayPayReceivedMapper.xml

@@ -22,13 +22,9 @@
             when rece.ladderlevel = 3 then '三阶'
             when rece.ladderlevel = 4 then '四阶'
             else '' end as "ladderlevelname",
-            rece.payseriesno as "payseriesno",
             rece.receivedamount as "receivedamount",
-            (select label from pay_sys_dict where type = '支付方式' and value = rece.payway and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
             rece.create_date as "transtime",
-            (select label from pay_sys_dict where type = '交易状态' and value = rece.state and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
             rece.state as "state",
-            users.name as "createbyname",
             (select name from sc_user where id = rece.cancelperson) as "cancelperson",
             rece.canceltime as "canceltime",
             rece.year as "year",
@@ -87,6 +83,8 @@
             max(users.name) as "createbyname",
             max(rece.create_date) as "transtime",
             max(rece.invoice_id) as "invoiceId",
+            max(canceltime) as "canceltime",
+            (select name from sc_user where id= max(rece.cancelperson)) as "cancelperson",
             rece.year as "year",
             rece.month as "month"
         from pay_pay_received rece
@@ -328,20 +326,19 @@
             rece.payseriesno as "payseriesno",
             rece.create_date as "createDate",
             rece.ladderlevel as "ladderlevel",
-            rece.payway as "payway",
-            dict2.label as "paywayname",
             sum(rece.receivedamount) as "receivedamount",
             rece.price as "price",
             rece.feetype as "feetype" ,
             dict.label as "feetypename"
         from pay_pay_received rece
         inner join pay_sys_dict dict on dict.type="收费类型" and dict.`value`= rece.feetype
-        inner join pay_sys_dict dict2 on dict2.type="支付方式" and dict2.`value`= rece.payway
+               and dict.site_id = #{siteId}
+               and dict.customer_id = #{customerId}
         where rece.canceledrecord_id is null and rece.iscanceled =0 and rece.receivedamount>0
-              #and rece.payseriesno= #{payseriesno}
+              and rece.payseriesno= #{payseriesno}
               and rece.site_id = #{siteId}
               and rece.customer_id = #{customerId}
-        group by rece.payseriesno,rece.create_date,rece.ladderlevel,rece.payway,dict2.label,rece.price,rece.feetype,dict.label
+        group by rece.payseriesno,rece.create_date,rece.ladderlevel,rece.price,rece.feetype,dict.label
 
     </select>
 </mapper>

+ 5 - 4
smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

@@ -222,12 +222,11 @@
                     when ladderlevel = 3 then '三阶'
                     when ladderlevel = 4 then '四阶'
                     else '' end) as "ladderlevelname",
-         payseriesno as "payseriesno",
+
          receivedamount,
-         reced.state as "state",
+
          reced.payway as "payway",
          (select label from pay_sys_dict where type = '支付方式' and value = reced.payway and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
-         (select label from pay_sys_dict where type = '交易状态' and value = reced.state and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
          create_date as "createDate",
          iscanceled,
           (select name from sc_user where id = reced.cancelperson) as "cancelperson",
@@ -257,8 +256,10 @@
             (select label from pay_sys_dict where type = '交易状态' and value =  max(reced.state) and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
             max(invoice_id) as "invoiceId",
             max(iscanceled) as "iscanceled",
+            (select name from sc_user where id= max(reced.cancelperson)) as "cancelperson",
             max(canceltime) as "canceltime",
-            max(create_date) as "createDate"
+            max(create_date) as "createDate",
+            max(canceledrecord_id) as "canceledrecordId"
         from pay_pay_received reced
         where
          account_id=#{accountId}