Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -86,14 +86,30 @@ public class BookLabelAndMarketController {
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateLabel")
|
||||
public R saveOrUpdateLabel(@RequestBody ShopProductBookLabel label) {
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
if (label.getIsLast()==1){
|
||||
labelService.saveOrUpdate(label);
|
||||
return R.ok().put("result",label);
|
||||
}else {
|
||||
return R.error("父标签非最后一集");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delLabel")
|
||||
public R delLabel(String id) {
|
||||
labelService.removeById(id);
|
||||
return R.ok();
|
||||
ShopProductBookLabel label = labelService.getById(id);
|
||||
if (label.getIsLast()==1){
|
||||
MPJLambdaWrapper<ShopProductToBookLabel> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ShopProductToBookLabel::getBookLabelId,id);
|
||||
List<ShopProductToBookLabel> tolables = toLabelService.list(wrapper);
|
||||
if (tolables.size()>0){
|
||||
return R.error("请先移除商品");
|
||||
}else {
|
||||
labelService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
return R.error("请先删除子集,设置成最后一集");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getMarketById")
|
||||
@@ -103,17 +119,53 @@ public class BookLabelAndMarketController {
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateMarket")
|
||||
public R saveOrUpdateMarket(@RequestBody ShopProductBookMarket market) {
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
if (market.getIsLast()==1){
|
||||
marketService.saveOrUpdate(market);
|
||||
return R.ok().put("result",market);
|
||||
}else {
|
||||
return R.error("父标签非最后一集");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delMarket")
|
||||
public R delMarket(String id) {
|
||||
marketService.removeById(id);
|
||||
return R.ok();
|
||||
ShopProductBookMarket market = marketService.getById(id);
|
||||
if (market.getIsLast()==1){
|
||||
MPJLambdaWrapper<ShopProductToBookMarket> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(ShopProductToBookMarket::getBookMarketId,id);
|
||||
List<ShopProductToBookMarket> tomarkets = toMarketService.list(wrapper);
|
||||
if (tomarkets.size()>0){
|
||||
return R.error("请先移除商品");
|
||||
}else {
|
||||
marketService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
return R.error("请先删除子集,设置成最后一集");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取未关联商品列表
|
||||
*/
|
||||
@RequestMapping("/getNotToLabelList")
|
||||
public R getNotToLabelList(@RequestBody Map params){
|
||||
LambdaQueryWrapper<ShopProduct> wrapper = new LambdaQueryWrapper();
|
||||
if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){
|
||||
wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString());
|
||||
}
|
||||
if (params.containsKey("bookLabelId")&&!"".equals(params.get("bookLabelId").toString())){
|
||||
String sql = "select product_id from shop_product_to_book_label where del_flag = 0 and book_label_id = "+params.get("bookLabelId");
|
||||
wrapper.notInSql(ShopProduct::getProductId,sql);
|
||||
}
|
||||
if (params.containsKey("bookMarketId")&&!"".equals(params.get("bookMarketId").toString())){
|
||||
String sql = "select product_id from shop_product_to_book_market where del_flag = 0 and book_market_id = "+params.get("bookMarketId");
|
||||
wrapper.notInSql(ShopProduct::getProductId,sql);
|
||||
}
|
||||
Page<ShopProduct> page = productService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取书标签列表
|
||||
@@ -126,6 +178,9 @@ public class BookLabelAndMarketController {
|
||||
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
|
||||
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
|
||||
}
|
||||
if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){
|
||||
wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString());
|
||||
}
|
||||
if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){
|
||||
wrapper.eq(ShopProductToBookLabel::getProductId,params.get("productId").toString());
|
||||
}
|
||||
@@ -156,6 +211,9 @@ public class BookLabelAndMarketController {
|
||||
if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){
|
||||
wrapper.like(ShopProduct::getProductName,params.get("productName").toString());
|
||||
}
|
||||
if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){
|
||||
wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString());
|
||||
}
|
||||
if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){
|
||||
wrapper.eq(ShopProductToBookMarket::getProductId,params.get("productId").toString());
|
||||
}
|
||||
@@ -177,9 +235,6 @@ public class BookLabelAndMarketController {
|
||||
|
||||
@RequestMapping(path = "/saveToLabel")
|
||||
public R saveToLabel(@RequestBody Map params) {
|
||||
LambdaQueryWrapper<ShopProductToBookLabel> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopProductToBookLabel::getBookLabelId,params.get("bookLabelId").toString());
|
||||
toLabelService.remove(wrapper);
|
||||
if (!StringUtils.isEmpty(params.get("productId").toString())){
|
||||
String[] ids = params.get("productId").toString().split(",");
|
||||
if (ids.length > 0) {
|
||||
@@ -196,15 +251,12 @@ public class BookLabelAndMarketController {
|
||||
|
||||
@RequestMapping(path = "/saveToMarket")
|
||||
public R saveToMarket(@RequestBody Map params) {
|
||||
LambdaQueryWrapper<ShopProductToBookMarket> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ShopProductToBookMarket::getBookMarketId,params.get("bookMarketId").toString());
|
||||
toMarketService.remove(wrapper);
|
||||
if (!StringUtils.isEmpty(params.get("productId").toString())){
|
||||
String[] ids = params.get("productId").toString().split(",");
|
||||
if (ids.length > 0) {
|
||||
for (String id : ids) {
|
||||
ShopProductToBookMarket toMarket = new ShopProductToBookMarket();
|
||||
toMarket.setBookMarketId(Integer.parseInt(params.get("bookLabelId").toString()));
|
||||
toMarket.setBookMarketId(Integer.parseInt(params.get("bookMarketId").toString()));
|
||||
toMarket.setProductId(Integer.parseInt(id));
|
||||
toMarketService.save(toMarket);
|
||||
}
|
||||
@@ -213,6 +265,26 @@ public class BookLabelAndMarketController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToLable")
|
||||
public R delToLable(String lableId,String productId) {
|
||||
LambdaQueryWrapper<ShopProductToBookLabel> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToBookLabel::getBookLabelId,lableId);
|
||||
wrapper.eq(ShopProductToBookLabel::getProductId,productId);
|
||||
toLabelService.remove(wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToMarket")
|
||||
public R delToMarket(String marketId,String productId) {
|
||||
LambdaQueryWrapper<ShopProductToBookMarket> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId);
|
||||
wrapper.eq(ShopProductToBookMarket::getProductId,productId);
|
||||
toMarketService.remove(wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
import com.peanut.modules.common.service.BaseAreaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 国家区域管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonBaseArea")
|
||||
@RequestMapping("common/baseArea")
|
||||
public class BaseAreaController {
|
||||
|
||||
@Autowired
|
||||
private BaseAreaService baseAreaService;
|
||||
|
||||
/**
|
||||
* 添加区域
|
||||
* @param baseArea
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addBaseArea")
|
||||
public R addBaseArea(@RequestBody BaseAreaEntity baseArea){
|
||||
baseAreaService.save(baseArea);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/delBaseArea")
|
||||
public R delBaseArea(@RequestBody Map<String,Object> map){
|
||||
Integer areaId = Integer.valueOf(map.get("areaId").toString());
|
||||
baseAreaService.removeById(areaId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑区域信息
|
||||
* @param baseArea
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/editBaseArea")
|
||||
public R editBaseArea(@RequestBody BaseAreaEntity baseArea){
|
||||
baseAreaService.updateById(baseArea);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域列表
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBaseAreas")
|
||||
public R getBaseAreas(@RequestBody Map<String,Object> map){
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
|
||||
Page baseAreas = baseAreaService.getBaseAreas(limit, page);
|
||||
return R.ok().put("page",baseAreas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部国家领域
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getAllBaseArea")
|
||||
public R getAllBaseArea(){
|
||||
List<BaseAreaEntity> list = baseAreaService.list();
|
||||
return R.ok().put("baseAreas",list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.HttpsUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ExpressCompany;
|
||||
import com.peanut.modules.common.entity.ExpressOrder;
|
||||
import com.peanut.modules.common.service.ExpressCompanyService;
|
||||
import com.peanut.modules.common.service.ExpressOrderService;
|
||||
import com.peanut.modules.common.to.ExpressPrintDto;
|
||||
import com.peanut.modules.common.vo.ExpressCompanyCommonVo;
|
||||
import com.peanut.modules.common.vo.PrintTemplateVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 快递
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonExpress")
|
||||
@RequestMapping("common/express")
|
||||
public class ExpressController {
|
||||
|
||||
@Autowired
|
||||
private ExpressCompanyService expressCompanyService;
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getExpressCompanyList", method = RequestMethod.GET)
|
||||
public R getExpressCompanyList() {
|
||||
List<ExpressCompanyCommonVo> expressCompanyList = expressCompanyService.getExpressCompanyList();
|
||||
return R.ok().put("result",expressCompanyList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取面单列表
|
||||
* @param expressPrintDto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getExpressPrints")
|
||||
public R getExpressPrints(@RequestBody ExpressPrintDto expressPrintDto) throws IOException {
|
||||
LambdaQueryWrapper<ExpressOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(StringUtils.isNotBlank(expressPrintDto.getExpressOrderSn()),ExpressOrder::getExpressOrderSn,expressPrintDto.getExpressOrderSn());
|
||||
if(expressPrintDto.getDate()!=null&&expressPrintDto.getDate()!=""){
|
||||
String startDate = expressPrintDto.getDate()+" 00:00:00";
|
||||
String endDate = expressPrintDto.getDate()+" 23:59:59";
|
||||
wrapper.between(ExpressOrder::getCreateTime,startDate,endDate);
|
||||
}
|
||||
wrapper.eq(expressPrintDto.getType()!=0,ExpressOrder::getTemplatePrinted,expressPrintDto.getType()==1?1:0);
|
||||
wrapper.orderByDesc(ExpressOrder::getCreateTime);
|
||||
Page<ExpressOrder> expressOrderPage = expressOrderService.getBaseMapper().selectPage(new Page<>(expressPrintDto.getPage(), expressPrintDto.getLimit()), wrapper);
|
||||
for (ExpressOrder e :expressOrderPage.getRecords()){
|
||||
if(e.getPrintTemplate()!=null){
|
||||
String c_string = HttpsUtil.getHttps(e.getPrintTemplate());
|
||||
e.setPrintString(c_string);
|
||||
}
|
||||
}
|
||||
return R.ok().put("page",expressOrderPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取快递面单列表(废弃)
|
||||
*
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getPrintTemplateList", method = RequestMethod.GET)
|
||||
public R getPrintTemplate(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||
Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
int totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalPage = totalDataSize / pageSize + 1;
|
||||
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
|
||||
List<ExpressOrder> expressOrderList = page.getRecords();
|
||||
List<PrintTemplateVo> data = new ArrayList<>();
|
||||
for (ExpressOrder expressOrder : expressOrderList) {
|
||||
PrintTemplateVo vo = new PrintTemplateVo();
|
||||
QueryWrapper<ExpressCompany> expressCompanyQueryWrapper = new QueryWrapper<>();
|
||||
expressCompanyQueryWrapper.eq("code", expressOrder.getExpressCompanyCode());
|
||||
ExpressCompany expressCompany = expressCompanyService.getOne(expressCompanyQueryWrapper);
|
||||
vo.setExpressCompanyCode(expressCompany.getName());
|
||||
vo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
vo.setExpressOrderSn(expressOrder.getExpressOrderSn());
|
||||
vo.setTemplatedPrinted(vo.getTemplatedPrinted());
|
||||
data.add(vo);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", data);
|
||||
result.put("currentPage", currentPage);
|
||||
result.put("pageSize", pageSize);
|
||||
result.put("totalDataSize", totalDataSize);
|
||||
result.put("totalPage", totalPage);
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/printTemplate", method = RequestMethod.POST)
|
||||
public R printTemplate(@RequestBody List<Integer> expressOrderIdList) {
|
||||
UpdateWrapper<ExpressOrder> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("template_printed", 1);
|
||||
updateWrapper.in("id", expressOrderIdList);
|
||||
expressOrderService.update(updateWrapper);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 省市区管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonProvince")
|
||||
@RequestMapping("common/province")
|
||||
public class ProvinceController {
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
//获取地址
|
||||
@RequestMapping("/getProvince")
|
||||
public R getProvince() {
|
||||
//优化查询速度 目录放入redis中
|
||||
String s = redisTemplate.opsForValue().get("Province");
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
List<Object> redisData = JSONArray.parseArray(s);
|
||||
for (Object object : redisData) {
|
||||
Map<String, Object> ret = (Map<String, Object>) object;//取出list里面的值转为map
|
||||
listData.add(ret);
|
||||
}
|
||||
return R.ok().put("provinceEntity", listData);
|
||||
}
|
||||
List<Province> provinceList = provinceService.getCity();
|
||||
redisTemplate.opsForValue().set("Province", JSON.toJSONString(provinceList));
|
||||
return R.ok().put("provinceEntity", provinceList);
|
||||
}
|
||||
|
||||
//获取省列表
|
||||
@RequestMapping("/getProvinceList")
|
||||
public R getProvinceList() {
|
||||
List<Province> provinceList = provinceService.getBaseMapper().selectList(new QueryWrapper<Province>());
|
||||
return R.ok().put("provinceList", provinceList);
|
||||
}
|
||||
|
||||
//获取市列表
|
||||
@RequestMapping("/getCityList")
|
||||
public R getCityList(@RequestParam("provId") Integer provId) {
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", provId));
|
||||
return R.ok().put("prov", prov);
|
||||
}
|
||||
|
||||
//获取区列表
|
||||
@RequestMapping("/getCountyList")
|
||||
public R getCountyList(@RequestParam("cityId") Integer cityId) {
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", cityId));
|
||||
return R.ok().put("countyList", countyList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.service.UserAddressService;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收货地址管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("commonUserAddress")
|
||||
@RequestMapping("common/userAddress")
|
||||
public class UserAddressController {
|
||||
|
||||
@Autowired
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*/
|
||||
@RequestMapping("/info/{addressId}")
|
||||
public R info(@PathVariable("addressId") Integer addressId) {
|
||||
UserAddress userAddress = userAddressService.getById(addressId);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
return R.ok().put("result", vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
// 判断是否已经有默认的地址了
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
if(userAddress.getRegionCode()==null||userAddress.getRegionCode().equals("")){
|
||||
return R.error("地址异常添加失败!");
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
return R.error("信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
userAddressService.save(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserAddress userAddress) {
|
||||
LambdaQueryWrapper<UserAddress> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(UserAddress::getId,userAddress.getId());
|
||||
wrapper.eq(UserAddress::getIsDefault,1);
|
||||
UserAddress ua = userAddressService.getOne(wrapper);
|
||||
if (ua == null){
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
return R.error("信息中不能含有“+”、“&”符号!");
|
||||
}
|
||||
userAddressService.updateById(userAddress);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户地址
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.GET)
|
||||
public R delete(@RequestParam("id") Integer id) {
|
||||
userAddressService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户收货地址列表
|
||||
*/
|
||||
@RequestMapping("/getUserAddress")
|
||||
public R getUserAddress(@RequestParam("userId") Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.orderByDesc("is_default");
|
||||
List<UserAddress> userAddressList = userAddressService.list(queryWrapper);
|
||||
List<UserAddressVo> result = new ArrayList<>();
|
||||
for (UserAddress userAddress : userAddressList) {
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
BeanUtil.copyProperties(userAddress, vo);
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("list", result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,294 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.MD5Utils;
|
||||
import com.peanut.common.utils.MailUtil;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import com.peanut.modules.sys.service.SysUserTokenService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 用户登陆注册验证码
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RestController("commonUser")
|
||||
@RequestMapping("common/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private MyUserService userService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
|
||||
/**
|
||||
* 常规注册 发短信验证码
|
||||
*/
|
||||
@RequestMapping("/sms/sendcode")
|
||||
public R registerSms(@RequestParam("phone") String phone, @RequestParam(required = false) String areaCode) throws Exception {
|
||||
int areacode=0;
|
||||
if(areaCode==null||areaCode.equals("")){
|
||||
areacode=0;
|
||||
}else{
|
||||
areacode = Integer.valueOf(areaCode);
|
||||
}
|
||||
//验证一分钟内是否已经发过
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
|
||||
if (!StringUtils.isEmpty(redisCode)) {
|
||||
long l = Long.parseLong(redisCode.split("_")[1]);
|
||||
if (System.currentTimeMillis() - l < 60000) {
|
||||
//60s 内不能再发
|
||||
return R.error(500,"短信验证码频率过高,请稍后再试!");
|
||||
}
|
||||
}
|
||||
//生成随机五位数
|
||||
Random random = new Random();
|
||||
String i = random.nextInt(99999) + "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int j = 0; j < 5 - i.length(); j++) {
|
||||
sb.append("0");
|
||||
}
|
||||
i = sb.toString() + i;
|
||||
String code = i + "_"+System.currentTimeMillis();
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+phone,code,5, TimeUnit.MINUTES);
|
||||
//发送
|
||||
userService.sendCodeForRegister(phone,code,areacode);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规注册 发送邮箱验证码
|
||||
*/
|
||||
@RequestMapping("/getMailCaptcha")
|
||||
public R getMailCaptcha(String email){
|
||||
//验证一分钟内是否已经发过
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + email);
|
||||
if (!StringUtils.isEmpty(redisCode)) {
|
||||
long l = Long.parseLong(redisCode.split("_")[1]);
|
||||
if (System.currentTimeMillis() - l < 60000) {
|
||||
//60s 内不能再发
|
||||
return R.error(500,"验证码频率过高,请稍后再试!");
|
||||
}
|
||||
}
|
||||
//生成随机五位数
|
||||
Random random = new Random();
|
||||
String code = random.nextInt(99999) + "";
|
||||
String timeCode = code + "_"+System.currentTimeMillis();
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+email,timeCode,5, TimeUnit.MINUTES);
|
||||
//发送
|
||||
return MailUtil.sendMail("疯子读书邮箱验证码",code,email);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定电话号
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updateUserTel")
|
||||
public R updateUserTel(@RequestBody Map<String,Object> map){
|
||||
String phone = map.get("phone").toString();
|
||||
String code = map.get("code").toString();
|
||||
Integer id = Integer.valueOf(map.get("id").toString());
|
||||
//查询是否存在当前手机号
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MyUserEntity::getTel,phone);
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode"+phone);
|
||||
if(StringUtils.isEmpty(redisCode)){
|
||||
return R.error("验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error("短信验证码不符!");
|
||||
}
|
||||
MyUserEntity userInfo = userService.getById(id);
|
||||
userInfo.setTel(phone);
|
||||
userService.updateById(userInfo);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("手机号已被绑定!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定邮箱
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updateUserEmail")
|
||||
public R updateUserEmail(@RequestBody Map<String,Object> map){
|
||||
String email = map.get("email").toString();
|
||||
String code = map.get("code").toString();
|
||||
Integer id = Integer.valueOf(map.get("id").toString());
|
||||
//查询是否存在当前邮箱
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(MyUserEntity::getEmail,email);
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode"+email);
|
||||
if(StringUtils.isEmpty(redisCode)){
|
||||
return R.error("验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error("验证码不符!");
|
||||
}
|
||||
MyUserEntity userInfo = userService.getById(id);
|
||||
userInfo.setEmail(email);
|
||||
userService.updateById(userInfo);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("邮箱已被绑定!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码注册或登录
|
||||
*/
|
||||
@RequestMapping("/registerOrLogin")
|
||||
public R register(String tel, String code) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + tel);
|
||||
System.out.println(redisCode);
|
||||
if (StringUtils.isEmpty(redisCode)){
|
||||
return R.error(500,"验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error(500,"验证码不符!");
|
||||
}
|
||||
//查询是否存在当前用户
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
if (tel.contains("@")){
|
||||
wrapper.eq(MyUserEntity::getEmail,tel);
|
||||
}else {
|
||||
wrapper.eq(MyUserEntity::getTel,tel);
|
||||
}
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
// 用户不存在则创建用户 注册成功
|
||||
MyUserEntity myUserEntity = new MyUserEntity();
|
||||
if (tel.contains("@")){
|
||||
myUserEntity.setEmail(tel);
|
||||
}else {
|
||||
myUserEntity.setTel(tel);
|
||||
}
|
||||
userService.save(myUserEntity);
|
||||
R r = sysUserTokenService.createToken(myUserEntity.getId());
|
||||
return R.ok("注册成功").put("userInfo",myUserEntity).put("token",r);
|
||||
}else {
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
return R.ok("登录成功!").put("userInfo",userEntity).put("token",r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
*/
|
||||
@RequestMapping("/login")
|
||||
public R login(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password) {
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper();
|
||||
if (phone.contains("@")) {
|
||||
wrapper.eq(MyUserEntity::getEmail,phone);
|
||||
}else {
|
||||
wrapper.eq(MyUserEntity::getTel,phone);
|
||||
}
|
||||
//防止多账号报错
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
return R.error(500,"用户不存在!");
|
||||
}else {
|
||||
if (userEntity.getPassword() == null|| userEntity.getPassword().equals("")) {
|
||||
return R.error(500,"当前未设置密码,请使用验证码登录!");
|
||||
}else {
|
||||
if (MD5Utils.getSaltverifyMD5(password,userEntity.getPassword())){
|
||||
R r = sysUserTokenService.createToken(userEntity.getId());
|
||||
return R.ok("登陆成功!").put("userInfo",userEntity).put("token",r);
|
||||
}else {
|
||||
return R.error(500,"密码不正确,请重试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置密码
|
||||
*/
|
||||
@RequestMapping("/setPassword")
|
||||
public R setPassword(@RequestParam("phone") String phone,
|
||||
@RequestParam("password") String password,
|
||||
@RequestParam("code") String code) {
|
||||
String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone);
|
||||
System.out.println(redisCode);
|
||||
if (StringUtils.isEmpty(redisCode)){
|
||||
return R.error(500,"验证码已过期,请重试");
|
||||
}
|
||||
String lcode = redisCode.split("_")[0];
|
||||
if (!lcode.equals(code)) {
|
||||
return R.error(500,"验证码不符!");
|
||||
}
|
||||
//查询是否存在当前用户
|
||||
LambdaQueryWrapper<MyUserEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if (phone.contains("@")){
|
||||
wrapper.eq(MyUserEntity::getEmail, phone);
|
||||
}else {
|
||||
wrapper.eq(MyUserEntity::getTel, phone);
|
||||
}
|
||||
MyUserEntity userEntity = userService.getOne(wrapper);
|
||||
if (userEntity == null) {
|
||||
return R.error(500,"当前用户不存在!");
|
||||
}
|
||||
String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
userEntity.setPassword(saltMD5);
|
||||
userService.updateById(userEntity);
|
||||
return R.ok("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号验证码密码注册 -未在apipost
|
||||
*/
|
||||
// @RequestMapping("/register")
|
||||
// public R register(@RequestParam("tel") String tel,
|
||||
// @RequestParam("code") String code,
|
||||
// @RequestParam("password") String password){
|
||||
// String redisCode = redisTemplate.opsForValue().get("RegistCode" + tel);
|
||||
// if (StringUtils.isEmpty(redisCode)){
|
||||
// return R.error(500,"短信验证码已过期,请重试");
|
||||
// }
|
||||
// String lcode = redisCode.split("_")[0];
|
||||
// if (!lcode.equals(code)) {
|
||||
// return R.error(500,"短信验证码不符!");
|
||||
// }
|
||||
// MyUserEntity user = userService.getBaseMapper().selectOne(new QueryWrapper<MyUserEntity>().eq("tel", tel));
|
||||
// if(!ObjectUtil.isEmpty(user)){
|
||||
// return R.error(500,"该手机号已经注册!");
|
||||
// }
|
||||
// String saltMD5 = MD5Utils.getSaltMD5(password);
|
||||
// MyUserEntity myUserEntity = new MyUserEntity();
|
||||
// myUserEntity.setTel(tel);
|
||||
// myUserEntity.setPassword(saltMD5);
|
||||
// userService.save(myUserEntity);
|
||||
// R r = sysUserTokenService.createToken(myUserEntity.getId());
|
||||
// return R.ok("注册成功").put("userInfo",myUserEntity).put("token",r);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.peanut.modules.common.dao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.common.entity.ExpressCompany;
|
||||
import com.peanut.modules.book.vo.ExpressCompanyVo;
|
||||
import com.peanut.modules.common.vo.ExpressCompanyCommonVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -15,4 +15,5 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface ExpressCompanyDao extends BaseMapper<ExpressCompany> {
|
||||
List<ExpressCompanyVo> getExpressCompanyList();
|
||||
List<ExpressCompanyCommonVo> getExpressComList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
|
||||
public interface BaseAreaService extends IService<BaseAreaEntity> {
|
||||
|
||||
Page getBaseAreas(Integer limit, Integer page);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CityService extends IService<City> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CountyService extends IService<County> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ExpressCompany;
|
||||
import com.peanut.modules.common.vo.ExpressCompanyCommonVo;
|
||||
import java.util.List;
|
||||
|
||||
public interface ExpressCompanyService extends IService<ExpressCompany> {
|
||||
//获取快递公司列表
|
||||
List<ExpressCompanyCommonVo> getExpressCompanyList();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ExpressOrder;
|
||||
import com.peanut.modules.common.entity.ExpressQueryResponse;
|
||||
import com.peanut.modules.common.vo.ExpressOrderResponseVo;
|
||||
|
||||
public interface ExpressOrderService extends IService<ExpressOrder> {
|
||||
/**
|
||||
* 下单生成面单
|
||||
*/
|
||||
ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder);
|
||||
|
||||
ExpressQueryResponse queryExpressOrder(String ShipperCode, String LogisticCode, String customerName);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
|
||||
public interface MyUserService extends IService<MyUserEntity> {
|
||||
|
||||
void sendCodeForRegister(String phone, String code,Integer areaCode) throws Exception;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ProvinceService extends IService<Province> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<Province> getCity();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserAddressService extends IService<UserAddress> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
UserAddressVo getAddressName(UserAddressVo vo, String regionCode);
|
||||
|
||||
int getUserDefaultAddressCount(Integer userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.BaseAreaDao;
|
||||
import com.peanut.modules.common.entity.BaseAreaEntity;
|
||||
import com.peanut.modules.common.service.BaseAreaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonBaseAreaService")
|
||||
public class BaseAreaServiceImpl extends ServiceImpl<BaseAreaDao, BaseAreaEntity> implements BaseAreaService {
|
||||
|
||||
@Override
|
||||
public Page getBaseAreas(Integer limit, Integer page) {
|
||||
LambdaQueryWrapper<BaseAreaEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BaseAreaEntity::getDelFlag,0);
|
||||
Page<BaseAreaEntity> baseAreaEntityPage = getBaseMapper().selectPage(new Page<BaseAreaEntity>(page, limit), wrapper);
|
||||
return baseAreaEntityPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.CityDao;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonCityService")
|
||||
public class CityServiceImpl extends ServiceImpl<CityDao, City> implements CityService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<City> page = this.page(
|
||||
new Query<City>().getPage(params),
|
||||
new QueryWrapper<City>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.CountyDao;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonCountyService")
|
||||
public class CountyServiceImpl extends ServiceImpl<CountyDao, County> implements CountyService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<County> page = this.page(
|
||||
new Query<County>().getPage(params),
|
||||
new QueryWrapper<County>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.ExpressCompanyDao;
|
||||
import com.peanut.modules.common.entity.ExpressCompany;
|
||||
import com.peanut.modules.common.service.ExpressCompanyService;
|
||||
import com.peanut.modules.common.vo.ExpressCompanyCommonVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonExpressCompanyService")
|
||||
public class ExpressCompanyServiceImpl extends ServiceImpl<ExpressCompanyDao, ExpressCompany> implements ExpressCompanyService {
|
||||
|
||||
@Autowired
|
||||
private ExpressCompanyDao expressCompanyDao;
|
||||
|
||||
@Override
|
||||
public List<ExpressCompanyCommonVo> getExpressCompanyList() {
|
||||
return expressCompanyDao.getExpressComList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.HttpClientUtils;
|
||||
import com.peanut.common.utils.KdUtils;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.modules.common.dao.ExpressOrderDao;
|
||||
import com.peanut.modules.common.entity.ExpressCommodity;
|
||||
import com.peanut.modules.common.entity.ExpressOrder;
|
||||
import com.peanut.modules.common.entity.ExpressQueryResponse;
|
||||
import com.peanut.modules.common.service.ExpressOrderService;
|
||||
import com.peanut.modules.common.vo.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonExpressOrderService")
|
||||
public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, ExpressOrder> implements ExpressOrderService {
|
||||
|
||||
@Value("${express.sender.senderName}")
|
||||
private String senderName;
|
||||
@Value("${express.sender.mobile}")
|
||||
private String senderMobile;
|
||||
@Value("${express.sender.provinceName}")
|
||||
private String senderProvinceName;
|
||||
@Value("${express.sender.cityName}")
|
||||
private String senderCityName;
|
||||
@Value("${express.sender.expAreaName}")
|
||||
private String senderExpAreaName;
|
||||
@Value("${express.sender.address}")
|
||||
private String senderAddress;
|
||||
|
||||
|
||||
@Override
|
||||
public ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder) {
|
||||
ExpressOrderRequestVo orderRequestVo = new ExpressOrderRequestVo();
|
||||
// 订单号
|
||||
orderRequestVo.setOrderCode(expressOrder.getOrderSn());
|
||||
orderRequestVo.setIsReturnPrintTemplate(1);
|
||||
orderRequestVo.setShipperCode(expressOrder.getExpressCompanyCode());
|
||||
orderRequestVo.setPayType(3);
|
||||
if (expressOrder.getExpressCompanyCode().equals(Constants.EXPRESS_COMPANY_CODE_SF)) {
|
||||
orderRequestVo.setMonthCode(Constants.EXPRESS_SF_MONTH_CODE);
|
||||
//如果是顺丰港澳台,参数多两个必填CurrencyCode、Dutiable.DeclaredValue
|
||||
if ("台湾省".equals(expressOrder.getProvince())||
|
||||
"香港特别行政区".equals(expressOrder.getProvince())||
|
||||
"澳门特别行政区".equals(expressOrder.getProvince())){
|
||||
orderRequestVo.setCurrencyCode("CNY");
|
||||
BigDecimal declaredValue = new BigDecimal(0);
|
||||
if (expressOrder.getCommodity().size()>0){
|
||||
for (ExpressCommodity commodity : expressOrder.getCommodity()) {
|
||||
BigDecimal quantity = BigDecimal.valueOf(commodity.getGoodsquantity());
|
||||
BigDecimal price = BigDecimal.valueOf(commodity.getGoodsPrice());
|
||||
BigDecimal total = quantity.multiply(price);
|
||||
declaredValue = declaredValue.add(total);
|
||||
}
|
||||
}
|
||||
DutiableVo dutiable = new DutiableVo();
|
||||
dutiable.setDeclaredValue(declaredValue.setScale(3));
|
||||
orderRequestVo.setDutiable(dutiable);
|
||||
}
|
||||
}
|
||||
if (expressOrder.getExpressCompanyCode().equals(Constants.EXPRESS_COMPANY_CODE_YD)) {
|
||||
orderRequestVo.setCustomerName(Constants.EXPRESS_YD_CUSTOMER_NAME);
|
||||
orderRequestVo.setCustomerPwd(Constants.EXPRESS_YD_CUSTOMER_PWD);
|
||||
}
|
||||
orderRequestVo.setExpType(231);//1特快2标快
|
||||
orderRequestVo.setCost(expressOrder.getExpressFee().doubleValue());
|
||||
// 发货人
|
||||
ExpressUserInfoVo sender = new ExpressUserInfoVo();
|
||||
sender.setName(senderName);
|
||||
sender.setMobile(senderMobile);
|
||||
sender.setProvinceName(senderProvinceName);
|
||||
sender.setCityName(senderCityName);
|
||||
sender.setExpAreaName(senderExpAreaName);
|
||||
sender.setAddress(senderAddress);
|
||||
// 收货人
|
||||
ExpressUserInfoVo receiver = new ExpressUserInfoVo();
|
||||
receiver.setName(expressOrder.getConsigneeName());
|
||||
receiver.setMobile(expressOrder.getConsigneeMobile());
|
||||
receiver.setProvinceName(expressOrder.getProvince());
|
||||
receiver.setCityName(expressOrder.getCity());
|
||||
receiver.setExpAreaName(expressOrder.getCounty());
|
||||
receiver.setAddress(expressOrder.getAddress());
|
||||
orderRequestVo.setSender(sender);
|
||||
orderRequestVo.setReceiver(receiver);
|
||||
orderRequestVo.setCommodity(expressOrder.getCommodity());
|
||||
orderRequestVo.setWeight(expressOrder.getTotalWeight().doubleValue());
|
||||
orderRequestVo.setRemark(expressOrder.getRemark());
|
||||
orderRequestVo.setTemplateSize("150");
|
||||
String requestData = JSONObject.toJSONString(orderRequestVo);
|
||||
//如果是顺丰港澳台,参数多两个必填CurrencyCode、Dutiable.DeclaredValue,需要大写
|
||||
String requestDataUpperCase = requestData;
|
||||
if (requestData.contains("currencyCode")){
|
||||
requestDataUpperCase = requestData.replace("currencyCode","CurrencyCode")
|
||||
.replace("dutiable","Dutiable")
|
||||
.replace("declaredValue","DeclaredValue");
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", requestDataUpperCase);
|
||||
params.put("EBusinessID", Constants.EXPRESS_BUSINESS_ID);
|
||||
params.put("RequestType", Constants.EXPRESS_REQUEST_TYPE_PLACE_ORDER);
|
||||
try {
|
||||
String dataSign = KdUtils.encrypt(requestDataUpperCase, Constants.EXPRESS_API_KEY, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
params.put("DataType", "2");
|
||||
|
||||
String response = HttpClientUtils.kdSendPost(Constants.EXPRESS_PLACE_ORDER_URL, params);
|
||||
return JSONObject.parseObject(response, ExpressOrderResponseVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressQueryResponse queryExpressOrder(String shipperCode, String logisticCode, String customerName) {
|
||||
ExpressQueryRequestVo requestVo = new ExpressQueryRequestVo();
|
||||
requestVo.setLogisticCode(logisticCode);
|
||||
requestVo.setCustomerName(customerName);
|
||||
requestVo.setShipperCode(shipperCode);
|
||||
String requestData = JSONObject.toJSONString(requestVo);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", requestData);
|
||||
params.put("EBusinessID", Constants.EXPRESS_BUSINESS_ID);
|
||||
params.put("RequestType", Constants.EXPRESS_REQUEST_TYPE_QUERY);
|
||||
try {
|
||||
String dataSign = KdUtils.encrypt(requestData, Constants.EXPRESS_API_KEY, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
params.put("DateType", "2");
|
||||
String response = HttpClientUtils.kdSendPost(Constants.EXPRESS_QUERY_URL, params);
|
||||
return JSONObject.parseObject(response, ExpressQueryResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.Common;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.app.config.SMSConfig;
|
||||
import com.peanut.modules.app.config.Sample;
|
||||
import com.peanut.modules.common.dao.MyUserDao;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.service.MyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service("myUserService")
|
||||
public class MyUserServiceImpl extends ServiceImpl<MyUserDao, MyUserEntity> implements MyUserService {
|
||||
|
||||
@Autowired
|
||||
private SMSConfig smsConfig;
|
||||
|
||||
@Override
|
||||
public void sendCodeForRegister(String phone, String code, Integer areaCode) throws Exception {
|
||||
String scode = code.split("_")[0];
|
||||
sendCode(phone,scode,areaCode);
|
||||
}
|
||||
|
||||
private void sendCode(String phone, String code, Integer areaCode) throws Exception {
|
||||
com.aliyun.dysmsapi20170525.Client client = Sample.createClient(smsConfig.getAccessKeyId(),smsConfig.getAccessKeySecret());
|
||||
String tem;
|
||||
if(areaCode!=null&&areaCode>0&&areaCode!=86){
|
||||
tem = smsConfig.getSTemplateCode();
|
||||
phone = areaCode+phone;
|
||||
}else{
|
||||
tem = smsConfig.getTemplateCode();
|
||||
}
|
||||
SendSmsRequest sendSmsRequest = new SendSmsRequest()
|
||||
.setSignName(smsConfig.getSingName())
|
||||
.setTemplateCode(tem)
|
||||
.setPhoneNumbers(phone)
|
||||
.setTemplateParam("{\"code\":\""+ code +"\"}");
|
||||
RuntimeOptions runtime = new RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||
System.out.println(body.getMessage());
|
||||
} catch (TeaException error) {
|
||||
// 如有需要,请打印 error
|
||||
Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 如有需要,请打印 error
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.ProvinceDao;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonProvinceService")
|
||||
public class ProvinceServiceImpl extends ServiceImpl<ProvinceDao, Province> implements ProvinceService {
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<Province> page = this.page(
|
||||
new Query<Province>().getPage(params),
|
||||
new QueryWrapper<Province>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Province> getCity() {
|
||||
List<Province> provinceList = this.baseMapper.selectList(new QueryWrapper<Province>());
|
||||
for (Province province:provinceList){
|
||||
List<City> prov = cityService.getBaseMapper().selectList(new QueryWrapper<City>()
|
||||
.eq("prov_id", province.getProvId()));
|
||||
if (prov.size() > 0) {
|
||||
for (City city : prov) {
|
||||
List<County> countyList = countyService.getBaseMapper().selectList(new QueryWrapper<County>().eq("city_id", city.getCityId()));
|
||||
if (countyList != null) {
|
||||
city.setCountyList(countyList);
|
||||
}
|
||||
}
|
||||
province.setCityList(prov);
|
||||
}
|
||||
}
|
||||
return provinceList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.UserAddressDao;
|
||||
import com.peanut.modules.common.entity.City;
|
||||
import com.peanut.modules.common.entity.County;
|
||||
import com.peanut.modules.common.entity.Province;
|
||||
import com.peanut.modules.common.entity.UserAddress;
|
||||
import com.peanut.modules.common.service.CityService;
|
||||
import com.peanut.modules.common.service.CountyService;
|
||||
import com.peanut.modules.common.service.ProvinceService;
|
||||
import com.peanut.modules.common.service.UserAddressService;
|
||||
import com.peanut.modules.common.vo.UserAddressVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonUserAddressService")
|
||||
public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddress> implements UserAddressService {
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<UserAddress> page = this.page(
|
||||
new Query<UserAddress>().getPage(params),
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAddressVo getAddressName(UserAddressVo vo, String regionCode) {
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("region_code", regionCode);
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
if(county==null){
|
||||
return null;
|
||||
}
|
||||
vo.setCounty(county.getCountyName());
|
||||
LambdaQueryWrapper<City> cityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
cityLambdaQueryWrapper.eq(City::getCityId,county.getCityId());
|
||||
City city = cityService.getOne(cityLambdaQueryWrapper);
|
||||
vo.setCity(city.getCityName());
|
||||
LambdaQueryWrapper<Province> provinceLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
provinceLambdaQueryWrapper.eq(Province::getProvId,city.getProvId());
|
||||
Province province = provinceService.getOne(provinceLambdaQueryWrapper);
|
||||
vo.setProvince((province.getProvName()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
public int getUserDefaultAddressCount(Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("is_default", 1);
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.peanut.modules.common.to;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExpressPrintDto {
|
||||
|
||||
/**
|
||||
* 时间2023-10-10
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 快递订单号
|
||||
*/
|
||||
private String expressOrderSn;
|
||||
|
||||
/**
|
||||
* 类型,0不限1已打印2未打印
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private Integer limit;
|
||||
|
||||
private Integer page;
|
||||
}
|
||||
|
||||
14
src/main/java/com/peanut/modules/common/vo/DutiableVo.java
Normal file
14
src/main/java/com/peanut/modules/common/vo/DutiableVo.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 申报价值
|
||||
*/
|
||||
@Data
|
||||
public class DutiableVo {
|
||||
|
||||
private BigDecimal DeclaredValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递公司 Vo
|
||||
*/
|
||||
@Data
|
||||
public class ExpressCompanyCommonVo {
|
||||
/**
|
||||
* 快递公司名称
|
||||
*/
|
||||
private String expressName;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String expressCode;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递公司 Vo
|
||||
*/
|
||||
@Data
|
||||
public class ExpressCompanyVo {
|
||||
/**
|
||||
* 快递公司名称
|
||||
*/
|
||||
private String expressName;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String expressCode;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
|
||||
import com.peanut.modules.common.entity.ExpressCommodity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 快递请求 Value Object
|
||||
*/
|
||||
@Data
|
||||
public class ExpressOrderRequestVo {
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String OrderCode;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
/**
|
||||
* 支付类型 1 - 现付 2 - 到付 3 - 月结 4 - 第三方付
|
||||
*/
|
||||
private int payType;
|
||||
/**
|
||||
* 快递公司业务类型
|
||||
*/
|
||||
private int ExpType;
|
||||
/**
|
||||
* 月付款账号
|
||||
*/
|
||||
private String MonthCode;
|
||||
/**
|
||||
* 快递运费
|
||||
*/
|
||||
private Double Cost;
|
||||
/**
|
||||
* 其他费用
|
||||
*/
|
||||
private Double OtherCost;
|
||||
/**
|
||||
* 发货人
|
||||
*/
|
||||
private ExpressUserInfoVo Sender;
|
||||
/**
|
||||
* 收货人
|
||||
*/
|
||||
private ExpressUserInfoVo Receiver;
|
||||
/**
|
||||
* 货物信息
|
||||
*/
|
||||
private List<ExpressCommodity> Commodity;
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private Double Weight;
|
||||
/**
|
||||
* 包裹数量
|
||||
*/
|
||||
private Integer Quantity;
|
||||
/**
|
||||
* 包裹体积
|
||||
*/
|
||||
private Double Volume;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String Remark;
|
||||
/**
|
||||
* 是否返回电子面单模板
|
||||
*/
|
||||
private Integer IsReturnPrintTemplate;
|
||||
/**
|
||||
* 快递客户号
|
||||
*/
|
||||
private String CustomerName;
|
||||
/**
|
||||
* 快递客户密码
|
||||
*/
|
||||
private String CustomerPwd;
|
||||
|
||||
/**
|
||||
* 面单规格
|
||||
*/
|
||||
private String TemplateSize;
|
||||
|
||||
/**
|
||||
* 货物单价的币种:港澳台必填
|
||||
* CNY: 人民币
|
||||
* HKD: 港币
|
||||
* NTD: 新台币
|
||||
* MOP: 澳门元
|
||||
*/
|
||||
private String CurrencyCode;
|
||||
|
||||
/**
|
||||
* 申报价值
|
||||
*/
|
||||
private DutiableVo Dutiable;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递下单响应 Value Object
|
||||
*/
|
||||
@Data
|
||||
public class ExpressOrderResponseVo {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String EBusinessID;
|
||||
/**
|
||||
* 返回模板
|
||||
*/
|
||||
private String PrintTemplate;
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private boolean Success;
|
||||
/**
|
||||
* 结果响应编码
|
||||
*/
|
||||
private String ResultCode;
|
||||
/**
|
||||
* 原因
|
||||
*/
|
||||
private String Reason;
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
private ExpressResponseOrderVo Order;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递查询请求 Value Object
|
||||
*/
|
||||
@Data
|
||||
public class ExpressQueryRequestVo {
|
||||
/**
|
||||
* 快递编码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 手机尾号
|
||||
*/
|
||||
private String CustomerName;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递查询相应 Order Value Object
|
||||
*/
|
||||
@Data
|
||||
public class ExpressResponseOrderVo {
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String OrderCode;
|
||||
/**
|
||||
* 快递公司代码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
/**
|
||||
* 大头笔(官网文档)
|
||||
*/
|
||||
private String MarkDestination;
|
||||
/**
|
||||
* 签回单单号
|
||||
*/
|
||||
private String SignWaybillCode;
|
||||
/**
|
||||
* 始发地区域编码
|
||||
*/
|
||||
private String OriginCode;
|
||||
/**
|
||||
* 事发地名称
|
||||
*/
|
||||
private String OriginName;
|
||||
/**
|
||||
* 目的地区域编码
|
||||
*/
|
||||
private String DestinatioCode;
|
||||
/**
|
||||
* 目的地名称
|
||||
*/
|
||||
private String DestinatioName;
|
||||
/**
|
||||
* 分拣编码
|
||||
*/
|
||||
private String SortingCode;
|
||||
/**
|
||||
* 邮包编码
|
||||
*/
|
||||
private String PackageCode;
|
||||
/**
|
||||
* 集包地
|
||||
*/
|
||||
private String PackageName;
|
||||
/**
|
||||
* 目的地分拨
|
||||
*/
|
||||
private String DestinationAllocationCentre;
|
||||
/**
|
||||
* 配送产品类型
|
||||
*/
|
||||
private String TransType;
|
||||
/**
|
||||
* 运输方式
|
||||
*/
|
||||
private String TransportType;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递收/发件人 Value Object
|
||||
*/
|
||||
@Data
|
||||
public class ExpressUserInfoVo {
|
||||
/**
|
||||
* 公司
|
||||
*/
|
||||
private String Company;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String Name;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String Mobile;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String ProvinceName;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String cityName;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
private String ExpAreaName;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String Address;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 面单响应 value object
|
||||
*/
|
||||
@Data
|
||||
public class PrintTemplateVo {
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String expressOrderSn;
|
||||
/**
|
||||
* 面单
|
||||
*/
|
||||
private String printTemplate;
|
||||
/**
|
||||
* 快递公司代码
|
||||
*/
|
||||
private String expressCompanyCode;
|
||||
/**
|
||||
* 是否打印过
|
||||
*/
|
||||
private int templatedPrinted;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.peanut.modules.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserAddressVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* 会员 ID
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 收货人
|
||||
*/
|
||||
private String consigneeName;
|
||||
/**
|
||||
* 收货人手机号码
|
||||
*/
|
||||
private String consigneePhone;
|
||||
/**
|
||||
* 区域代码
|
||||
*/
|
||||
private String regionCode;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String detailAddress;
|
||||
/**
|
||||
* 默认
|
||||
*/
|
||||
private Integer isDefault;
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 县
|
||||
*/
|
||||
private String county;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.master.service.BuyConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充值价格表单管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterBookBuyConfig")
|
||||
@RequestMapping("master/bookBuyConfig")
|
||||
public class BuyConfigController {
|
||||
|
||||
@Autowired
|
||||
private BuyConfigService buyConfigService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = buyConfigService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{priceTypeId}")
|
||||
public R info(@PathVariable("priceTypeId") Integer priceTypeId){
|
||||
BookBuyConfigEntity bookBuyConfig = buyConfigService.getById(priceTypeId);
|
||||
return R.ok().put("bookBuyConfig", bookBuyConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BookBuyConfigEntity bookBuyConfig){
|
||||
buyConfigService.save(bookBuyConfig);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BookBuyConfigEntity bookBuyConfig){
|
||||
buyConfigService.updateById(bookBuyConfig);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] priceTypeIds){
|
||||
buyConfigService.removeByIds(Arrays.asList(priceTypeIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取VIP 金额 或者充值类型
|
||||
*/
|
||||
@RequestMapping("/getVipOrPoint")
|
||||
public R getVipOrPoint(@RequestParam("type") String type,@RequestParam("qudao") String qudao){
|
||||
List<BookBuyConfigEntity> bookBuyConfigEntities = buyConfigService.getBaseMapper().selectList(new QueryWrapper<BookBuyConfigEntity>().eq("type",type).eq("qudao",qudao));
|
||||
return R.ok().put("list",bookBuyConfigEntities);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.master.service.PayPaymentOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 充值订单表
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterPayPaymentOrder")
|
||||
@RequestMapping("master/payPaymentOrder")
|
||||
public class PayPaymentOrderController {
|
||||
|
||||
@Autowired
|
||||
private PayPaymentOrderService payPaymentOrderService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = payPaymentOrderService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
PayPaymentOrderEntity payPaymentOrder = payPaymentOrderService.getById(id);
|
||||
return R.ok().put("payPaymentOrder", payPaymentOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody PayPaymentOrderEntity payPaymentOrder){
|
||||
payPaymentOrderService.save(payPaymentOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody PayPaymentOrderEntity payPaymentOrder){
|
||||
payPaymentOrderService.updateById(payPaymentOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
payPaymentOrderService.removeByIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterShopProduct")
|
||||
@RequestMapping("master/shopProduct")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BuyConfigService extends IService<BookBuyConfigEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PayPaymentOrderService extends IService<PayPaymentOrderEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.BookBuyConfigDao;
|
||||
import com.peanut.modules.common.entity.BookBuyConfigEntity;
|
||||
import com.peanut.modules.master.service.BuyConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("buyConfigService")
|
||||
public class BuyConfigServiceImpl extends ServiceImpl<BookBuyConfigDao, BookBuyConfigEntity> implements BuyConfigService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<BookBuyConfigEntity> page = this.page(
|
||||
new Query<BookBuyConfigEntity>().getPage(params),
|
||||
new QueryWrapper<BookBuyConfigEntity>()
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.common.dao.PayPaymentOrderDao;
|
||||
import com.peanut.modules.common.entity.PayPaymentOrderEntity;
|
||||
import com.peanut.modules.master.service.PayPaymentOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterPayPaymentOrderService")
|
||||
public class PayPaymentOrderServiceImpl extends ServiceImpl<PayPaymentOrderDao, PayPaymentOrderEntity> implements PayPaymentOrderService {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<PayPaymentOrderEntity> page = this.page(
|
||||
new Query<PayPaymentOrderEntity>().getPage(params),
|
||||
new ExcludeEmptyQueryWrapper<PayPaymentOrderEntity>()
|
||||
.eq("tel",params.get("key"))
|
||||
.or().like("user_name",params.get("key")).orderByDesc("create_time")
|
||||
);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,4 +6,8 @@
|
||||
select name as expressName, code as expressCode
|
||||
from express_company
|
||||
</select>
|
||||
<select id="getExpressComList" resultType="com.peanut.modules.common.vo.ExpressCompanyCommonVo">
|
||||
select name as expressName, code as expressCode
|
||||
from express_company
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user