From 4b154ffa155e62cda4e4c2d322132c1617a952c6 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Fri, 26 Oct 2018 16:22:09 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=97=A5=E5=B8=B8=E8=B4=B9=E7=94=A8=E5=90=88?= =?UTF-8?q?=E5=90=8C][=E6=B7=BB=E5=8A=A0][=E4=B8=9A=E5=8A=A1=E9=80=BB?= =?UTF-8?q?=E8=BE=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxBillDailyController.java | 73 +++++ .../com/iformall/domain/po/WxBillDaily.java | 251 ++++++++++++++++++ .../iformall/enums/EnumBillDailyStatus.java | 39 +++ .../iformall/enums/EnumBillRentStatus.java | 4 +- .../iformall/mapper/WxBillDailyMapper.java | 22 ++ .../iformall/service/WxBillDailyService.java | 49 ++++ .../service/impl/WxBillDailyServiceImpl.java | 153 +++++++++++ .../resources/mapper/WxBillDailyMapper.xml | 89 +++++++ 8 files changed, 679 insertions(+), 1 deletion(-) create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/WxBillDailyController.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/WxBillDaily.java create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumBillDailyStatus.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/WxBillDailyMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/service/WxBillDailyService.java create mode 100644 mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java create mode 100644 mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxBillDailyController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxBillDailyController.java new file mode 100644 index 000000000..6bc77e3bf --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxBillDailyController.java @@ -0,0 +1,73 @@ +package com.iformall.controller; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.Result; +import com.iformall.common.ResultData; +import com.iformall.domain.po.WxBillDaily; +import com.iformall.service.WxBillDailyService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author gongbiao + */ +@RestController +@RequestMapping("wxBillDaily") +public class WxBillDailyController extends BaseController +{ + @Autowired + private WxBillDailyService wxBillDailyService; + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), + @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) + public ResultData list(@ModelAttribute WxBillDaily wxBillDaily,Integer pageNum, Integer pageSize) { + if (null == wxBillDaily) { + wxBillDaily = new WxBillDaily(); + } + wxBillDaily.setTenantId(getTenantId()); + final PageInfo> page = wxBillDailyService.listAsPage(wxBillDaily, pageNum, pageSize); + return new ResultData(page); + } + + @PostMapping("add") + public ResultData add(@RequestBody WxBillDaily wxBillDaily) { + wxBillDaily.setTenantId(getTenantId()); + return wxBillDailyService.saveOrUpdate(wxBillDaily); + } + + @PostMapping("update") + public ResultData update(@RequestBody WxBillDaily wxBillDaily) { + return wxBillDailyService.saveOrUpdate(wxBillDaily); + } + + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + wxBillDailyService.deleteById(id); + return new ResultData(Result.SUCCESS, "删除成功", null); + } + + @GetMapping("/findById") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData findById(Long id) { + return new ResultData(Result.SUCCESS,"查询成功",wxBillDailyService.getById(id)); + } + + @GetMapping("/updatePaid") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData updatePaid(Long id) { + return wxBillDailyService.updatePaid(id); + } + + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBillDaily.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBillDaily.java new file mode 100644 index 000000000..2b1b52ecb --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBillDaily.java @@ -0,0 +1,251 @@ +package com.iformall.domain.po; + +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author gongbiao + */ +@Table(name = "wx_bill_daily") +public class WxBillDaily implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; + + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + public String getSortColumns() { + return sortColumns; + } + + public List getIds() { + return ids; + } + public void setIds(List ids) { + this.ids = ids; + } + + @Transient + private String merchantName; + + public String getMerchantName() { + return merchantName; + } + + public void setMerchantName(String merchantName) { + this.merchantName = merchantName; + } + + /*实际应收金额**/ + @io.swagger.annotations.ApiModelProperty(value="实际应收金额",name="receivePay") + private Integer receivePay; + /*实收金额**/ + @io.swagger.annotations.ApiModelProperty(value="实收金额",name="pay") + private Integer pay; + /*截止收款日期**/ + @io.swagger.annotations.ApiModelProperty(value="截止收款日期",name="receiveDate") + private Date receiveDate; + /*到账日期**/ + @io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate") + private Date payDate; + /*创建时间**/ + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime") + private Date createtime; + /*逾期天数**/ + @io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay") + private Long expiredDay; + /*租户**/ + @io.swagger.annotations.ApiModelProperty(value="租户",name="tenantId") + private String tenantId; + /*欠缴**/ + @io.swagger.annotations.ApiModelProperty(value="欠缴",name="owe") + private Integer owe; + /*账单状态1待缴2欠缴3已结清**/ + @io.swagger.annotations.ApiModelProperty(value="账单状态1待缴2欠缴3已结清",name="status") + private Integer status; + /*删除 是1否0**/ + @io.swagger.annotations.ApiModelProperty(value="删除 是1否0",name="isDel") + private Integer isDel; + /*商户ID**/ + @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") + private Long merchantId; + /*账号ID**/ + @io.swagger.annotations.ApiModelProperty(value="账号ID",name="userId") + private Long userId; + /*商铺ID**/ + @io.swagger.annotations.ApiModelProperty(value="商铺ID",name="shopId") + private Long shopId; + /*更新时间**/ + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") + private Date updatetime; + public Integer getReceivePay() { + return receivePay; + } + public void setReceivePay(Integer _receivePay) { + receivePay = _receivePay; + } + public Integer getPay() { + return pay; + } + public void setPay(Integer _pay) { + pay = _pay; + } + public Date getReceiveDate() { + return receiveDate; + } + public void setReceiveDate(Date _receiveDate) { + receiveDate = _receiveDate; + } + public Date getPayDate() { + return payDate; + } + public void setPayDate(Date _payDate) { + payDate = _payDate; + } + public Date getCreatetime() { + return createtime; + } + public void setCreatetime(Date _createtime) { + createtime = _createtime; + } + public Long getExpiredDay() { + return expiredDay; + } + public void setExpiredDay(Long _expiredDay) { + expiredDay = _expiredDay; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String _tenantId) { + tenantId = _tenantId; + } + public Integer getOwe() { + return owe; + } + public void setOwe(Integer _owe) { + owe = _owe; + } + public Integer getStatus() { + return status; + } + public void setStatus(Integer _status) { + status = _status; + } + public Integer getIsDel() { + return isDel; + } + public void setIsDel(Integer _isDel) { + isDel = _isDel; + } + public Long getMerchantId() { + return merchantId; + } + public void setMerchantId(Long _merchantId) { + merchantId = _merchantId; + } + public Long getUserId() { + return userId; + } + public void setUserId(Long _userId) { + userId = _userId; + } + public Long getShopId() { + return shopId; + } + public void setShopId(Long _shopId) { + shopId = _shopId; + } + public Date getUpdatetime() { + return updatetime; + } + public void setUpdatetime(Date _updatetime) { + updatetime = _updatetime; + } + + + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,ReceivePay_ASC("`receivePay` ASC"),ReceivePay_DESC("`receivePay` DESC") + ,Pay_ASC("`pay` ASC"),Pay_DESC("`pay` DESC") + ,ReceiveDate_ASC("`receiveDate` ASC"),ReceiveDate_DESC("`receiveDate` DESC") + ,PayDate_ASC("`payDate` ASC"),PayDate_DESC("`payDate` DESC") + ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") + ,ExpiredDay_ASC("`expiredDay` ASC"),ExpiredDay_DESC("`expiredDay` DESC") + ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,Owe_ASC("`owe` ASC"),Owe_DESC("`owe` DESC") + ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") + ,IsDel_ASC("`isDel` ASC"),IsDel_DESC("`isDel` DESC") + ,MerchantId_ASC("`merchantId` ASC"),MerchantId_DESC("`merchantId` DESC") + ,UserId_ASC("`userId` ASC"),UserId_DESC("`userId` DESC") + ,ShopId_ASC("`shopId` ASC"),ShopId_DESC("`shopId` DESC") + ,Updatetime_ASC("`updatetime` ASC"),Updatetime_DESC("`updatetime` DESC") + ; + private String value; + Field(String value){ + this.value = value; + } + public String getValue() { + return value; + } + public void setCol(String value) { + this.value = value; + } + @Override + public String toString() { + return this.getValue(); + } + } + + public void setSortColumns(Field... fields) + { + if (fields == null || fields.length == 0) { + return; + } + for (int k = 0; k < fields.length; k++) { + if (fields[k] == null) { + return; + } + } + StringBuilder sb = new StringBuilder(fields[0].toString()); + for (int k = 1; k < fields.length; k++) { + sb.append(","); + sb.append(fields[k].toString()); + } + + } + + public void setSortColumns(String sortColumns) + { + if (sortColumns == null || "".equals(sortColumns.trim())) { + return; + } + if (sortColumns.contains(",")) { + String[] cols = sortColumns.split(","); + List fList = new ArrayList(); + for (int k = 0; k < cols.length; k++) { + fList.add(Field.valueOf(cols[k])); + } + this.setSortColumns(fList.toArray(new Field[fList.size()])); + } else { + this.setSortColumns(Field.valueOf(sortColumns)); + } + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumBillDailyStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumBillDailyStatus.java new file mode 100644 index 000000000..e22745b9c --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumBillDailyStatus.java @@ -0,0 +1,39 @@ +package com.iformall.enums; + + +/** + * @author gongbiao + */ + +public enum EnumBillDailyStatus { + + WAIT_PAY(1,"待缴"), + NOT_PAID(2, "欠缴"), + PAID(3, "已结清"), + ; + + public static EnumBillDailyStatus getEnum(Integer code) { + for (EnumBillDailyStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumBillDailyStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumBillRentStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumBillRentStatus.java index 6caba4354..bcf706dee 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumBillRentStatus.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumBillRentStatus.java @@ -1,8 +1,10 @@ package com.iformall.enums; + /** - * Created by Stormeye on 2018/08/09. + * @author gongbiao */ + public enum EnumBillRentStatus { NOT_EXPIRED(1,"未到期"), diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillDailyMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillDailyMapper.java new file mode 100644 index 000000000..b5cf9d27f --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillDailyMapper.java @@ -0,0 +1,22 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxBillDaily; + +import java.util.List; +import java.util.Map; + +/** + * @author gongbiao + */ +public interface WxBillDailyMapper extends CommonMapper { + + List findList(WxBillDaily wxBillDaily); + + void updateNotPaidStatus(Map params); + + void updateWaitPayStatus(Map params); + + List> queryBillDailyList(WxBillDaily record); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxBillDailyService.java b/mallinkService/src/main/java/com/iformall/service/WxBillDailyService.java new file mode 100644 index 000000000..b4e3a6cd5 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxBillDailyService.java @@ -0,0 +1,49 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.WxBillDaily; + +import java.util.Map; + +/** + * @author gongbiao + */ +public interface WxBillDailyService { + + /** + * 根据实体查询分页列表 + * + * @param offset + * @param limit + * @param record + * @return + */ + PageInfo> listAsPage(WxBillDaily record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + Map getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + ResultData saveOrUpdate(WxBillDaily record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + ResultData updatePaid(Long id); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java new file mode 100644 index 000000000..039c5e9a7 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDailyServiceImpl.java @@ -0,0 +1,153 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; +import com.iformall.common.IdWorker; +import com.iformall.common.Result; +import com.iformall.common.ResultData; +import com.iformall.domain.po.WxBillDaily; +import com.iformall.domain.po.WxBillDeposit; +import com.iformall.enums.EnumBillDailyStatus; +import com.iformall.enums.EnumBillRentStatus; +import com.iformall.exception.MallinkException; +import com.iformall.mapper.WxBillDailyMapper; +import com.iformall.service.WxBillDailyService; +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; + +/** + * @author gongbiao + */ +@Service +public class WxBillDailyServiceImpl implements WxBillDailyService { + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxBillDailyMapper wxBillDailyMapper; + + + @Override + public PageInfo> listAsPage(WxBillDaily record, Integer pageIndex, Integer pageSize) { + + //更新逾期天数及状态 + updateNotPaidStatus(record); + //更新待缴的状态 + updateWaidPayStatus(record); + PageHelper.startPage(pageIndex, pageSize); + List> billDepositList = wxBillDailyMapper.queryBillDailyList(record); + PageInfo> pageInfo = new PageInfo<>(billDepositList); + return pageInfo; + + } + + @Transactional(rollbackFor = {Exception.class}) + public void updateWaidPayStatus(WxBillDaily record) { + Map params = new HashMap<>(); + params.put("tenantId", record.getTenantId()); + params.put("waitPay", EnumBillDailyStatus.WAIT_PAY.getCode()); + params.put("paid", EnumBillRentStatus.PAID.getCode()); + try { + wxBillDailyMapper.updateWaitPayStatus(params); + } catch (Exception e) { + logger.error("更新日常待缴账单状态失败,e:" + e.getMessage()); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); + } + } + + + @Transactional(rollbackFor = {Exception.class}) + public void updateNotPaidStatus(WxBillDaily record) { + Map params = new HashMap<>(); + params.put("tenantId", record.getTenantId()); + params.put("notPaid", EnumBillDailyStatus.NOT_PAID.getCode()); + params.put("paid", EnumBillRentStatus.PAID.getCode()); + try { + wxBillDailyMapper.updateNotPaidStatus(params); + } catch (Exception e) { + logger.error("更新日常欠缴账单状态失败,e:" + e.getMessage()); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); + } + } + + @Override + public Map getById(Long id) { + WxBillDaily record = new WxBillDaily(); + record.setId(id); + return wxBillDailyMapper.queryBillDailyList(record).get(0); + } + + @Override + public ResultData saveOrUpdate(WxBillDaily record) { + + if (record.getId() == null) { + logger.info("新增日常账单"); + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + Date date = new Date(); + record.setStatus(record.getReceiveDate().before(date)?EnumBillDailyStatus.WAIT_PAY.getCode():EnumBillDailyStatus.NOT_PAID.getCode()); + record.setCreatetime(date); + record.setUpdatetime(date); + try { + wxBillDailyMapper.insertSelective(record); + } catch (Exception e) { + logger.error("保存日常账单失败,e:" + e.getMessage()); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); + } + return new ResultData(Result.SUCCESS, "保存日常账单成功"); + } else { + logger.info("更新日常押金账单"); + WxBillDaily wxBillDaily = wxBillDailyMapper.selectByPrimaryKey(record.getId()); + wxBillDaily.setPayDate(record.getPayDate()); + wxBillDaily.setPay(record.getPay() * 100); + wxBillDaily.setReceivePay(record.getReceivePay() * 100); + wxBillDaily.setOwe(record.getOwe() * 100); + wxBillDaily.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillDaily.getStatus()); + wxBillDaily.setUpdatetime(new Date()); + try { + wxBillDailyMapper.updateByPrimaryKeySelective(wxBillDaily); + } catch (Exception e) { + logger.error("更新日常账单失败,e:" + e.getMessage()); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); + } + return new ResultData(Result.SUCCESS, "更新日常账单成功"); + } + } + + + @Override + public void deleteById(Long id) { + wxBillDailyMapper.deleteByPrimaryKey(id); + } + + @Transactional(rollbackFor = {Exception.class}) + @Override + public ResultData updatePaid(Long id) { + WxBillDaily wxBillDaily = wxBillDailyMapper.selectByPrimaryKey(id); + wxBillDaily.setStatus(EnumBillDailyStatus.PAID.getCode()); + Date d =new Date(); + wxBillDaily.setPayDate(d); + wxBillDaily.setUpdatetime(d); + try { + wxBillDailyMapper.updateByPrimaryKeySelective(wxBillDaily); + } catch (Exception e) { + logger.error("日常账单结单失败,e:" + e.getMessage()); + throw new MallinkException(ErrorCode.DB_FAIL.getCode(),e.getMessage()); + } + return new ResultData(Result.SUCCESS, "日常账单结单成功"); + } + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml new file mode 100644 index 000000000..332f6e35a --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime` + + + + where 1 = 1 + and `id` = #{id} + and `receive_pay` = #{receivePay} + and `pay` = #{pay} + and `receive_date` = #{receiveDate} + and `pay_date` = #{payDate} + and `createtime` = #{createtime} + and `expired_day` = #{expiredDay} + and `tenant_id` = #{tenantId} + and `owe` = #{owe} + and `status` = #{status} + and `is_del` = #{isDel} + and `merchant_id` = #{merchantId} + and `user_id` = #{userId} + and `shop_id` = #{shopId} + and `updatetime` = #{updatetime} + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date) + where tenant_id=#{tenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0 + + + + update wx_bill_daily set status=#{waitPay} where tenant_id=#{tenantId} + and status!=#{paid} and DATEDIFF(now(),receive_date) <=0 + + + + + + +