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

[审批流][修改][完善账单审批]

release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
3e7326a620
9 измененных файлов: 216 добавлений и 39 удалений
  1. +12
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java
  2. +3
    -2
      mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java
  3. +10
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxShop.java
  4. +78
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxNotRentShopVo.java
  5. +8
    -0
      mallinkService/src/main/java/com/iformall/service/WxShopService.java
  6. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxChartServiceImpl.java
  7. +85
    -27
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  8. +16
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java
  9. +3
    -3
      mallinkService/src/main/resources/mapper/WxShopMapper.xml

+ 12
- 2
mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java Просмотреть файл

@@ -144,7 +144,17 @@ public class WxShopController extends BaseController {
wxShopService.exportShop(wxShop, request, response);
}



@ApiOperation("导出未出租店铺")
@GetMapping("/exportNotRentShop")
@SystemControllerLog(description = "商铺出租数据-未出租商铺列表-导出")
public void exportNotRentShop(@ModelAttribute WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {
logger.debug("[" + getIpAddr() + "] WxShopController::exportNotRentShop");
if (null == wxShop){
wxShop = new WxShop();
}
wxShop.setTenantId(getTenantId());
wxShop.setSortColumns(WxShop.Field.Id_DESC);
wxShopService.exportNotRentShop(wxShop, request, response);
}

}

+ 3
- 2
mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java Просмотреть файл

@@ -62,8 +62,9 @@ public class MqBaseConsumer {
baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode());
wxMsgRecordMapper.update(baseMsg);
}catch (Exception e){
log.error("consum received error: {}", e);
baseMsg.setStatusMessage(e.getMessage());
log.error("consum received error: ", e.getMessage());
log.error("consum received error: ", e);
//baseMsg.setStatusMessage(e.getMessage());
baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode());
wxMsgRecordMapper.update(baseMsg);
// if(null != baseMsg){


+ 10
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxShop.java Просмотреть файл

@@ -132,6 +132,16 @@ public class WxShop implements Serializable {
//结束时间
@Transient
private Date enddate;
@Transient
private Integer freeDay;

public Integer getFreeDay() {
return freeDay;
}

public void setFreeDay(Integer freeDay) {
this.freeDay = freeDay;
}

public Integer getIsDel() {
return isDel;


+ 78
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxNotRentShopVo.java Просмотреть файл

@@ -0,0 +1,78 @@
package com.iformall.domain.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;

public class WxNotRentShopVo {

@Excel(name="商铺类型",width = 20,orderNum = "1",
replace = {"商铺_null", "固定点位_1", "临时促销点位_2", "宣传点位_3","ATM点位_4","仓库点位_5","其他点位_6"})
private Integer pointType;
@Excel(name="商铺号",width = 20,orderNum = "2")
private String shopNumber;
@Excel(name="楼座",width = 20,orderNum = "3")
private Long building;
@Excel(name="楼层",width = 20,orderNum = "4")
private Long floor;
@Excel(name="建筑面积(㎡)",width = 20,orderNum = "5")
private String buildArea;
@Excel(name="计租面积(㎡)",width = 20,orderNum = "6")
private String operationArea;
@Excel(name="闲置时间(天)",width = 20,orderNum = "7")
private Integer freeDay;

public Integer getPointType() {
return pointType;
}

public void setPointType(Integer pointType) {
this.pointType = pointType;
}

public String getShopNumber() {
return shopNumber;
}

public void setShopNumber(String shopNumber) {
this.shopNumber = shopNumber;
}

public Long getBuilding() {
return building;
}

public void setBuilding(Long building) {
this.building = building;
}

public Long getFloor() {
return floor;
}

public void setFloor(Long floor) {
this.floor = floor;
}

public String getBuildArea() {
return buildArea;
}

public void setBuildArea(String buildArea) {
this.buildArea = buildArea;
}

public String getOperationArea() {
return operationArea;
}

public void setOperationArea(String operationArea) {
this.operationArea = operationArea;
}

public Integer getFreeDay() {
return freeDay;
}

public void setFreeDay(Integer freeDay) {
this.freeDay = freeDay;
}
}

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

@@ -60,4 +60,12 @@ public interface WxShopService {
* @param response
*/
void exportShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response);

/**
* 导出未出租商铺数据
* @param wxShop
* @param request
* @param response
*/
void exportNotRentShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response);
}

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

@@ -2203,7 +2203,7 @@ public class WxChartServiceImpl implements WxChartDataService {
*/
private ResultData getIndexShopRentData(String tenantId, String startDateStr) {
HashMap<String, Object> datamap = new HashMap<>();
Date startDate = DateUtils.getDateFromString(startDateStr,"yyyy-MM-dd").getTime();
Date startDate = DateUtils.getDateFromString(startDateStr+"-01","yyyy-MM-dd").getTime();
Date endDate = DateUtils.getLastDayForMonth(startDate);
WxShop query = new WxShop();
query.setTenantId(tenantId);


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

@@ -670,7 +670,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview);
} else {
//按日计租
Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null);
Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false);
rentList = ( List<WxBillRent>)resultMap.get("billList");
}
}
@@ -771,10 +771,22 @@ public class WxRentContractServiceImpl implements WxRentContractService {
List<WxBillRent> resultList = new ArrayList<>();
for (int i = 0; i < size; i++) {
Calendar instance = Calendar.getInstance();
instance.setTime(rentalStartDate);
//开始时间
instance.add(Calendar.MONTH, month * i);
Map<String, Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArrs[i], instance.getTime(), Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount, isPreview, shopInfos.isEmpty() ? null : shopInfos.get(i));
Date startDate;
//自然月
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
if(i == 0){ //第一期
startDate = rentalStartDate;
}else{
instance.setTime(rentalStartDate);
instance.add(Calendar.MONTH, month * i);
startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime());
}
}else{
instance.setTime(rentalStartDate);
instance.add(Calendar.MONTH, month * i);
startDate = instance.getTime();
}
Map<String, Object> resultMap = buildRent(leaseArr[i], receivePeriod, priceArrs[i], startDate, Calendar.MONTH, wxRentContract, userId, wxMerchant, billcount, isPreview, shopInfos.isEmpty() ? null : shopInfos.get(i),i==size-1?true:false);
List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList");
billcount = (Integer)resultMap.get("billcount");
resultList.addAll(billRentList);
@@ -790,7 +802,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return false;
}

public Map<String, Object> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map<String, Object> shopInfo) {
public Map<String, Object> buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxRentContract wxRentContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map<String, Object> shopInfo,boolean isLastYesr) {
System.out.println("------lease:"+lease+"receivePeriod:"+receivePeriod+"price:"+price+"start:"+DateUtils.date2String(startdate,"yyyy-MM-dd")
+"dayType:"+dayType+"billcount:"+billcount);

String shopInfoStr = null;
if (shopInfo != null) {
shopInfoStr = JSONObject.toJSONString(shopInfo);
@@ -802,34 +817,39 @@ public class WxRentContractServiceImpl implements WxRentContractService {
int paycount = lease / receivePeriod + extracount;
int index = paycount - 1;
final IdWorker idWorker = IdWorker.get();
//自然月 n+1
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())
&& !isFirstDay(wxRentContract.getRentalStartDate())
){
paycount ++;
}
for (int i = 0; i < paycount; i++) {
//自然月,而且残月,而且整除,最后一个月单独一个周期
// if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())
// && !isFirstDay(wxRentContract.getRentalStartDate()) && isLastYesr
// && (wxRentContract.getLease()/wxRentContract.getReceivePeriod() == 0)
// ){
// paycount ++;
// }
for(int i = 0; i < paycount; i++){
WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setIsPreview(isPreview);

wxBillRent.setId(idWorker.nextId());
wxBillRent.setRentContractId(wxRentContract.getId());
wxBillRent.setPay(0);
System.out.println("-----------price:"+price+",receivePeriod:"+receivePeriod);
//System.out.println("-----------price:"+price+",receivePeriod:"+receivePeriod);
int needpay = price * receivePeriod;
System.out.println("--------needpay:"+needpay);
//System.out.println("--------needpay:"+needpay);

Calendar instance = Calendar.getInstance();
Date date = new Date();
instance.setTime(startdate);
instance.add(dayType, receivePeriod * i);
instance.add(Calendar.DAY_OF_MONTH, -1);
if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
instance.add(Calendar.DAY_OF_MONTH, -1);
}
Date time = instance.getTime();
wxBillRent.setReceiveDate(time);
//账单开始时间
instance.clear();
instance.setTime(wxBillRent.getReceiveDate());
instance.add(Calendar.DAY_OF_MONTH, 1);
if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
instance.add(Calendar.DAY_OF_MONTH, 1);
}
wxBillRent.setStarttime(instance.getTime());
//账单结束时间
instance.clear();
@@ -843,7 +863,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//账单开始时间
instance.clear();
instance.setTime(wxBillRent.getReceiveDate());
instance.add(Calendar.DAY_OF_MONTH, 1);
if(!wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
instance.add(Calendar.DAY_OF_MONTH, 1);
}
wxBillRent.setStarttime(instance.getTime());
//账单结束时间
instance.clear();
@@ -857,25 +879,28 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//自然月,开始日期、缴款日,结束日期
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
if(i == 0){//第一周期
wxBillRent.setReceiveDate(wxRentContract.getRentalStartDate());
wxBillRent.setStarttime(wxRentContract.getRentalStartDate());
double oneDayProce = (double) price / DateUtils.getMonthDayCount(wxRentContract.getRentalStartDate());
int startDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxRentContract.getRentalStartDate()));
double oneDayProce = (double) price / DateUtils.getMonthDayCount(wxBillRent.getStarttime());
int startDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxBillRent.getStarttime()));
double needPayDouble;

if(receivePeriod <= 1) {//周期为一个月
wxBillRent.setEndtime(DateUtils.getLastDayForMonth(wxRentContract.getRentalStartDate()));
needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxRentContract.getRentalStartDate())-startDateInt+1);
wxBillRent.setEndtime(DateUtils.getLastDayForMonth(wxBillRent.getStarttime()));
needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxBillRent.getStarttime())-startDateInt+1);
}else{ //周期大于一个月
wxBillRent.setEndtime(DateUtils.getLastDayForMonth(wxRentContract.getRentalStartDate(),receivePeriod - 1));
Date firstDay = DateUtils.getFirstDayForCurrMonth(wxBillRent.getStarttime());
instance.clear();
instance.setTime(firstDay);
instance.add(dayType, extralease);
instance.add(Calendar.DAY_OF_MONTH, -1);
wxBillRent.setEndtime(instance.getTime());
// [A/31 *(31-12+1)]+A+A
needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxRentContract.getRentalStartDate())-startDateInt+1);
needPayDouble = oneDayProce * (DateUtils.getMonthDayCount(wxBillRent.getStarttime())-startDateInt+1);
needPayDouble += price * (receivePeriod - 1);
}
DecimalFormat format = new DecimalFormat("0");
needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入
}else if(i < paycount - 1){//中间周期
Date receiveDate = DateUtils.getFirstDayOfNextMonth(wxRentContract.getRentalStartDate(),receivePeriod * i);
Date receiveDate = DateUtils.getFirstDayOfNextMonth(startdate,receivePeriod * i);
wxBillRent.setReceiveDate(receiveDate);
wxBillRent.setStarttime(receiveDate);
wxBillRent.setEndtime(DateUtils.getLastDayForMonth(receiveDate,receivePeriod * i));
@@ -904,6 +929,39 @@ public class WxRentContractServiceImpl implements WxRentContractService {
needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入
}
}
//最后一个周期
if (isLastYesr) {
if(wxRentContract.getLease()/wxRentContract.getReceivePeriod() == 0){
wxBillRent.setStarttime(startdate);

int endDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxRentContract.getRentalEndDate()));
String endDateStr = DateUtils.date2String(startdate,"yyyy-MM")+ "-" +(endDateInt - 1);
wxBillRent.setEndtime(DateUtils.stringToDate(endDateStr,"yyyy-MM-dd"));

double needPayDouble;
double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxBillRent.getEndtime());
needPayDouble = oneDayProce * endDateInt;
DecimalFormat format = new DecimalFormat("0");
needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入
}else{
wxBillRent.setStarttime(startdate);
int endDateInt = Integer.parseInt(new SimpleDateFormat("d").format(wxRentContract.getRentalEndDate()));

instance.clear();
instance.setTime(DateUtils.getLastDayOfNextMonth(startdate,lease));
instance.add(dayType, receivePeriod);
instance.add(Calendar.DAY_OF_MONTH, endDateInt-1);
wxBillRent.setEndtime(instance.getTime());

double needPayDouble;
double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxBillRent.getEndtime());
needPayDouble = oneDayProce * endDateInt;
DecimalFormat format = new DecimalFormat("0");
needpay = Integer.parseInt(format.format(needPayDouble)); //分做四舍五入
}

}


wxBillRent.setNeedPay(needpay);
wxBillRent.setOwe(needpay);


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

@@ -8,6 +8,7 @@ import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMerchantShop;
import com.iformall.domain.po.WxShop;
import com.iformall.domain.vo.WxNotRentShopVo;
import com.iformall.domain.vo.WxShopVo;
import com.iformall.enums.EnumDelStatus;
import com.iformall.enums.EnumRentShopType;
@@ -19,15 +20,13 @@ import com.iformall.service.ExcelService;
import com.iformall.service.WxShopService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

@Service
public class WxShopServiceImpl implements WxShopService {
@@ -156,4 +155,17 @@ public class WxShopServiceImpl implements WxShopService {
String name = EnumRentShopType.SHOP.getCode().equals(wxShop.getType())?"店铺列表":"多经点位列表";
excelService.exportExcel(list,null, name, WxShopVo.class,name+".xls",response);
}

@Override
public void exportNotRentShop(WxShop wxShop, HttpServletRequest request, HttpServletResponse response) {
List<WxShop> list = wxShopMapper.findList(wxShop);
List<WxNotRentShopVo> notRentShopVoList = new ArrayList<>();
for (WxShop ws:list) {
WxNotRentShopVo notRentShopVo = new WxNotRentShopVo();
BeanUtils.copyProperties(ws, notRentShopVo);
notRentShopVoList.add(notRentShopVo);
}
String name = "未出租商铺列表";
excelService.exportExcel(notRentShopVoList,null, name, WxNotRentShopVo.class,name+".xls",response);
}
}

+ 3
- 3
mallinkService/src/main/resources/mapper/WxShopMapper.xml Просмотреть файл

@@ -25,13 +25,14 @@
<result column="point_type" jdbcType="INTEGER" property="pointType"/>
<result column="comments" jdbcType="VARCHAR" property="comments"/>
<result column="is_del" jdbcType="INTEGER" property="isDel"/>
<result column="freeDay" property="freeDay"/>

</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`,
`floor`,`status`,`x`,`y`,`addr`,`baidu_poi`,`longitude`,`latitude`,`create_date`,
`update_date`,`img_url`,`manager`,`manager_phone`,`type`,`point_type`,`comments`,`is_del`
`update_date`,`img_url`,`manager`,`manager_phone`,`type`,`point_type`,`comments`,`is_del`,DATEDIFF(now(),create_date) freeDay
</sql>

<sql id="dynamicWhereConditions">
@@ -147,14 +148,13 @@
<include refid="dynamicWhereConditions"/>
</select>


<select id="findListMap" parameterType="com.iformall.domain.po.WxShop" resultType="hashmap">

select s.id,s.shop_number shopNumber,s.build_area buildArea,
s.img_url imgUrl,s.operation_area operationArea,
s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId,
m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone,
s.type,s.point_type pointType,s.addr
s.type,s.point_type pointType,s.addr,DATEDIFF(now(),s.create_date) freeDay
from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0
left join wx_merchant m on ms.merchant_id=m.id
left join wx_mall_building b on s.building=b.id


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