Commit 1ac2b19d authored by 黎聪聪's avatar 黎聪聪

药品接口

parent 4cc1a94f
......@@ -81,7 +81,7 @@
<div class="box-body">
</div>
<!--<div class="form-group form-md-line-input col-md-12">
<div class="form-group form-md-line-input col-md-12">
<label>上级分类</label>
<div class="input-group">
<input type="text" id="parentId" name="parentId" value="$!{data.parentId}"
......@@ -93,7 +93,7 @@
class="btn btn-info btn-flat">选择</button>
</span>
</div>
</div>-->
</div>
<div class="form-group form-md-line-input col-md-12">
<label>产品分类名称</label>
......
package com.cftech.productclassify.dao;
import com.cftech.productclassify.model.ProductMenuVO;
import com.cftech.productclassify.model.Productclassify;
import com.cftech.core.generic.GenericDao;
import com.cftech.productclassify.model.ProductclassifyVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -20,5 +23,20 @@ public interface ProductclassifyMapper extends GenericDao<Productclassify> {
* @return
*/
List<Productclassify> fetchTreeByPage(Map<String, Object> params);
/**
*
* @Description 商品列表展示
* @Date 15:19 2020/10/21
* @Param
* @return
**/
List<ProductclassifyVO> productList(@Param("productName") String productName, @Param("classifyName") String classifyName, @Param("dosagaFrom") String dosagaFrom);
/**
*
* @Description 商品分类菜单数据回填
* @Date 15:19 2020/10/21
* @Param
* @return
**/
List<ProductMenuVO> productMenu();
}
\ No newline at end of file
......@@ -146,6 +146,7 @@
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<update id="update" parameterType="com.cftech.productclassify.model.Productclassify">
update t_aidea_product_classify
<set>
......@@ -198,4 +199,43 @@
<update id="delete" parameterType="java.lang.Long">
update t_aidea_product_classify set del_flag=1 where id=#{id,jdbcType=BIGINT}
</update>
<select id="productList" resultType="com.cftech.productclassify.model.ProductclassifyVO">
SELECT
t.id AS ID,
t.product_name AS productName,
t.classify_id AS classifyId,
t.product_img AS productImg,
t.dosaga_from AS dosagaFrom,
t.common_name AS commonName,
t.format,
t.product_number AS productNumber,
t.accounts_id AS accountsId,
c.classify_name AS classifyName
FROM t_aidea_product t LEFT JOIN t_aidea_product_classify c
ON c.id = t.classify_id WHERE t.del_flag=0
<if test="productName !=null">
and
t.product_name like concat('%',#{productName},'%')
</if>
<if test="classifyName !=null">
and
c.classify_name = #{classifyName}
</if>
<if test="dosagaFrom !=null">
and
t.dosaga_from = #{dosagaFrom}
</if>
</select>
<!--商品分类菜单数据回填!-->
<select id="productMenu" resultType="com.cftech.productclassify.model.ProductMenuVO">
SELECT
t.id,
t.classify_name AS classifyName,
t.parent_id AS parentId,
a.dosaga_from AS dosagaFrom
FROM t_aidea_product_classify t LEFT JOIN t_aidea_product a ON a.classify_id = t.id AND t.del_flag = 0
</select>
</mapper>
\ No newline at end of file
package com.cftech.productclassify.model;
import lombok.Data;
/**
* @author :licc
* @date :Created in 2020/10/22 9:55
* @description:
*/
@Data
public class ProductMenuVO {
private Long Id;
/*分类名称*/
private String classifyName;
/*产品分类ID*/
private String parentId;
/*剂型*/
private String dosagaFrom;
}
package com.cftech.productclassify.model;
import lombok.Data;
/**
* @author :licc
* @date :Created in 2020/10/21 17:49
* @description:
*/
@Data
public class ProductclassifyVO {
/*商品主键id*/
private Long ID;
/*商品名称*/
private String productName;
/*产品分类ID*/
private String classifyId;
/*商品图片*/
private String productImg;
/*分类名称*/
private String classifyName;
/*剂型*/
private String dosagaFrom;
/*通用名*/
private String commonName;
/*规格*/
private String format;
}
package com.cftech.productclassify.service;
import com.alibaba.fastjson.JSONObject;
import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort;
import com.cftech.productclassify.model.Productclassify;
......@@ -25,4 +26,21 @@ public interface ProductclassifyService extends GenericService<Productclassify>
* @return
*/
List<Productclassify> fetchTreeByPage(Conds conds , Sort sort,int pageNo , int pageSize);
/**
*
* @Description 商品列表展示
* @Date 15:16 2020/10/21
* @Param
* @return
**/
JSONObject productList(String productName, String classifyName, String dosagaFrom);
/**
*
* @Description 商品分类菜单数据回填
* @Date 15:16 2020/10/21
* @Param
* @return
**/
JSONObject productMenu();
}
package com.cftech.productclassify.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cftech.core.sql.Sort;
import com.cftech.productclassify.model.ProductMenuVO;
import com.cftech.productclassify.model.Productclassify;
import com.cftech.productclassify.dao.ProductclassifyMapper;
import com.cftech.productclassify.model.ProductclassifyVO;
import com.cftech.productclassify.service.ProductclassifyService;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.core.sql.Conds;
import com.esotericsoftware.minlog.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
......@@ -43,4 +48,47 @@ public class ProductclassifyServiceImpl extends GenericServiceImpl<Productclassi
return productclassifyMapper.fetchTreeByPage(params);
}
@Override
public JSONObject productList(String productName, String classifyName, String dosagaFrom) {
JSONObject rtnJson = new JSONObject();
try {
List<ProductclassifyVO> productVOS = productclassifyMapper.productList(productName, classifyName, dosagaFrom);
if (productVOS==null){
rtnJson.put("errorNO","1");
rtnJson.put("errorNo","查询失败");
}
Log.info("返回结果:"+productVOS);
rtnJson.put("errorNO","0");
rtnJson.put("data",productVOS);
}catch (Exception e){
e.printStackTrace();
rtnJson.put("errorNO","1");
}
return rtnJson;
}
@Override
public JSONObject productMenu() {
JSONObject rtnJson = new JSONObject();
try {
List<ProductMenuVO> menu = productclassifyMapper.productMenu();
if (menu==null){
rtnJson.put("errorNO","1");
rtnJson.put("errorMsg","查询失败");
}
Log.info("返回结果:"+menu);
rtnJson.put("errorNO","0");
rtnJson.put("data",menu);
}catch (Exception e){
e.printStackTrace();
rtnJson.put("errorNO","1");
}
return rtnJson;
}
}
\ No newline at end of file
package com.cftech.productclassify.web;
import com.alibaba.fastjson.JSONObject;
import com.cftech.productclassify.service.ProductclassifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @author :licc
* @date :Created in 2020/10/21 17:46
* @description:
*/
@Slf4j
@RestController
@RequestMapping("mobile/auth/productclassify")
public class MobileclassifyController {
@Autowired
private com.cftech.productclassify.service.ProductclassifyService ProductclassifyService;
/**
* @Author Licc
* @Description 商品列表展示
* @Date 14:14 2020/10/21
* @Param
* @return
**/
@RequestMapping(value = "/productList",method = {RequestMethod.GET,RequestMethod.POST},produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JSONObject productList(String productName, String classifyName, String dosagaFrom){
return ProductclassifyService.productList(productName,classifyName,dosagaFrom);
}
/**
* @Author Licc
* @Description 商品分类菜单数据回填
* @Date 9:46 2020/10/22
* @Param []
* @return com.alibaba.fastjson.JSONObject
**/
@RequestMapping(value = "/productMenu",method = {RequestMethod.GET,RequestMethod.POST},produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JSONObject productMenu(){
return ProductclassifyService.productMenu();
}
}
......@@ -2,6 +2,10 @@ package com.cftech.product.dao;
import com.cftech.product.model.Product;
import com.cftech.core.generic.GenericDao;
import com.cftech.product.model.ProductVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 产品Mapper
......@@ -10,5 +14,12 @@ import com.cftech.core.generic.GenericDao;
* @date: 2020-09-24 15:07
*/
public interface ProductMapper extends GenericDao<Product> {
/**
*
* @Description 根据id查询商品详情
* @Date 15:19 2020/10/21
* @Param
* @return
**/
List<ProductVO> product(@Param("ID") Long ID);
}
\ No newline at end of file
......@@ -89,6 +89,29 @@
is_rs
</sql>
<sql id="productList">
t.id AS ID,
t.product_name AS productName,
t.classify_id AS classifyId,
t.product_img AS productImg,
t.recommend_measure AS recommendMeasure,
t.dosaga_from AS dosagaFrom,
t.common_name AS commonName,
t.format,
t.approve_number AS approveNumber,
t.manufacturer,
t.description,
t.tips,
t.take_type AS takeType,
t.take_frequency AS takeFrequency,
t.take_amount AS takeAmount,
t.stock,
t.price,
t.is_rs AS isRs,
t.product_number AS productNumber,
t.accounts_id AS accountsId,
c.classify_name AS classifyName
</sql>
<insert id="save" parameterType="com.cftech.product.model.Product" useGeneratedKeys="true"
keyProperty="id">
......@@ -181,6 +204,7 @@
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<update id="update" parameterType="com.cftech.product.model.Product">
update t_aidea_product
<set>
......@@ -266,4 +290,12 @@
<update id="delete" parameterType="java.lang.Long">
update t_aidea_product set del_flag=1 where id=#{id,jdbcType=BIGINT}
</update>
<!-- 根据ID查询商品详情!-->
<select id="product" resultType="com.cftech.product.model.ProductVO">
select
<include refid="productList"/>
FROM t_aidea_product t LEFT JOIN t_aidea_product_classify c
ON c.id = t.classify_id WHERE t.del_flag=0 and t.id= #{ID}
</select>
</mapper>
\ No newline at end of file
package com.cftech.product.model;
import com.sun.xml.bind.v2.model.core.ID;
import lombok.Data;
/**
* @author :licc
* @date :Created in 2020/10/21 14:24
* @description:
*/
@Data
public class ProductVO {
/*商品主键id*/
private Long ID;
/*商品名称*/
private String productName;
/*产品分类ID*/
private String classifyId;
/*商品图片*/
private String productImg;
/*推荐剂量*/
private String recommendMeasure;
/*剂型*/
private String dosagaFrom;
/*通用名*/
private String commonName;
/*规格*/
private String format;
/*批准文号*/
private String approveNumber;
/*生产企业*/
private String manufacturer;
/*药品简介*/
private String description;
/*温馨提示*/
private String tips;
/*服用类型*/
private String takeType;
/*服用频率*/
private String takeFrequency;
/*服用次数*/
private String takeAmount;
/*库存*/
private Long stock;
/*价格*/
private Double price;
/*是否为处方药*/
private String isRs;
/*产品编码*/
private String productNumber;
/*销量*/
private Long sales;
/*accounts_id*/
private Long accountsId;
/*分类名称*/
private String classifyName;
}
package com.cftech.product.service;
import com.alibaba.fastjson.JSONObject;
import com.cftech.product.model.Product;
import com.cftech.core.generic.GenericService;
import com.cftech.product.model.ProductVO;
/**
* 产品Service
*
......@@ -16,4 +19,13 @@ public interface ProductService extends GenericService<Product> {
* @param product
*/
boolean saveProduct(Product product);
/**
* @Author Licc
* @Description 根据id查询商品详情
* @Date 11:08 2020/10/22
* @Param
* @return
**/
JSONObject productId(Long ID);
}
package com.cftech.product.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cftech.base.codingrule.utils.CodingruleUtils;
import com.cftech.core.util.StringUtils;
import com.cftech.product.model.Product;
import com.cftech.product.dao.ProductMapper;
import com.cftech.product.model.ProductVO;
import com.cftech.product.service.ProductService;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
......@@ -12,6 +14,7 @@ import com.cftech.productdetail.dao.ProductDetailMapper;
import com.cftech.productdetail.model.ProductDetail;
import com.cftech.productintowareroom.dao.ProductIntoWareroomMapper;
import com.cftech.productintowareroom.model.ProductIntoWareroom;
import com.esotericsoftware.minlog.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
......@@ -31,6 +34,7 @@ import java.util.Map;
@Service("productService")
public class ProductServiceImpl extends GenericServiceImpl<Product> implements ProductService {
@Autowired
@Qualifier("productMapper")
private ProductMapper productMapper;
......@@ -52,40 +56,71 @@ public class ProductServiceImpl extends GenericServiceImpl<Product> implements P
/**
* 保存导入商品信息并生成商品入库单记录和商品明细记录
*
* @param product
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveProduct(Product product){
public boolean saveProduct(Product product) {
// 1、保存商品实体 根据商品编码判断该商品是否存在 存在则更新 不存在则新增
Map<String,Object> params = new HashMap<>();
Map<String, Object> params = new HashMap<>();
Conds conds = new Conds();
conds.equal("a.product_number",product.getProductNumber());
conds.equal("a.del_flag",0);
params.put("conds",conds);
conds.equal("a.product_number", product.getProductNumber());
conds.equal("a.del_flag", 0);
params.put("conds", conds);
List<Product> listProduct = productMapper.fetchSearchByPage(params);
if(listProduct.size() > 0){
if (listProduct.size() > 0) {
Product productEntity = listProduct.get(0);
if(StringUtils.isNotBlank(product.getClassifyNumber())){ productEntity.setClassifyNumber(product.getClassifyNumber()); }
if(StringUtils.isNotBlank(product.getProductName())){ productEntity.setProductName(product.getProductName()); }
if(StringUtils.isNotBlank(product.getCommonName())){ productEntity.setCommonName(product.getCommonName()); }
if(StringUtils.isNotBlank(product.getDosagaFrom())){ productEntity.setDosagaFrom(product.getDosagaFrom()); }
if(StringUtils.isNotBlank(product.getFormat())){ productEntity.setFormat(product.getFormat()); }
if(StringUtils.isNotBlank(product.getApproveNumber())){ productEntity.setApproveNumber(product.getApproveNumber()); }
if(StringUtils.isNotBlank(product.getManufacturer())){ productEntity.setManufacturer(product.getManufacturer()); }
if(StringUtils.isNoneBlank(product.getRecommendMeasure())){ productEntity.setRecommendMeasure(product.getRecommendMeasure()); }
if(StringUtils.isNoneBlank(product.getDescription())){ productEntity.setDescription(product.getDescription()); }
if(StringUtils.isNoneBlank(product.getTips())){ productEntity.setTips(product.getTips()); }
if(StringUtils.isNoneBlank(product.getTakeType())){ productEntity.setTakeType(product.getTakeType()); }
if(StringUtils.isNotBlank(product.getTakeFrequency())){ productEntity.setTakeFrequency(product.getTakeFrequency()); }
if(StringUtils.isNotBlank(product.getTakeAmount())){ productEntity.setTakeAmount(product.getTakeAmount()); }
if(StringUtils.isNotBlank(String.valueOf(product.getStock()))){
if (StringUtils.isNotBlank(product.getClassifyNumber())) {
productEntity.setClassifyNumber(product.getClassifyNumber());
}
if (StringUtils.isNotBlank(product.getProductName())) {
productEntity.setProductName(product.getProductName());
}
if (StringUtils.isNotBlank(product.getCommonName())) {
productEntity.setCommonName(product.getCommonName());
}
if (StringUtils.isNotBlank(product.getDosagaFrom())) {
productEntity.setDosagaFrom(product.getDosagaFrom());
}
if (StringUtils.isNotBlank(product.getFormat())) {
productEntity.setFormat(product.getFormat());
}
if (StringUtils.isNotBlank(product.getApproveNumber())) {
productEntity.setApproveNumber(product.getApproveNumber());
}
if (StringUtils.isNotBlank(product.getManufacturer())) {
productEntity.setManufacturer(product.getManufacturer());
}
if (StringUtils.isNoneBlank(product.getRecommendMeasure())) {
productEntity.setRecommendMeasure(product.getRecommendMeasure());
}
if (StringUtils.isNoneBlank(product.getDescription())) {
productEntity.setDescription(product.getDescription());
}
if (StringUtils.isNoneBlank(product.getTips())) {
productEntity.setTips(product.getTips());
}
if (StringUtils.isNoneBlank(product.getTakeType())) {
productEntity.setTakeType(product.getTakeType());
}
if (StringUtils.isNotBlank(product.getTakeFrequency())) {
productEntity.setTakeFrequency(product.getTakeFrequency());
}
if (StringUtils.isNotBlank(product.getTakeAmount())) {
productEntity.setTakeAmount(product.getTakeAmount());
}
if (StringUtils.isNotBlank(String.valueOf(product.getStock()))) {
productEntity.setStock((new BigDecimal(productEntity.getStock()).add(new BigDecimal(product.getStock()))).longValue());
}
if(StringUtils.isNotBlank(String.valueOf(product.getPrice()))){ productEntity.setPrice(product.getPrice()); }
if(StringUtils.isNotBlank(product.getIsRs())) { productEntity.setIsRs(product.getIsRs()); }
if (StringUtils.isNotBlank(String.valueOf(product.getPrice()))) {
productEntity.setPrice(product.getPrice());
}
if (StringUtils.isNotBlank(product.getIsRs())) {
productEntity.setIsRs(product.getIsRs());
}
productMapper.update(productEntity);
}else {
} else {
productMapper.save(product);
}
......@@ -107,12 +142,12 @@ public class ProductServiceImpl extends GenericServiceImpl<Product> implements P
// 3、生成商品明细表
ProductDetail productDetail = null;
if (product.getStock() != null && product.getStock() > 0){
for (int i = 0; i < product.getStock().intValue(); i++){
if (product.getStock() != null && product.getStock() > 0) {
for (int i = 0; i < product.getStock().intValue(); i++) {
productDetail = new ProductDetail();
productDetail.setAccountsId(product.getAccountsId());
productDetail.setProductDetailNumber(codingruleUtils.getNumber(product.getAccountsId(),ProductDetail.class.getName()));
productDetail.setMaterielNumber(codingruleUtils.getNumber(product.getAccountsId(),"com.cftech.productmaterie.model.Materie"));
productDetail.setProductDetailNumber(codingruleUtils.getNumber(product.getAccountsId(), ProductDetail.class.getName()));
productDetail.setMaterielNumber(codingruleUtils.getNumber(product.getAccountsId(), "com.cftech.productmaterie.model.Materie"));
productDetail.setProductNumber(product.getProductNumber());
productDetail.setProductName(product.getProductName());
productDetail.setProductClassifyNumber(product.getClassifyNumber());
......@@ -128,5 +163,28 @@ public class ProductServiceImpl extends GenericServiceImpl<Product> implements P
return true;
}
@Override
public JSONObject productId(Long ID) {
JSONObject rtnJson = new JSONObject();
try {
if (ID.equals("")){
rtnJson.put("errorNO","1");
rtnJson.put("errorMsg","id不能为空");
}
List<ProductVO> product = productMapper.product(ID);
if (product==null){
rtnJson.put("errorNO","1");
rtnJson.put("errorMsg","查询失败");
}
Log.info("返回结果:"+product);
rtnJson.put("errorNO","0");
rtnJson.put("data",product);
}catch (Exception e){
e.printStackTrace();
rtnJson.put("errorNO","1");
}
return rtnJson;
}
}
\ No newline at end of file
package com.cftech.product.web;
import com.alibaba.fastjson.JSONObject;
import com.cftech.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import sun.util.resources.cldr.gv.LocaleNames_gv;
/**
* @author :licc
* @date :Created in 2020/10/21 14:10
* @description:药品分类
*/
@Slf4j
@RestController
@RequestMapping("mobile/auth/product")
public class MobileProductController {
@Autowired
private ProductService productService;
/**
* @Author Licc
* @Description 根据id查询商品详情
* @Date 11:05 2020/10/22
* @Param
* @return
**/
@RequestMapping(value = "/productId",method = {RequestMethod.GET,RequestMethod.POST},produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JSONObject productMenu(Long ID){
return productService.productId(ID);
}
}
......@@ -179,7 +179,7 @@
offline.phone memberPhone,
offline.storeid memberStoreId
FROM wx_mp_member t
left join wx_mp_member_offline offline on offline.member_id = t.member_id
left join wx_mp_member_offline offline on offline.member_id = t.member_id and t.del_flag=0
WHERE t.id=#{id}
</select>
......@@ -354,7 +354,7 @@
-->
<select id="memberFormation" parameterType="java.lang.Long" resultType="com.cftech.member.model.MemberVO">
SELECT `name` AS memberName,sex,birthday,imageurl,email AS mailbox,phone
FROM wx_mp_member WHERE id= #{Id}
FROM wx_mp_member WHERE id= #{Id} and del_flag=0
</select>
<!--个人信息修改
-->
......
......@@ -149,6 +149,7 @@
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
and t.del_flag=0
WHERE t.open_id = #{openId}
</select>
......@@ -159,6 +160,7 @@
LEFT JOIN area a ON t.province_id = a.areaid
LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid
and t.del_flag=0
WHERE t.id=#{id}
</select>
......@@ -254,6 +256,6 @@
select areaid,areaname,affiliationareaId,citytype from area
</select>
<select id="whetherList" resultType="java.lang.Integer">
select * from t_shipping_address where open_id = #{openId} and whether=1
select * from t_shipping_address where open_id = #{openId} and whether=1 and del_flag=0
</select>
</mapper>
\ No newline at end of file
......@@ -18,7 +18,7 @@ import java.util.List;
/**
* @author :licc
* @date :Created in 2020/10/19 18:11
* @description:收货地址修改
* @description:收货地址
*/
@Slf4j
@RestController
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment