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

[商铺商户][修改]:添加商户功能的修改

release_toaliyun_real
gongbiao 7 лет назад
Родитель
Сommit
d94ff7a63d
8 измененных файлов: 89 добавлений и 40 удалений
  1. +2
    -2
      mallinkAdmin/src/main/java/com/simple/controller/WxMerchantController.java
  2. +16
    -6
      mallinkAdmin/src/main/java/com/simple/controller/WxMerchantShopController.java
  3. +21
    -2
      mallinkService/src/main/java/com/simple/domain/po/WxMerchant.java
  4. +0
    -2
      mallinkService/src/main/java/com/simple/service/WxMerchantService.java
  5. +6
    -7
      mallinkService/src/main/java/com/simple/service/WxMerchantShopService.java
  6. +8
    -1
      mallinkService/src/main/java/com/simple/service/impl/WxMerchantBUserServiceImpl.java
  7. +5
    -18
      mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java
  8. +31
    -2
      mallinkService/src/main/java/com/simple/service/impl/WxMerchantShopServiceImpl.java

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

@@ -34,11 +34,11 @@ public class WxMerchantController extends BaseController

@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@ModelAttribute WxMerchant wxMerchant,String shopids, String userids) {
public ResultData add(@RequestBody WxMerchant wxMerchant) {
//Assert.notNull(wxMerchant.getName(), "角色名不能为空");
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
wxMerchant.setTenantId(getTenantId());
wxMerchantService.saveOrUpdate(wxMerchant,shopids,userids);
wxMerchantService.saveOrUpdate(wxMerchant);
return new ResultData();
}



+ 16
- 6
mallinkAdmin/src/main/java/com/simple/controller/WxMerchantShopController.java Просмотреть файл

@@ -1,19 +1,17 @@
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.simple.common.Result;
import com.simple.common.ResultData;

import com.simple.domain.po.WxMerchantShop;
import com.simple.domain.po.WxShop;
import com.simple.service.WxMerchantShopService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wxMerchantShop")
@@ -35,6 +33,18 @@ public class WxMerchantShopController extends BaseController
return new ResultData(page);
}

@ApiOperation("获取关联商铺信息")
@GetMapping("queryShopList")
@ApiImplicitParams({
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop,Integer pageNum, Integer pageSize) {
if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop();
final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize);
return new ResultData(page);
}


@ApiOperation("新增接口")
@PostMapping("add")
public ResultData add(@RequestBody WxMerchantShop wxMerchantShop) {


+ 21
- 2
mallinkService/src/main/java/com/simple/domain/po/WxMerchant.java Просмотреть файл

@@ -37,8 +37,11 @@ public class WxMerchant implements Serializable {
public void setIds(List<Long> ids) {
this.ids = ids;
}

@Transient
private String userids;
@Transient
private String shopids;
/*租户ID**/
@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
@@ -152,6 +155,22 @@ public class WxMerchant implements Serializable {
this.status = status;
}

public String getUserids() {
return userids;
}

public void setUserids(String userids) {
this.userids = userids;
}

public String getShopids() {
return shopids;
}

public void setShopids(String shopids) {
this.shopids = shopids;
}

public static enum Field
{
Id_ASC("`id` ASC"),Id_DESC("`id` DESC")


+ 0
- 2
mallinkService/src/main/java/com/simple/service/WxMerchantService.java Просмотреть файл

@@ -39,6 +39,4 @@ public interface WxMerchantService {
void deleteById(Long id);


void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids);

}

+ 6
- 7
mallinkService/src/main/java/com/simple/service/WxMerchantShopService.java Просмотреть файл

@@ -1,8 +1,8 @@
package com.simple.service;

import java.util.*;
import com.github.pagehelper.PageInfo;
import com.simple.domain.po.WxMerchantShop;
import com.simple.domain.po.WxShop;

public interface WxMerchantShopService {

@@ -37,12 +37,11 @@ public interface WxMerchantShopService {
* @param id
*/
void deleteById(Long id);



PageInfo<WxShop> queryShopList(WxMerchantShop record, Integer pageIndex, Integer pageSize);


}

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

@@ -37,9 +37,16 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService {
if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
long id = idWorker.nextId();
record.setId(id);
record.setBUserId(id);
Date date = new Date();
record.setCreateDate(date);
record.setUpdateDate(date);
wxMerchantBUserMapper.insertSelective(record);
} else {
Date date = new Date();
record.setUpdateDate(date);
wxMerchantBUserMapper.updateByPrimaryKeySelective(record);
}
}


+ 5
- 18
mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java Просмотреть файл

@@ -45,19 +45,6 @@ public class WxMerchantServiceImpl implements WxMerchantService {
return wxMerchantMapper.selectByPrimaryKey(id);
}

@Override
public void saveOrUpdate(WxMerchant record) {
if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateDate(new Date());

wxMerchantMapper.insertSelective(record);
} else {
wxMerchantMapper.updateByPrimaryKeySelective(record);
}
}

@Override
public void deleteById(Long id) {
@@ -66,7 +53,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

@Transactional
@Override
public void saveOrUpdate(WxMerchant wxMerchant, String shopids, String userids) {
public void saveOrUpdate(WxMerchant wxMerchant) {


if (wxMerchant.getId() == null) {
@@ -79,7 +66,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxMerchantMapper.insertSelective(wxMerchant);

//保存商户商铺的关联
List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class);
List<Long> shopidlist = JSONArray.parseArray(wxMerchant.getShopids(), Long.class);
for(Long shopid:shopidlist){
WxMerchantShop wxMerchantShop = new WxMerchantShop();
wxMerchantShop.setId(idWorker.nextId());
@@ -101,7 +88,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
}

//保存商户关联用户
List<Long> useridlist = JSONArray.parseArray(userids, Long.class);
List<Long> useridlist = JSONArray.parseArray(wxMerchant.getUserids(), Long.class);
for(Long userid:useridlist){
WxMerchantBUser wxMerchantBUser = new WxMerchantBUser();
wxMerchantBUser.setId(userid);
@@ -139,7 +126,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

final IdWorker idWorker = IdWorker.get();
//保存商户商铺的关联
List<Long> shopidlist = JSONArray.parseArray(shopids, Long.class);
List<Long> shopidlist = JSONArray.parseArray(wxMerchant.getShopids(), Long.class);
for(Long shopid:shopidlist){
WxMerchantShop wxMerchantShop = new WxMerchantShop();
wxMerchantShop.setId(idWorker.nextId());
@@ -162,7 +149,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {


//保存商户关联用户
List<Long> useridlist = JSONArray.parseArray(userids, Long.class);
List<Long> useridlist = JSONArray.parseArray(wxMerchant.getUserids(), Long.class);
for(Long userid:useridlist){
WxMerchantBUser wxMerchantBUser = new WxMerchantBUser();
wxMerchantBUser.setId(userid);


+ 31
- 2
mallinkService/src/main/java/com/simple/service/impl/WxMerchantShopServiceImpl.java Просмотреть файл

@@ -1,14 +1,22 @@
package com.simple.service.impl;

import java.util.*;
import com.github.pagehelper.ISelect;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.simple.common.IdWorker;
import com.simple.domain.po.WxMerchantShop;
import com.simple.domain.po.WxShop;
import com.simple.mapper.WxMerchantShopMapper;
import com.simple.mapper.WxShopMapper;
import com.simple.service.WxMerchantShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.simple.common.IdWorker;

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

@Service
public class WxMerchantShopServiceImpl implements WxMerchantShopService {
@@ -16,12 +24,33 @@ public class WxMerchantShopServiceImpl implements WxMerchantShopService {
@Autowired
WxMerchantShopMapper wxMerchantShopMapper;

@Autowired
WxShopMapper wxShopMapper;


@Override
public PageInfo<WxMerchantShop> listAsPage(WxMerchantShop record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantShopMapper.findList(record));
}

@Override
public PageInfo<WxShop> queryShopList(WxMerchantShop record, Integer pageIndex, Integer pageSize) {
List<WxShop> resultlist=new ArrayList<>();

List<WxMerchantShop> merchantShops = wxMerchantShopMapper.findList(record);
for(WxMerchantShop merchantShop:merchantShops){
WxShop wxShop = new WxShop();
wxShop.setId(merchantShop.getShopId());
List<WxShop> shopList = wxShopMapper.findList(wxShop);
if(shopList.size()>0){
resultlist.add(shopList.get(0));
}
}
PageHelper.startPage(pageIndex, pageSize);
PageInfo<WxShop> pageInfo = new PageInfo<>(resultlist);
return pageInfo;
}

@Override
public WxMerchantShop getById(Long id) {
return wxMerchantShopMapper.selectByPrimaryKey(id);


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