Просмотр исходного кода

Merge commit '6c7363d21d6f8015ea621067fdde390ebbfdaa8f' into release

release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
a378a28b0f
12 измененных файлов: 92 добавлений и 101 удалений
  1. +1
    -0
      mallinkAdmin/src/main/resources/db/migration/V201906211335__L_ADD_MENU_DATA.sql
  2. +12
    -0
      mallinkAdmin/src/main/resources/db/migration/V201906211405__CHANGE_PAY_RATE.sql
  3. +0
    -37
      mallinkCallback/src/main/java/com/iformall/utils/PayUtil.java
  4. +1
    -1
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  5. +5
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java
  6. +5
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  7. +5
    -16
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java
  8. +8
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java
  9. +2
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  10. +3
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxSubsidyServiceImpl.java
  11. +50
    -0
      mallinkService/src/main/java/com/iformall/utils/PayUtils.java
  12. +0
    -37
      mallinkSysAdmin/src/main/java/com/iformall/utils/PayUtil.java

+ 1
- 0
mallinkAdmin/src/main/resources/db/migration/V201906211335__L_ADD_MENU_DATA.sql Просмотреть файл

@@ -0,0 +1 @@
update mall_permission set icon = 'icon-zhangdan' where name ='商铺租赁合同';

+ 12
- 0
mallinkAdmin/src/main/resources/db/migration/V201906211405__CHANGE_PAY_RATE.sql Просмотреть файл

@@ -0,0 +1,12 @@
ALTER TABLE `wx_pay_order`
ADD COLUMN `rate_amount` int(11) NULL DEFAULT NULL COMMENT '分账通道费差';

ALTER TABLE `wx_pay_account`
ADD COLUMN `real_rate` int(6) NULL DEFAULT NULL COMMENT '支付实际费率(万分之几)' after `rate`;

update `wx_pay_account` set `real_rate` = `rate`;

ALTER TABLE `wx_pay_account_bill`
ADD COLUMN `real_rate` int(6) NULL DEFAULT NULL COMMENT '支付实际费率(万分之几)' after `rate`;

update `wx_pay_account_bill` set `real_rate` = `rate`;

+ 0
- 37
mallinkCallback/src/main/java/com/iformall/utils/PayUtil.java Просмотреть файл

@@ -1,37 +0,0 @@
package com.iformall.utils;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import java.awt.image.BufferedImage;
import java.util.Hashtable;
import java.util.Map;

public class PayUtil {
/**
* 根据url生成二位图片对象
*
* @param codeUrl
* @return
* @throws WriterException
*/
public static BufferedImage getQRCodeImge(String codeUrl) throws WriterException {
Map<EncodeHintType, Object> hints = new Hashtable();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
int width = 256;
BitMatrix bitMatrix = (new MultiFormatWriter()).encode(codeUrl, BarcodeFormat.QR_CODE, width, width, hints);
BufferedImage image = new BufferedImage(width, width, 1);
for(int x = 0; x < width; ++x) {
for(int y = 0; y < width; ++y) {
image.setRGB(x, y, bitMatrix.get(x, y) ? -16777216 : -1);
}
}

return image;
}
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/common/ErrorCode.java Просмотреть файл

@@ -12,7 +12,7 @@ public enum ErrorCode{
* 系统级别
* 1000-1999
*/
SYS_SERVER_ERROR(1000, "服务器请求异常"),
SYS_SERVER_ERROR(1000, "系统异常"),
SYS_PARAMETER_ERROR(1001, "参数不合法"),
SYS_PARAMETER_NOT_NULL(1002, "参数不能为空"),
SYS_PARAMETER_TYPE_ERROR(1003, "参数类型异常"),


+ 5
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java Просмотреть файл

@@ -13,6 +13,7 @@ import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.*;
import com.iformall.utils.PayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -123,8 +124,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
// 4. 扣减计算
Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount();
Integer payment = paymentD.intValue();
Double dChargeFee = Math.ceil(payment * 1.0D * payAccount.getRate() / 10000);
Integer real_payment = payment - dChargeFee.intValue();
int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate());
Integer real_payment = payment - iChargeFee;
Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment;

Integer remaingAmount = cardInfo.getRemainingAmount()-record.getDeductionAmount();
@@ -189,8 +190,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
logger.info("补贴额: " + subsidyFee);
if(subsidyFee > 0) {
// 有补贴时入库
Double dSubChargeFee = Math.ceil(subsidyFee * 1.0D * payAccount.getRate() / 10000);
Integer realSubsidyFee = subsidyFee - dSubChargeFee.intValue();
int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate());
Integer realSubsidyFee = subsidyFee - iSubChargeFee;
WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy();
merchantSubsidy.setId(idWorker.nextId());
merchantSubsidy.setTenantId(record.getTenantId());


+ 5
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -21,6 +21,7 @@ import com.iformall.mapper.*;
import com.iformall.mq.MqBaseProducer;
import com.iformall.service.*;
import com.iformall.utils.DateUtils;
import com.iformall.utils.PayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -480,11 +481,11 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}
if (subsidyNum != null && subsidyNum.intValue() > 0) {
// 有补贴时入库
Double dSubChargeFee = Math.ceil(subsidyNum * 1.0D * payAccount.getRate() / 10000);
Integer realSubsidyFee = subsidyNum - dSubChargeFee.intValue();
int iSubChargeFee = PayUtils.getPayRate(subsidyNum, payAccount.getRate());
Integer realSubsidyFee = subsidyNum - iSubChargeFee;

Double priceChargeFee = Math.ceil(coupon.getSalePrice() * 1.0D * payAccount.getRate() / 10000);
Integer realPayment = coupon.getSalePrice() - priceChargeFee.intValue();
int iPriceChargeFee = PayUtils.getPayRate(coupon.getSalePrice(), payAccount.getRate());
Integer realPayment = coupon.getSalePrice() - iPriceChargeFee;

WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy();
merchantSubsidy.setId(idWorker.nextId());


+ 5
- 16
mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java Просмотреть файл

@@ -14,10 +14,7 @@ import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.pay.*;
import com.iformall.service.*;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.MapUtil;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;
import com.iformall.utils.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -219,8 +216,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
record.setShare(isShare.getCode());
if (isShare == EnumPayShare.YES) {
// 分账金额
Double dChargeFee = Math.ceil(record.getPayAmount() * 1.0D * payAccount.getRate() / 10000);
Integer share_amount = record.getPayAmount() - dChargeFee.intValue();
int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate());
Integer share_amount = record.getPayAmount() - iChargeFee;
record.setShareAmount(share_amount);
}

@@ -458,8 +455,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
record.setShare(isShare.getCode());
if (isShare == EnumPayShare.YES) {
// 分账金额
Double dChargeFee = Math.ceil(record.getPayAmount() * 1.0D * payAccount.getRate() / 10000);
Integer share_amount = record.getPayAmount() - dChargeFee.intValue();
int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate());
Integer share_amount = record.getPayAmount() - iChargeFee;
record.setShareAmount(share_amount);
if (share_amount <= 0) {
isShare = EnumPayShare.NO;
@@ -1532,12 +1529,4 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
public void deleteById(Long id) {
wxPayOrderMapper.deleteByPrimaryKey(id);
}

public static void main(String[] args) {
Integer v = 50;
Integer rate = 6;
Double dChargeFee = Math.ceil(v * 1.0D * 60 / 10000);
Integer share_amount = v - dChargeFee.intValue();
System.out.println("share value " + share_amount);
}
}

+ 8
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java Просмотреть файл

@@ -270,6 +270,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
String message;
boolean hasFlow = true;
if (record.getId() == null) {
if (record.getOperationType().equals(EnumContractOperationType.WHOLE.getCode())) {
WxPropertyContract propertyContractQuery = new WxPropertyContract();
propertyContractQuery.setRentContractId(record.getRentContractId());
int propertyContractCount = wxPropertyContractMapper.selectCount(propertyContractQuery);
if (propertyContractCount > 0) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR);
}
}
hasFlow = false;
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());


+ 2
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java Просмотреть файл

@@ -1375,6 +1375,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxPropertyContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode());
WxPropertyContract propertyContract = wxPropertyContractMapper.selectOne(wxPropertyContract);
if (propertyContract != null) {
propertyContract.setMerchantId(record.getMerchantId());
wxPropertyContractMapper.updateByPrimaryKeySelective(propertyContract);
wxPropertyContractService.updatePropertyContractStatus(propertyContract.getId());
}
}


+ 3
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxSubsidyServiceImpl.java Просмотреть файл

@@ -21,6 +21,7 @@ import com.iformall.pay.WxPayment;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxSubsidyService;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.PayUtils;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;
import org.apache.commons.lang3.StringUtils;
@@ -113,8 +114,8 @@ public class WxSubsidyServiceImpl implements WxSubsidyService {
record.setPayTimeEnd(curDate);
record.setAmount(totalFee);
// 分账金额
Double dChargeFee = Math.ceil(record.getAmount() * 1.0D * payAccount.getRate() / 10000);
Integer share_amount = record.getAmount() - dChargeFee.intValue();
int iChargeFee = PayUtils.getPayRate(record.getAmount(), payAccount.getRate());
Integer share_amount = record.getAmount() - iChargeFee;
record.setShareAmount(share_amount);
record.setShareRemainAmount(share_amount);
try {


+ 50
- 0
mallinkService/src/main/java/com/iformall/utils/PayUtils.java Просмотреть файл

@@ -0,0 +1,50 @@
package com.iformall.utils;

/**
* 分账手续费
*
* @author stormeye.wu
* @email wuguoqiang@iformall.com
* @date 2019年1月5月
*/
public class PayUtils {

/**
* getPayRate
* @param payAmount 支付总钱数(分)
* @param rate 万分之几
* @return
*/
public static int getPayRate(int payAmount, int rate) {
Double dBaseAmount = 5.0D * 1000 / rate;
// 基础分 千分之6 83分
if(payAmount > dBaseAmount.intValue()) {
// 大于基础分,不小于他的最小整数
Double dChargeFee = Math.ceil(payAmount * 1.0D * rate / 10000);
return dChargeFee.intValue();
} else {
// 小于基础分,四舍五入
Double dPayRate = 1.0D * payAmount * rate / 10000;
long dChargeFee = Math.round(dPayRate);
return Long.valueOf(dChargeFee).intValue();
}
}

public static void main(String[] args) {
int iValue = getPayRate(100, 60);
System.out.println(iValue);

iValue = getPayRate(200, 60);
System.out.println(iValue);

iValue = getPayRate(82, 60);
System.out.println(iValue);

iValue = getPayRate(83, 60);
System.out.println(iValue);

iValue = getPayRate(84, 60);
System.out.println(iValue);
}

}

+ 0
- 37
mallinkSysAdmin/src/main/java/com/iformall/utils/PayUtil.java Просмотреть файл

@@ -1,37 +0,0 @@
package com.iformall.utils;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import java.awt.image.BufferedImage;
import java.util.Hashtable;
import java.util.Map;

public class PayUtil {
/**
* 根据url生成二位图片对象
*
* @param codeUrl
* @return
* @throws WriterException
*/
public static BufferedImage getQRCodeImge(String codeUrl) throws WriterException {
Map<EncodeHintType, Object> hints = new Hashtable();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
int width = 256;
BitMatrix bitMatrix = (new MultiFormatWriter()).encode(codeUrl, BarcodeFormat.QR_CODE, width, width, hints);
BufferedImage image = new BufferedImage(width, width, 1);
for(int x = 0; x < width; ++x) {
for(int y = 0; y < width; ++y) {
image.setRGB(x, y, bitMatrix.get(x, y) ? -16777216 : -1);
}
}

return image;
}
}

Загрузка…
Отмена
Сохранить