Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.QuerySpecDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ProductService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,9 +38,12 @@ public class ProductController {
|
||||
|
||||
@PutMapping("/productStock")
|
||||
public Result productStock(
|
||||
@RequestHeader("token") String token,
|
||||
@Valid @RequestBody ProductStockDTO productStockDTO
|
||||
) {
|
||||
productService.updateStock(productStockDTO);
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
String loginName = jsonObject.getString("loginName");
|
||||
productService.updateStock(productStockDTO,loginName);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ShopPrinterService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 16:56
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("shop-config/printer")
|
||||
public class ShopPrinterController {
|
||||
|
||||
@Resource
|
||||
private ShopPrinterService shopPrinterService;
|
||||
|
||||
@GetMapping("page")
|
||||
public Result page(@RequestParam Map<String, Object> params) {
|
||||
PageInfo<ShopPrinterDTO> page = shopPrinterService.page(params);
|
||||
return Result.success(CodeEnum.SUCCESS,page);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public Result list(@RequestParam Map<String, Object> params) {
|
||||
List<ShopPrinterDTO> list = shopPrinterService.list(params);
|
||||
return Result.success(CodeEnum.SUCCESS,list);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public Result get(@PathVariable("id") Integer id) {
|
||||
ShopPrinterDTO dto = shopPrinterService.get(id);
|
||||
return Result.success(CodeEnum.SUCCESS,dto);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Result save(@RequestBody ShopPrinterDTO dto) {
|
||||
shopPrinterService.save(dto);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Result update(@RequestBody ShopPrinterDTO dto) {
|
||||
shopPrinterService.update(dto);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
public Result delete(@PathVariable("id") Integer id){
|
||||
shopPrinterService.delete(id);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@PostMapping("update-status")
|
||||
public Result updateStatus(@RequestBody ShopPrinterDTO dto){
|
||||
shopPrinterService.updateStatus(dto.getId(),dto.getStatus());
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 17:25
|
||||
*/
|
||||
@Mapper
|
||||
public interface ShopPrinterServiceMapper {
|
||||
List<ShopPrinterDTO> getList(Map<String, Object> params);
|
||||
|
||||
int updateStatus(@Param("id") Integer id, @Param("status") Integer status);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class TbShopUser implements Serializable {
|
||||
private Integer id;
|
||||
@@ -61,6 +62,7 @@ public class TbShopUser implements Serializable {
|
||||
private Long updatedAt;
|
||||
|
||||
private String miniOpenId;
|
||||
private Date joinTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -295,4 +297,12 @@ public class TbShopUser implements Serializable {
|
||||
public void setDynamicCode(String dynamicCode) {
|
||||
this.dynamicCode = dynamicCode;
|
||||
}
|
||||
|
||||
public Date getJoinTime() {
|
||||
return joinTime;
|
||||
}
|
||||
|
||||
public void setJoinTime(Date joinTime) {
|
||||
this.joinTime = joinTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 店铺打印机配置
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 17:13
|
||||
*/
|
||||
@Data
|
||||
public class ShopPrinterDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String connectionType;
|
||||
|
||||
private String address;
|
||||
|
||||
private String port;
|
||||
|
||||
private String subType;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String shopId;
|
||||
|
||||
private String categoryIds;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private String createdAt;
|
||||
|
||||
private String updatedAt;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private String vendorId;
|
||||
|
||||
private String productId;
|
||||
private String config;
|
||||
|
||||
public String getCreatedAt() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(Long.valueOf(createdAt)));
|
||||
}
|
||||
|
||||
public String getUpdatedAt() {
|
||||
if("".equals(updatedAt) || updatedAt == null){
|
||||
return "";
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(Long.valueOf(updatedAt)));
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,7 @@ public class MemberService {
|
||||
tbShopUser.setLevel(Byte.parseByte(String.valueOf(map.get("level"))));
|
||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUser.setJoinTime(new Date());
|
||||
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
@@ -168,6 +169,7 @@ public class MemberService {
|
||||
tbShopUser.setCode(code);
|
||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
||||
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
||||
tbShopUser.setJoinTime(new Date());
|
||||
tbShopUserMapper.insert(tbShopUser);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ProductService {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStock(ProductStockDTO productStockDTO) {
|
||||
public void updateStock(ProductStockDTO productStockDTO,String loginName) {
|
||||
TbProduct product = tbProductMapper.selectByShopIdAndId(productStockDTO.getProductId(), productStockDTO.getShopId());
|
||||
if (product == null) {
|
||||
throw new MsgException("商品不存在");
|
||||
@@ -213,9 +213,16 @@ public class ProductService {
|
||||
data.put("shopId", productStockDTO.getShopId());
|
||||
data.put("skuId", tbProductSkus.isEmpty() ? null : tbProductSkus.get(0).getId());
|
||||
data.put("productId", productStockDTO.getProductId());
|
||||
data.put("type", "pc收银机修改库存");
|
||||
// data.put("type", "pc收银机修改库存");
|
||||
data.put("subType", product.getStockNumber() > productStockDTO.getStock() ? -1 : 1);
|
||||
data.put("number", productStockDTO.getStock() - product.getStockNumber());
|
||||
data.put("operator", loginName);
|
||||
data.put("remark", "pc收银机修改库存");
|
||||
if (product.getStockNumber() > productStockDTO.getStock()) {
|
||||
data.put("type", "盘点出库");
|
||||
}else {
|
||||
data.put("type", "盘点入库");
|
||||
}
|
||||
producer.sendStockRecordMsg(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 打印机配置
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 17:15
|
||||
*/
|
||||
public interface ShopPrinterService {
|
||||
|
||||
PageInfo<ShopPrinterDTO> page(Map<String, Object> params);
|
||||
|
||||
List<ShopPrinterDTO> list(Map<String, Object> params);
|
||||
|
||||
ShopPrinterDTO get(Integer id);
|
||||
|
||||
void save(ShopPrinterDTO dto);
|
||||
|
||||
void update(ShopPrinterDTO dto);
|
||||
|
||||
void delete(Integer id);
|
||||
|
||||
void updateStatus(Integer id,Integer status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.map.MapProxy;
|
||||
import com.chaozhanggui.system.cashierservice.dao.ShopPrinterServiceMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPrintMachineMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachineWithBLOBs;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ShopPrinterService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 店铺打印配置
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-24 17:23
|
||||
*/
|
||||
@Service
|
||||
public class ShopPrinterServiceImpl implements ShopPrinterService {
|
||||
|
||||
@Resource
|
||||
private ShopPrinterServiceMapper shopPrinterServiceMapper;
|
||||
|
||||
@Resource
|
||||
private TbPrintMachineMapper tbPrintMachineMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<ShopPrinterDTO> page(Map<String, Object> params) {
|
||||
MapProxy mapProxy = MapProxy.create(params);
|
||||
Integer pageNum = mapProxy.getInt("pageNum");
|
||||
Integer pageSize = mapProxy.getInt("pageSize");
|
||||
PageInfo<ShopPrinterDTO> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> shopPrinterServiceMapper.getList(params));
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopPrinterDTO> list(Map<String, Object> params) {
|
||||
return shopPrinterServiceMapper.getList(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopPrinterDTO get(Integer id) {
|
||||
TbPrintMachineWithBLOBs entity = tbPrintMachineMapper.selectByPrimaryKey(id);
|
||||
return BeanUtil.toBean(entity, ShopPrinterDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ShopPrinterDTO dto) {
|
||||
TbPrintMachineWithBLOBs entity = new TbPrintMachineWithBLOBs();
|
||||
BeanUtil.copyProperties(dto, entity, "createdAt", "updatedAt");
|
||||
entity.setCreatedAt(System.currentTimeMillis());
|
||||
entity.setUpdatedAt(System.currentTimeMillis());
|
||||
tbPrintMachineMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ShopPrinterDTO dto) {
|
||||
TbPrintMachineWithBLOBs entity = tbPrintMachineMapper.selectByPrimaryKey(dto.getId());
|
||||
BeanUtil.copyProperties(dto, entity, "createdAt", "updatedAt");
|
||||
entity.setUpdatedAt(System.currentTimeMillis());
|
||||
tbPrintMachineMapper.updateByPrimaryKeyWithBLOBs(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Integer id) {
|
||||
tbPrintMachineMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Integer id, Integer status) {
|
||||
shopPrinterServiceMapper.updateStatus(id, status);
|
||||
}
|
||||
}
|
||||
65
src/main/resources/mapper/ShopPrinterMapper.xml
Normal file
65
src/main/resources/mapper/ShopPrinterMapper.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.ShopPrinterServiceMapper">
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, name, type, connection_type, address, port, sub_type, status, shop_id, category_ids, content_type, created_at, updated_at, sort, vendor_id, product_id
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
config, category_list
|
||||
</sql>
|
||||
|
||||
<select id="getList" resultType="com.chaozhanggui.system.cashierservice.entity.dto.ShopPrinterDTO">
|
||||
select
|
||||
<include refid="Base_Column_List" />,
|
||||
<include refid="Blob_Column_List" />
|
||||
from tb_print_machine
|
||||
where shop_id = #{shopId}
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat(#{name}, '%')
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="connectionType != null and connectionType != ''">
|
||||
and connection_type = #{connectionType}
|
||||
</if>
|
||||
<if test="address != null and address != ''">
|
||||
and address = #{address}
|
||||
</if>
|
||||
<if test="port != null and port != ''">
|
||||
and port = #{port}
|
||||
</if>
|
||||
<if test="subType != null and subType != ''">
|
||||
and sub_type = #{subType}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="categoryIds != null and categoryIds != ''">
|
||||
and category_ids = #{categoryIds}
|
||||
</if>
|
||||
<if test="contentType != null and contentType != ''">
|
||||
and content_type = #{contentType}
|
||||
</if>
|
||||
<if test="config != null and config != ''">
|
||||
and config = #{config}
|
||||
</if>
|
||||
<if test="categoryList != null and categoryList != ''">
|
||||
and category_list = #{categoryList}
|
||||
</if>
|
||||
<if test="vendorId != null and vendorId != ''">
|
||||
and vendor_id = #{vendorId}
|
||||
</if>
|
||||
<if test="productId != null and productId != ''">
|
||||
and product_id = #{productId}
|
||||
</if>
|
||||
order by sort asc,id desc
|
||||
</select>
|
||||
|
||||
<update id="updateStatus">
|
||||
update tb_print_machine set status = #{status} where id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -32,12 +32,13 @@
|
||||
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
|
||||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
||||
<result column="mini_open_id" jdbcType="VARCHAR" property="miniOpenId" />
|
||||
<result column="join_time" jdbcType="VARCHAR" property="joinTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, amount, credit_amount, consume_amount, consume_number, level_consume, status,
|
||||
merchant_id, shop_id, user_id, parent_id, parent_level, name, head_img, sex, birth_day,
|
||||
telephone, is_vip, code, is_attention, attention_at, is_shareholder, level, distribute_type,
|
||||
sort, created_at, updated_at, mini_open_id,dynamic_code
|
||||
sort, created_at, updated_at, mini_open_id,dynamic_code,join_time
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
@@ -59,7 +60,7 @@
|
||||
code, is_attention, attention_at,
|
||||
is_shareholder, level, distribute_type,
|
||||
sort, created_at, updated_at,
|
||||
mini_open_id)
|
||||
mini_open_id,join_time)
|
||||
values (#{id,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, #{creditAmount,jdbcType=DECIMAL},
|
||||
#{consumeAmount,jdbcType=DECIMAL}, #{consumeNumber,jdbcType=INTEGER}, #{levelConsume,jdbcType=DECIMAL},
|
||||
#{status,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR},
|
||||
@@ -69,7 +70,7 @@
|
||||
#{code,jdbcType=VARCHAR}, #{isAttention,jdbcType=TINYINT}, #{attentionAt,jdbcType=INTEGER},
|
||||
#{isShareholder,jdbcType=TINYINT}, #{level,jdbcType=TINYINT}, #{distributeType,jdbcType=VARCHAR},
|
||||
#{sort,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
|
||||
#{miniOpenId,jdbcType=VARCHAR})
|
||||
#{miniOpenId,jdbcType=VARCHAR},#{joinTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
|
||||
insert into tb_shop_user
|
||||
@@ -158,6 +159,9 @@
|
||||
<if test="miniOpenId != null">
|
||||
mini_open_id,
|
||||
</if>
|
||||
<if test="joinTime != null">
|
||||
join_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
@@ -244,6 +248,9 @@
|
||||
<if test="miniOpenId != null">
|
||||
#{miniOpenId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="joinTime != null">
|
||||
#{joinTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
|
||||
@@ -330,6 +337,9 @@
|
||||
<if test="miniOpenId != null">
|
||||
mini_open_id = #{miniOpenId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="joinTime != null">
|
||||
join_time = #{joinTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
@@ -361,7 +371,8 @@
|
||||
sort = #{sort,jdbcType=INTEGER},
|
||||
created_at = #{createdAt,jdbcType=BIGINT},
|
||||
updated_at = #{updatedAt,jdbcType=BIGINT},
|
||||
mini_open_id = #{miniOpenId,jdbcType=VARCHAR}
|
||||
mini_open_id = #{miniOpenId,jdbcType=VARCHAR},
|
||||
join_time = #{joinTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user