| @@ -1,19 +1,16 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.util.Assert; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.WxMerchantBUser; | import com.simple.domain.po.WxMerchantBUser; | ||||
| import com.simple.service.WxMerchantBUserService; | import com.simple.service.WxMerchantBUserService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxMerchantBUser") | @RequestMapping("wxMerchantBUser") | ||||
| @@ -40,6 +37,7 @@ public class WxMerchantBUserController extends BaseController | |||||
| public ResultData add(@RequestBody WxMerchantBUser wxMerchantBUser) { | public ResultData add(@RequestBody WxMerchantBUser wxMerchantBUser) { | ||||
| //Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空"); | //Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxMerchantBUser.setTenantId(getTenantId()); | |||||
| wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -1,19 +1,16 @@ | |||||
| package com.simple.controller; | package com.simple.controller; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.util.Assert; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.Result; | import com.simple.common.Result; | ||||
| import com.simple.common.ResultData; | import com.simple.common.ResultData; | ||||
| import com.simple.domain.po.WxMerchant; | import com.simple.domain.po.WxMerchant; | ||||
| import com.simple.service.WxMerchantService; | import com.simple.service.WxMerchantService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxMerchant") | @RequestMapping("wxMerchant") | ||||
| @@ -37,10 +34,11 @@ public class WxMerchantController extends BaseController | |||||
| @ApiOperation("新增接口") | @ApiOperation("新增接口") | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxMerchant wxMerchant) { | |||||
| public ResultData add(@ModelAttribute WxMerchant wxMerchant,String shopids, String userids) { | |||||
| //Assert.notNull(wxMerchant.getName(), "角色名不能为空"); | //Assert.notNull(wxMerchant.getName(), "角色名不能为空"); | ||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | ||||
| wxMerchantService.saveOrUpdate(wxMerchant); | |||||
| wxMerchant.setTenantId(getTenantId()); | |||||
| wxMerchantService.saveOrUpdate(wxMerchant,shopids,userids); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -1,12 +1,11 @@ | |||||
| package com.simple.domain.po; | package com.simple.domain.po; | ||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_merchant") | @Table(name = "wx_merchant") | ||||
| public class WxMerchant implements Serializable { | public class WxMerchant implements Serializable { | ||||
| @@ -74,6 +73,10 @@ public class WxMerchant implements Serializable { | |||||
| /*停车厂商参数**/ | /*停车厂商参数**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="停车厂商参数",name="carParams") | @io.swagger.annotations.ApiModelProperty(value="停车厂商参数",name="carParams") | ||||
| private String carParams; | private String carParams; | ||||
| @io.swagger.annotations.ApiModelProperty(value="状态1可用0停用",name="status") | |||||
| private Integer status; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -141,7 +144,13 @@ public class WxMerchant implements Serializable { | |||||
| carParams = _carParams; | carParams = _carParams; | ||||
| } | } | ||||
| public Integer getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(Integer status) { | |||||
| this.status = status; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| @@ -157,7 +166,9 @@ public class WxMerchant implements Serializable { | |||||
| ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | ,UpdateDate_ASC("`updateDate` ASC"),UpdateDate_DESC("`updateDate` DESC") | ||||
| ,CarVendorType_ASC("`carVendorType` ASC"),CarVendorType_DESC("`carVendorType` DESC") | ,CarVendorType_ASC("`carVendorType` ASC"),CarVendorType_DESC("`carVendorType` DESC") | ||||
| ,CarParams_ASC("`carParams` ASC"),CarParams_DESC("`carParams` DESC") | ,CarParams_ASC("`carParams` ASC"),CarParams_DESC("`carParams` DESC") | ||||
| ; | |||||
| ,Status_ASC("`status` ASC"),Status_DESC("`status` DESC") | |||||
| ; | |||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| this.value = value; | this.value = value; | ||||
| @@ -37,12 +37,8 @@ public interface WxMerchantService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids); | |||||
| } | } | ||||
| @@ -1,14 +1,24 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.util.*; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.IdWorker; | |||||
| import com.simple.domain.po.WxMerchant; | import com.simple.domain.po.WxMerchant; | ||||
| import com.simple.domain.po.WxMerchantBUser; | |||||
| import com.simple.domain.po.WxMerchantShop; | |||||
| import com.simple.domain.po.WxShop; | |||||
| import com.simple.mapper.WxMerchantBUserMapper; | |||||
| import com.simple.mapper.WxMerchantMapper; | import com.simple.mapper.WxMerchantMapper; | ||||
| import com.simple.mapper.WxMerchantShopMapper; | |||||
| import com.simple.mapper.WxShopMapper; | |||||
| import com.simple.service.WxMerchantService; | import com.simple.service.WxMerchantService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.simple.common.IdWorker; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Service | @Service | ||||
| public class WxMerchantServiceImpl implements WxMerchantService { | public class WxMerchantServiceImpl implements WxMerchantService { | ||||
| @@ -16,6 +26,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantMapper wxMerchantMapper; | WxMerchantMapper wxMerchantMapper; | ||||
| @Autowired | |||||
| WxShopMapper WxShopMapper; | |||||
| @Autowired | |||||
| WxMerchantShopMapper wxMerchantShopMapper; | |||||
| @Autowired | |||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchant> listAsPage(WxMerchant record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -33,6 +51,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreateDate(new Date()); | |||||
| wxMerchantMapper.insertSelective(record); | wxMerchantMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| wxMerchantMapper.updateByPrimaryKeySelective(record); | wxMerchantMapper.updateByPrimaryKeySelective(record); | ||||
| @@ -43,12 +63,123 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxMerchantMapper.deleteByPrimaryKey(id); | wxMerchantMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Transactional | |||||
| @Override | |||||
| public void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids) { | |||||
| if (wxMerchant.getId() == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| long merchantid = idWorker.nextId(); | |||||
| wxMerchant.setId(merchantid); | |||||
| Date date = new Date(); | |||||
| wxMerchant.setUpdateDate(date); | |||||
| wxMerchant.setCreateDate(date); | |||||
| wxMerchantMapper.insertSelective(wxMerchant); | |||||
| //保存商户商铺的关联 | |||||
| List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class); | |||||
| for(Long shopid:shopidlist){ | |||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||||
| wxMerchantShop.setId(idWorker.nextId()); | |||||
| wxMerchantShop.setMerchantId(merchantid); | |||||
| wxMerchantShop.setShopId(shopid); | |||||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | |||||
| Date shopdate = new Date(); | |||||
| wxMerchantShop.setUpdateDate(shopdate); | |||||
| wxMerchantShop.setCreateDate(shopdate); | |||||
| wxMerchantShop.setRentalEndDate(shopdate); | |||||
| wxMerchantShop.setRentalStartDate(shopdate); | |||||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||||
| //更新商铺状态 | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setId(shopid); | |||||
| wxShop.setStatus(1);//已出租 | |||||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | |||||
| } | |||||
| //保存商户关联用户 | |||||
| List<Long> useridlist = JSONArray.parseArray(userids, Long.class); | |||||
| for(Long userid:useridlist){ | |||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.setId(userid); | |||||
| List<WxMerchantBUser> buserlist = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||||
| if(buserlist.size()>0){ | |||||
| wxMerchantBUser = buserlist.get(0); | |||||
| wxMerchantBUser.setMerchantId(merchantid); | |||||
| wxMerchantBUser.setUpdateDate(new Date()); | |||||
| wxMerchantBUserMapper.updateByPrimaryKey(wxMerchantBUser); | |||||
| } | |||||
| } | |||||
| } else { | |||||
| //更新商户 | |||||
| Date date = new Date(); | |||||
| wxMerchant.setUpdateDate(date); | |||||
| wxMerchantMapper.updateByPrimaryKeySelective(wxMerchant); | |||||
| //删除当前商户关联的所有商铺然后再插入 | |||||
| WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); | |||||
| wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); | |||||
| wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); | |||||
| List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); | |||||
| for(WxMerchantShop merchantShop:wxMerchantShopList){ | |||||
| wxMerchantShopMapper.delete(merchantShop); | |||||
| //更新商铺状态 | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setId(merchantShop.getShopId()); | |||||
| wxShop.setStatus(0);//已出租 | |||||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| //保存商户商铺的关联 | |||||
| List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class); | |||||
| for(Long shopid:shopidlist){ | |||||
| WxMerchantShop wxMerchantShop = new WxMerchantShop(); | |||||
| wxMerchantShop.setId(idWorker.nextId()); | |||||
| wxMerchantShop.setMerchantId(wxMerchant.getId()); | |||||
| wxMerchantShop.setShopId(shopid); | |||||
| wxMerchantShop.setTenantId(wxMerchant.getTenantId()); | |||||
| Date shopdate = new Date(); | |||||
| wxMerchantShop.setUpdateDate(shopdate); | |||||
| wxMerchantShop.setCreateDate(shopdate); | |||||
| wxMerchantShop.setRentalEndDate(shopdate); | |||||
| wxMerchantShop.setRentalStartDate(shopdate); | |||||
| wxMerchantShopMapper.insertSelective(wxMerchantShop); | |||||
| //更新商铺状态 | |||||
| WxShop wxShop = new WxShop(); | |||||
| wxShop.setId(shopid); | |||||
| wxShop.setStatus(1);//已出租 | |||||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | |||||
| } | |||||
| //保存商户关联用户 | |||||
| List<Long> useridlist = JSONArray.parseArray(userids, Long.class); | |||||
| for(Long userid:useridlist){ | |||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.setId(userid); | |||||
| List<WxMerchantBUser> buserlist = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||||
| if(buserlist.size()>0){ | |||||
| wxMerchantBUser = buserlist.get(0); | |||||
| wxMerchantBUser.setMerchantId(wxMerchant.getId()); | |||||
| wxMerchantBUser.setUpdateDate(new Date()); | |||||
| wxMerchantBUserMapper.updateByPrimaryKey(wxMerchantBUser); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -30,15 +30,14 @@ public class WxShopServiceImpl implements WxShopService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxShop record) { | public void saveOrUpdate(WxShop record) { | ||||
| List<WxShop> list = wxShopMapper.findList(record); | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setStatus(0); | record.setStatus(0); | ||||
| record.setUpdateDate(new Date()); | |||||
| record.setCreateDate(new Date()); | |||||
| Date date = new Date(); | |||||
| record.setUpdateDate(date); | |||||
| record.setCreateDate(date); | |||||
| wxShopMapper.insertSelective(record); | wxShopMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| @@ -14,10 +14,12 @@ | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | ||||
| <result column="car_vendor_type" jdbcType="INTEGER" property="carVendorType" /> | <result column="car_vendor_type" jdbcType="INTEGER" property="carVendorType" /> | ||||
| <result column="car_params" jdbcType="VARCHAR" property="carParams" /> | <result column="car_params" jdbcType="VARCHAR" property="carParams" /> | ||||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`bank_card`,`bank_name`,`pay_id`,`create_date`,`update_date`,`car_vendor_type`,`car_params` | |||||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`bank_card`,`bank_name`,`wxchat_account`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -81,7 +83,13 @@ | |||||
| <if test=" null != carParams "> | <if test=" null != carParams "> | ||||
| and `car_params` like concat('%', #{carParams},'%') | and `car_params` like concat('%', #{carParams},'%') | ||||
| </if> | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and `status` = #{status} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||