Преглед изворни кода

[账单管理][添加][业务逻辑]

release_toaliyun_real
gongbiao пре 7 година
родитељ
комит
ccb12066e8
5 измењених фајлова са 112 додато и 64 уклоњено
  1. +8
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/WxBillRentController.java
  2. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java
  3. +6
    -7
      mallinkService/src/main/java/com/iformall/service/WxBillRentService.java
  4. +36
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java
  5. +60
    -52
      mallinkService/src/main/resources/mapper/WxBillRentMapper.xml

+ 8
- 1
mallinkAdmin/src/main/java/com/iformall/controller/WxBillRentController.java Прегледај датотеку

@@ -30,7 +30,9 @@ public class WxBillRentController extends BaseController {
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
public ResultData list(@ModelAttribute WxBillRent wxBillRent, Integer pageNum, Integer pageSize) {
if (null == wxBillRent) wxBillRent = new WxBillRent();
if (null == wxBillRent) {
wxBillRent = new WxBillRent();
}
wxBillRent.setTenantId(getTenantId());
wxBillRent.setSortColumns(WxBillRent.Field.Id_DESC);
final PageInfo<Map<String, Object>> page = wxBillRentService.listAsPage(wxBillRent, pageNum, pageSize);
@@ -61,5 +63,10 @@ public class WxBillRentController extends BaseController {
return new ResultData(Result.SUCCESS, "查询成功", wxBillRentService.getById(id));
}

@GetMapping("/findByMerchantId")
@ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true)
public ResultData findByMerchantId(Long id) {
return new ResultData(Result.SUCCESS, "查询成功", wxBillRentService.findByMerchantId(id));
}

}

+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java Прегледај датотеку

@@ -17,4 +17,6 @@ public interface WxBillRentMapper extends CommonMapper<WxBillRent, String> {

Map<String,Object> queryPayInfo(Map<String,Object> params);

void updateNotPaidStatus(Map<String,Object> params);

}

+ 6
- 7
mallinkService/src/main/java/com/iformall/service/WxBillRentService.java Прегледај датотеку

@@ -5,6 +5,9 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBillRent;

/**
* @author gongbiao
*/
public interface WxBillRentService {

/**
@@ -38,12 +41,8 @@ public interface WxBillRentService {
* @param id
*/
void deleteById(Long id);


Object findByMerchantId(Long id);

}

+ 36
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java Прегледај датотеку

@@ -7,6 +7,8 @@ import com.iformall.common.IdWorker;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxBillRent;
import com.iformall.enums.EnumBillRentPayWay;
import com.iformall.enums.EnumBillRentStatus;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxBillRentMapper;
import com.iformall.service.WxBillRentService;
@@ -14,8 +16,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@@ -32,13 +36,29 @@ public class WxBillRentServiceImpl implements WxBillRentService {

@Override
public PageInfo<Map<String, Object>> listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) {
//更新逾期天数及状态
updateNotPaidStatus(record);
PageHelper.startPage(pageIndex, pageSize);
List<Map<String, Object>> shops = wxBillRentMapper.queryBillRentList(record);
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(shops);
List<Map<String, Object>> billRentList = wxBillRentMapper.queryBillRentList(record);
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(billRentList);
return pageInfo;
//return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBillRentMapper.findList(record));
}

@Transactional(rollbackFor = {Exception.class})
public void updateNotPaidStatus(WxBillRent record) {
Map<String,Object> params=new HashMap<>();
params.put("tenantId",record.getTenantId());
params.put("notPaid",EnumBillRentStatus.NOT_PAID);
params.put("paid",EnumBillRentStatus.PAID);
try{
wxBillRentMapper.updateNotPaidStatus(params);
} catch (Exception e) {
logger.error("更新租赁账单失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}
}

@Override
public Map<String, Object> getById(Long id) {
WxBillRent record = new WxBillRent();
@@ -64,9 +84,14 @@ public class WxBillRentServiceImpl implements WxBillRentService {
return new ResultData(Result.SUCCESS, "保存租赁账单成功");
} else {
logger.info("更新租赁账单");
record.setUpdatetime(new Date());
WxBillRent wxBillRent = wxBillRentMapper.selectByPrimaryKey(record.getId());
wxBillRent.setPayDate(record.getPayDate());
wxBillRent.setPay(record.getPay());
wxBillRent.setReceivePay(record.getReceivePay());
wxBillRent.setStatus(record.getStatus());
wxBillRent.setUpdatetime(new Date());
try {
wxBillRentMapper.updateByPrimaryKeySelective(record);
wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent);
} catch (Exception e) {
logger.error("更新租赁账单失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
@@ -80,5 +105,12 @@ public class WxBillRentServiceImpl implements WxBillRentService {
wxBillRentMapper.deleteByPrimaryKey(id);
}

@Override
public Object findByMerchantId(Long id) {
WxBillRent record = new WxBillRent();
record.setMerchantId(id);
return wxBillRentMapper.queryBillRentList(record);
}


}

+ 60
- 52
mallinkService/src/main/resources/mapper/WxBillRentMapper.xml Прегледај датотеку

@@ -2,80 +2,83 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.WxBillRentMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillRent">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId" />
<result column="receive_pay" jdbcType="INTEGER" property="receivePay" />
<result column="pay" jdbcType="INTEGER" property="pay" />
<result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
<result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
<result column="expired_day" jdbcType="INTEGER" property="expiredDay" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="owe" jdbcType="BIGINT" property="owe" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="is_del" jdbcType="INTEGER" property="isDel" />
<result column="need_pay" jdbcType="INTEGER" property="needPay" />
<result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="shop_id" jdbcType="BIGINT" property="shopId" />
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
<result column="receive_pay" jdbcType="INTEGER" property="receivePay"/>
<result column="pay" jdbcType="INTEGER" property="pay"/>
<result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate"/>
<result column="pay_date" jdbcType="TIMESTAMP" property="payDate"/>
<result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
<result column="expired_day" jdbcType="INTEGER" property="expiredDay"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="owe" jdbcType="BIGINT" property="owe"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="is_del" jdbcType="INTEGER" property="isDel"/>
<result column="need_pay" jdbcType="INTEGER" property="needPay"/>
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="shop_id" jdbcType="BIGINT" property="shopId"/>
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
</resultMap>
<sql id="allColumns">
`id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`need_pay`,`merchant_id`,`user_id`,`shop_id`,`updatetime`
</sql>
<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id "> and `id` = #{id} </if>
<if test=" null != rentContractId "> and `rent_contract_id` = #{rentContractId} </if>
<if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
<if test=" null != pay "> and `pay` = #{pay} </if>
<if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
<if test=" null != payDate "> and `pay_date` = #{payDate} </if>
<if test=" null != createtime "> and `createtime` = #{createtime} </if>
<if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </if>
<if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>
<if test=" null != owe "> and `owe` = #{owe} </if>
<if test=" null != status "> and `status` = #{status} </if>
<if test=" null != isDel "> and `is_del` = #{isDel} </if>
<if test=" null != needPay "> and `need_pay` = #{needPay} </if>
<if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
<if test=" null != userId "> and `user_id` = #{userId} </if>
<if test=" null != shopId "> and `shop_id` = #{shopId} </if>
<if test=" null != updatetime "> and `updatetime` = #{updatetime} </if>
where 1 = 1
<if test=" null != id ">and `id` = #{id}</if>
<if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
<if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
<if test=" null != pay ">and `pay` = #{pay}</if>
<if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
<if test=" null != payDate ">and `pay_date` = #{payDate}</if>
<if test=" null != createtime ">and `createtime` = #{createtime}</if>
<if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
<if test=" null != tenantId ">and `tenant_id` = #{tenantId}</if>
<if test=" null != owe ">and `owe` = #{owe}</if>
<if test=" null != status ">and `status` = #{status}</if>
<if test=" null != isDel ">and `is_del` = #{isDel}</if>
<if test=" null != needPay ">and `need_pay` = #{needPay}</if>
<if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
<if test=" null != userId ">and `user_id` = #{userId}</if>
<if test=" null != shopId ">and `shop_id` = #{shopId}</if>
<if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
<if test=" null != ids ">
and id in
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>
<select id="findList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_bill_rent
<include refid="dynamicWhereConditions" />
select
<include refid="allColumns"/>
from wx_bill_rent
<include refid="dynamicWhereConditions"/>
</select>
<select id="queryBillRentList" parameterType="com.iformall.domain.po.WxRentContract" resultType="hashmap">
select br.`id`,br.`receive_pay` receivePay,br.`pay`,br.`receive_date` receiveDate,
br.`pay_date` payDate,br.`createtime`,br.`expired_day` expiredDay,br.`owe`,br.`status`,
br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`
br.`need_pay` needPay,m.`name` merchantName,s.shop_number shopNumber,br.`updatetime`,
br.`merchant_id` merchantId
from wx_bill_rent br left join wx_merchant m on br.merchant_id=m.id
left join wx_shop s on br.shop_id=s.id
<where>
<if test=" null != id "> and br.`id` = #{id} </if>
<if test=" null != merchantId "> and br.`merchant_id` = #{merchantId} </if>
<if test=" null != tenantId "> and br.`tenant_id` = #{tenantId} </if>
<if test=" null != status "> and br.`status` = #{status} </if>
<if test=" null != isDel "> and br.`is_del` = #{isDel} </if>
<if test=" null != id ">and br.`id` = #{id}</if>
<if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
<if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
<if test=" null != status ">and br.`status` = #{status}</if>
<if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
</where>
order by id
</select>
@@ -86,5 +89,10 @@
group by tenant_id
</select>
<update id="updateNotPaidStatus" parameterType="hashmap">
update wx_bill_rent set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
where tenant_id=#{tenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0
</update>


</mapper>

Loading…
Откажи
Сачувај