From eedc61102e635a118313bc85a82d5c955b96c2b4 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Wed, 31 Oct 2018 18:16:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=B4=A6=E5=8D=95=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0][=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxBillOtherController.java | 73 +++++ .../com/iformall/domain/po/WxBillOther.java | 273 ++++++++++++++++++ .../iformall/mapper/WxBillOtherMapper.java | 22 ++ .../iformall/service/WxBillOtherService.java | 52 ++++ .../service/impl/WxBillOtherServiceImpl.java | 180 ++++++++++++ .../resources/mapper/WxBillOtherMapper.xml | 95 ++++++ 6 files changed, 695 insertions(+) create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/WxBillOtherController.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/po/WxBillOther.java create mode 100644 mallinkService/src/main/java/com/iformall/mapper/WxBillOtherMapper.java create mode 100644 mallinkService/src/main/java/com/iformall/service/WxBillOtherService.java create mode 100644 mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java create mode 100644 mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxBillOtherController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxBillOtherController.java new file mode 100644 index 000000000..7f4613982 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxBillOtherController.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.WxBillOther; +import com.iformall.service.WxBillOtherService; +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("wxBillOther") +public class WxBillOtherController extends BaseController +{ + @Autowired + private WxBillOtherService wxBillOtherService; + + 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 WxBillOther wxBillOther,Integer pageNum, Integer pageSize) { + if (null == wxBillOther) { + wxBillOther = new WxBillOther(); + } + wxBillOther.setTenantId(getTenantId()); + final PageInfo> page = wxBillOtherService.listAsPage(wxBillOther, pageNum, pageSize); + return new ResultData(page); + } + + @PostMapping("add") + public ResultData add(@RequestBody WxBillOther wxBillOther) { + wxBillOther.setTenantId(getTenantId()); + return wxBillOtherService.saveOrUpdate(wxBillOther); + } + + @PostMapping("update") + public ResultData update(@RequestBody WxBillOther wxBillOther) { + return wxBillOtherService.saveOrUpdate(wxBillOther); + } + + @GetMapping("/del") + @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) + public ResultData delete(Long id) { + wxBillOtherService.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,"查询成功",wxBillOtherService.getById(id)); + } + + @GetMapping("/updatePaid") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData updatePaid(Long id) { + return wxBillOtherService.updatePaid(id); + } + + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBillOther.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBillOther.java new file mode 100644 index 000000000..0644dd235 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBillOther.java @@ -0,0 +1,273 @@ +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_other") +public class WxBillOther 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="name") + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @io.swagger.annotations.ApiModelProperty(value="账单备注",name="comments") + private String comments; + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + /*实际应收金额**/ + @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欠缴4已结清",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/mapper/WxBillOtherMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillOtherMapper.java new file mode 100644 index 000000000..29edff38d --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillOtherMapper.java @@ -0,0 +1,22 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxBillOther; + +import java.util.List; +import java.util.Map; + +/** + * @author gongbiao + */ +public interface WxBillOtherMapper extends CommonMapper { + + List findList(WxBillOther wxBillDaily); + + void updateNotPaidStatus(Map params); + + void updateWaitPayStatus(Map params); + + List> queryBillDailyList(WxBillOther record); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxBillOtherService.java b/mallinkService/src/main/java/com/iformall/service/WxBillOtherService.java new file mode 100644 index 000000000..ab3390573 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxBillOtherService.java @@ -0,0 +1,52 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.WxBillOther; +import com.iformall.domain.po.WxBillOther; + +import java.util.Map; + +/** + * @author gongbiao + */ +public interface WxBillOtherService { + + /** + * 根据实体查询分页列表 + * + * @param offset + * @param limit + * @param record + * @return + */ + PageInfo> listAsPage(WxBillOther record, Integer pageIndex, Integer pageSize); + + void updateBillStatus(WxBillOther record); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + Map getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + ResultData saveOrUpdate(WxBillOther record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + ResultData updatePaid(Long id); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java new file mode 100644 index 000000000..27f49df00 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillOtherServiceImpl.java @@ -0,0 +1,180 @@ +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.WxBillOther; +import com.iformall.domain.po.WxShop; +import com.iformall.enums.EnumBillDailyStatus; +import com.iformall.enums.EnumBillRentStatus; +import com.iformall.exception.MallinkException; +import com.iformall.mapper.WxBillOtherMapper; +import com.iformall.mapper.WxShopMapper; +import com.iformall.service.WxBillOtherService; +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.*; + +/** + * @author gongbiao + */ +@Service +public class WxBillOtherServiceImpl implements WxBillOtherService { + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxBillOtherMapper wxBillOtherMapper; + + @Autowired + WxShopMapper wxShopMapper; + + @Override + public PageInfo> listAsPage(WxBillOther record, Integer pageIndex, Integer pageSize) { + //更新账单状态 + updateBillStatus(record); + //分页对象设置页数和条数 + PageHelper.startPage(pageIndex, pageSize); + //查询 + List> billDepositList = wxBillOtherMapper.queryBillDailyList(record); + //结果放入分页对象 + PageInfo> pageInfo = new PageInfo<>(billDepositList); + return pageInfo; + + } + + @Override + public void updateBillStatus(WxBillOther record) { + logger.info("更新其他账单状态开始..."); + //更新逾期天数及状态 + updateNotPaidStatus(record); + //更新待缴的状态 + updateWaidPayStatus(record); + logger.info("更新其他账单状态结束..."); + } + + @Transactional(rollbackFor = {Exception.class}) + public void updateWaidPayStatus(WxBillOther record) { + Map params = new HashMap<>(); + params.put("tenantId", record.getTenantId()); + params.put("waitPay", EnumBillDailyStatus.WAIT_PAY.getCode()); + params.put("paid", EnumBillRentStatus.PAID.getCode()); + try { + wxBillOtherMapper.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(WxBillOther record) { + Map params = new HashMap<>(); + params.put("tenantId", record.getTenantId()); + params.put("notPaid", EnumBillDailyStatus.NOT_PAID.getCode()); + params.put("paid", EnumBillRentStatus.PAID.getCode()); + try { + wxBillOtherMapper.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) { + WxBillOther record = new WxBillOther(); + record.setId(id); + Map wxBillOther = wxBillOtherMapper.queryBillDailyList(record).get(0); + + if(wxBillOther.get("shopId")!=null) { + WxShop shop = new WxShop(); + shop.setId((Long)wxBillOther.get("shopId")); + List> shoplist = wxShopMapper.findListMap(shop); + wxBillOther.put("shops",shoplist); + }else{ + wxBillOther.put("shops",Collections.EMPTY_LIST); + } + + return wxBillOther; + } + + @Override + public ResultData saveOrUpdate(WxBillOther 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 { + wxBillOtherMapper.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("更新其他押金账单"); + WxBillOther wxBillOther = wxBillOtherMapper.selectByPrimaryKey(record.getId()); + if(wxBillOther==null){ + return new ResultData(ErrorCode.BILL_ROUTINE_IS_NOT_FOUND); + } + wxBillOther.setPayDate(record.getPayDate()); + wxBillOther.setPay(record.getPay()); + wxBillOther.setReceivePay(record.getReceivePay()); + wxBillOther.setOwe(record.getOwe()); + wxBillOther.setStatus(record.getPay().equals(record.getReceivePay()) ? EnumBillDailyStatus.PAID.getCode() : wxBillOther.getStatus()); + wxBillOther.setUpdatetime(new Date()); + try { + wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther); + } 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) { + wxBillOtherMapper.deleteByPrimaryKey(id); + } + + @Transactional(rollbackFor = {Exception.class}) + @Override + public ResultData updatePaid(Long id) { + WxBillOther wxBillOther = wxBillOtherMapper.selectByPrimaryKey(id); + if(wxBillOther==null){ + return new ResultData(ErrorCode.BILL_ROUTINE_IS_NOT_FOUND); + } + wxBillOther.setStatus(EnumBillDailyStatus.PAID.getCode()); + Date d =new Date(); + wxBillOther.setPayDate(d); + wxBillOther.setUpdatetime(d); + try { + wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther); + } 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/WxBillOtherMapper.xml b/mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml new file mode 100644 index 000000000..68a4e7cc5 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxBillOtherMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`tenant_id`,`owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`name`,`comments` + + + + 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 `name` = #{name} + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + update wx_bill_other 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_other set status=#{waitPay} where tenant_id=#{tenantId} + and status!=#{paid} and DATEDIFF(now(),receive_date) <=0 + + + + + + +