浏览代码

app一级市场商户操作-商品管理

linbl 2 年之前
父节点
当前提交
b097f5c4b1

+ 32 - 30
sp-core/sp-base/src/main/java/com/pj/project4sp/uploadfile/UploadUtil.java

@@ -25,39 +25,41 @@ public class UploadUtil {
 	public void setUploadConfig(UploadConfig uploadConfig) {
 		UploadUtil.uploadConfig = uploadConfig;
 	}
-	
+
 	/** 将文件名保存在服务器硬盘上,并把文件对应的http地址返回给前台  */
 	public static String saveFile(MultipartFile file, String flieTypeFolder) {
-		
-		// 1、计算路径  
-		// 根据日期计算需要保存的文件夹 
-		String currDateFolder = getCurrDateFolder();		
-		// 文件名 
-		String fileName = getMarking28() + '.' + getSuffixName(file.getOriginalFilename());				
-		// 需要保存到的文件夹地址 
+
+		// 1、计算路径
+		// 根据日期计算需要保存的文件夹
+		String currDateFolder = getCurrDateFolder();
+		// 文件名
+		String fileName = getMarking28() + '.' + getSuffixName(file.getOriginalFilename());
+		// 需要保存到的文件夹地址
 		String fileFolder = new File(uploadConfig.rootFolder).getAbsolutePath() + "/" +
-				uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/";	
+				uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/";
 		// 对外暴露的http路径
-		String httpUrl = getDoMain() + uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/" + fileName;	
-		
-		// 2、如果文件夹不存在,则先创建 
+		//String httpUrl = getDoMain() + uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/" + fileName;
+		//去掉前缀ip端口,从前台实时获取当前服务ip与端口
+		String httpUrl = uploadConfig.httpPrefix + flieTypeFolder + currDateFolder + "/" + fileName;
+
+		// 2、如果文件夹不存在,则先创建
 		File dirFile = new File(fileFolder);
 		if(dirFile.exists() == false) {
 			dirFile.mkdirs();
 		}
 
-		// 3、开始转存文件 
+		// 3、开始转存文件
 		try {
 			File outFile = new File(fileFolder + fileName);
-	        file.transferTo(outFile);		
+	        file.transferTo(outFile);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-		
+
 		// 4、将文件外网地址返回给前台
 		return httpUrl;
 	}
-	
+
 	/** 验证文件大小  */
 	static void checkFileSize(MultipartFile file) {
 		// 文件大小(B)
@@ -66,22 +68,22 @@ public class UploadUtil {
         	throw new RuntimeException("文件大小超出限制");
         }
 	}
-	
-	/** 
-	 * 验证指定文件名是否存在于指定后缀列表中 
-	 * 参数:文件名、后缀列表	
-	 * case:checkSubffix("123.jpg", "jpg,png,gif")	验证通过  
+
+	/**
+	 * 验证指定文件名是否存在于指定后缀列表中
+	 * 参数:文件名、后缀列表
+	 * case:checkSubffix("123.jpg", "jpg,png,gif")	验证通过
 	 */
 	static void checkSubffix(String fileName, String suffixList) {
-		// 获取后缀,并转为小写 
-		String ext = getSuffixName(fileName).toLowerCase();	
-		// 去空格,加逗号   
-		String yxSuffix = suffixList.replace(" ", "") + ",";		
+		// 获取后缀,并转为小写
+		String ext = getSuffixName(fileName).toLowerCase();
+		// 去空格,加逗号
+		String yxSuffix = suffixList.replace(" ", "") + ",";
 		if(yxSuffix.indexOf(ext + ",") == -1) {
 			throw new RuntimeException("文件后缀验证未通过:" + ext);
 		}
 	}
-	
+
 	/** 返回随机生成的唯一标示28位唯一标示符 */
 	static String getMarking28() {
 		return System.currentTimeMillis() + "" + new Random().nextInt(Integer.MAX_VALUE);
@@ -91,16 +93,16 @@ public class UploadUtil {
 	static String getSuffixName(String fileName) {
 		return fileName.substring(fileName.lastIndexOf(".") + 1);
 	}
-	
+
 	/** 返回今天的日期文件夹  */
 	static String getCurrDateFolder() {
-		String currDateFolder = new SimpleDateFormat("/yyyy/MM-dd").format(new Date()); 
+		String currDateFolder = new SimpleDateFormat("/yyyy/MM-dd").format(new Date());
 		return currDateFolder;
 	}
-	
+
 	/** 返回本服务器域名信息  */
 	static String getDoMain() {
 		return SystemObject.config.getDomain();
 	}
-	
+
 }

+ 27 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/GoodsTransitAppController.java

@@ -3,6 +3,7 @@ package com.pj.tb_goods_transit;
 
 import com.pj.current.dto.APPLoginUserInfo;
 import com.pj.current.satoken.StpAPPUserUtil;
+import com.pj.enummj.DeleteStatus;
 import com.pj.tb_goods_transit.param.PurchaseLevelOneGoodsTransitParam;
 import com.pj.tb_goods_transit.param.TransactionGoodsParam;
 import com.pj.utils.sg.AjaxJson;
@@ -28,6 +29,14 @@ public class GoodsTransitAppController {
     @Autowired
     private TbGoodsTransitService tbGoodsTransitService;
 
+    /** 查 - 根据id */
+    @RequestMapping("getById")
+//		@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE)
+    public AjaxJson getById(Long id){
+        TbGoodsTransit t = tbGoodsTransitService.getById(id);
+        return AjaxJson.getSuccessData(t);
+    }
+
     /** 查集合 - 根据APP用户ID查发布的商品(参数为空时代表忽略指定条件) */
     @RequestMapping("getTransitList")
 //		@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE)
@@ -38,14 +47,31 @@ public class GoodsTransitAppController {
 
         SoMap so = SoMap.getRequestSoMap();
         so.put("merchantId",appLoginInfo.getLoginId());
+        so.put("deleteStatus" , DeleteStatus.DELETE_STATUS_ON.getCode());
         List<TbGoodsTransit> list = tbGoodsTransitService.getList(so.startPage());
         return AjaxJson.getPageData(so.getDataCount(), list);
     }
 
+    /** 删 */
+    @RequestMapping("deleteById")
+//	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_DEL)
+    public AjaxJson deleteById(Long id){
+        tbGoodsTransitService.delete(id);
+        return AjaxJson.getSuccess();
+    }
+
+    /** 改 */
+    @RequestMapping("update")
+//	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_EDIT)
+    public AjaxJson update(TbGoodsTransit t){
+        tbGoodsTransitService.update(t);
+        return AjaxJson.getSuccess();
+    }
+
     /** app端用户添加商品 */
     @RequestMapping("transactionGoods")
 //    @SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_ADD)
-    public AjaxJson transactionGoods(@Validated @RequestBody TransactionGoodsParam t){
+    public AjaxJson transactionGoods(TransactionGoodsParam t){
         boolean goods = tbGoodsTransitService.transactionGoods(t);
         if(goods) return AjaxJson.getSuccess("商品添加成功!");
         return AjaxJson.getError("商品添加失败!");

+ 22 - 22
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitController.java

@@ -19,7 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 /**
  * Controller: tb_goods_transit -- 审核商户在APP端发布的商品
- * @author qzy 
+ * @author qzy
  */
 @RestController
 @RequestMapping("/TbGoodsTransit/")
@@ -29,7 +29,7 @@ public class TbGoodsTransitController {
 	@Autowired
 	TbGoodsTransitService tbGoodsTransitService;
 
-	/** 增 */  
+	/** 增 */
 	@RequestMapping("add")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_ADD)
 	public AjaxJson add(TbGoodsTransit t){
@@ -38,24 +38,24 @@ public class TbGoodsTransitController {
 		return AjaxJson.getSuccessData(t);
 	}
 
-	/** 删 */  
+	/** 删 */
 	@RequestMapping("delete")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_DEL)
 	public AjaxJson delete(Long id){
 		 tbGoodsTransitService.delete(id);
 		return AjaxJson.getSuccess();
 	}
-	
-	/** 删 - 根据id列表 */  
+
+	/** 删 - 根据id列表 */
 	@RequestMapping("deleteByIds")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_DEL)
 	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
+		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
 		int line = SP.publicMapper.deleteByIds(TbGoodsTransit.TABLE_NAME, ids);
 		return AjaxJson.getByLine(line);
 	}
-	
-	/** 改 */  
+
+	/** 改 */
 	@RequestMapping("update")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_EDIT)
 	public AjaxJson update(TbGoodsTransit t){
@@ -63,7 +63,7 @@ public class TbGoodsTransitController {
 		return AjaxJson.getSuccess();
 	}
 
-	/** 查 - 根据id */  
+	/** 查 - 根据id */
 	@RequestMapping("getById")
 //		@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE)
 	public AjaxJson getById(Long id){
@@ -71,38 +71,38 @@ public class TbGoodsTransitController {
 		return AjaxJson.getSuccessData(t);
 	}
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
 	@RequestMapping("getList")
 //		@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE)
-	public AjaxJson getList() { 
+	public AjaxJson getList() {
 		SoMap so = SoMap.getRequestSoMap();
 		List<TbGoodsTransit> list = tbGoodsTransitService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	/** 改 - 商品状态(0=下架,1=在售) */  
+
+
+
+	/** 改 - 商品状态(0=下架,1=在售) */
 	@RequestMapping("updateGoodsStatus")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_EDIT)
 	public AjaxJson updateGoodsStatus(Long id, Integer value){
 		int line = SP.publicMapper.updateColumnById(TbGoodsTransit.TABLE_NAME, "goods_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	/** 改 - 审核状态(0=待审核,1=通过,2=不通过) */  
+
+	/** 改 - 审核状态(0=待审核,1=通过,2=不通过) */
 	@RequestMapping("updateAuditStatus")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_EDIT)
 	public AjaxJson updateAuditStatus(Long id, Integer value){
 		int line = SP.publicMapper.updateColumnById(TbGoodsTransit.TABLE_NAME, "audit_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	/** 改 - 删除状态(0=禁用,1=启用) */  
+
+	/** 改 - 删除状态(0=禁用,1=启用) */
 	@RequestMapping("updateDelStatus")
 //	@SaCheckPermission(TbGoodsTransit.PERMISSION_CODE_EDIT)
 	public AjaxJson updateDelStatus(Long id, Integer value){
-		int line = SP.publicMapper.updateColumnById(TbGoodsTransit.TABLE_NAME, "del_status", value, id);
+		int line = SP.publicMapper.updateColumnById(TbGoodsTransit.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
 
@@ -157,7 +157,7 @@ public class TbGoodsTransitController {
 		}
 		return AjaxJson.getError();
 	}
-	
-	
+
+
 
 }

+ 19 - 17
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitMapper.xml

@@ -6,18 +6,18 @@
 
 
 	<!-- ================================== 查询相关 ================================== -->
-	<!-- select id, merchant_id, merchant_name, goods_type, goods_name, goods_units, price, place_origin, discription, stock, goods_status, audit_status, audit_time, remark, create_time, create_by, create_name, update_time, update_by, update_name, del_status from tb_goods_transit  -->
-	
+	<!-- select id, merchant_id, merchant_name, goods_type, goods_name, goods_units, price, place_origin, discription, stock, goods_status, audit_status, audit_time, remark, create_time, create_by, create_name, update_time, update_by, update_name, delete_status from tb_goods_transit  -->
+
 	<!-- 通用映射:自动模式 -->
 	<resultMap id="model" autoMapping="true" type="com.pj.tb_goods_transit.TbGoodsTransit"></resultMap>
-	
+
 	<!-- 公共查询sql片段 -->
 	<sql id="select_sql">
-		select * 
-		from tb_goods_transit 
+		select *
+		from tb_goods_transit
 	</sql>
 
-	
+
 	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
 	<select id="getList" resultMap="model">
 		<include refid="select_sql"></include>
@@ -33,6 +33,8 @@
 			<if test=' this.has("description") '> and discription = #{discription} </if>
 			<if test=' this.has("stock") '> and stock = #{stock} </if>
 			<if test=' this.has("goodsStatus") '> and goods_status = #{goodsStatus} </if>
+			<if test=' this.has("isOrders") '> and is_orders = #{isOrders} </if>
+			<if test=' this.has("enterpriseConfirm") '> and enterprise_confirm = #{enterpriseConfirm} </if>
 			<if test=' this.has("auditStatus") '> and audit_status = #{auditStatus} </if>
 			<if test=' this.has("auditTime") '> and audit_time = #{auditTime} </if>
 			<if test=' this.has("remark") '> and remark = #{remark} </if>
@@ -42,7 +44,7 @@
 			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>
 			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
 			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
-			<if test=' this.has("deleteStatus") '> and del_status = #{delStatus} </if>
+			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
 		</where>
 		order by
 		<choose>
@@ -66,18 +68,18 @@
 			<when test='sortType == 18'> update_time desc </when>
 			<when test='sortType == 19'> update_by desc </when>
 			<when test='sortType == 20'> update_name desc </when>
-			<when test='sortType == 21'> del_status desc </when>
+			<when test='sortType == 21'> delete_status desc </when>
 			<otherwise> id desc </otherwise>
 		</choose>
 	</select>
-	
-	
-	
-	
-	
-	
-	
-	
-	
+
+
+
+
+
+
+
+
+
 
 </mapper>

+ 12 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/TbGoodsTransitService.java

@@ -47,7 +47,7 @@ import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_goods_transit -- 审核商户在APP端发布的商品
- * @author qzy 
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
@@ -98,9 +98,9 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 		return super.getById(id);
 	}
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbGoodsTransit> getList(SoMap so) { 
-		return tbGoodsTransitMapper.getList(so);	
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
+	List<TbGoodsTransit> getList(SoMap so) {
+		return tbGoodsTransitMapper.getList(so);
 	}
 
 	/** 查看一级市场在销/上架商品 */
@@ -182,11 +182,19 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
 		tbGoodsTransit.setGoodsType(tbGoods.getTypeNames());
 		tbGoodsTransit.setShopId(transactionGoodsParam.getShopId());
 		tbGoodsTransit.setShopName(transactionGoodsParam.getShopName());
+
+		//商户编号
+		tbGoodsTransit.setMerchantId(appLoginInfo.getLoginId() + "");
+		//商户名称
+		tbGoodsTransit.setMerchantName(appLoginInfo.getLoginName());
+
 		//保存海关商品表的主键到商品审核表上 todo:原计划是保存[海关申报单号],临时修改成保存海关商品表的主键
 		tbGoodsTransit.setDeclareOdd(tbGoods.getId().toString());
 		//设置默认信息
 		tbGoodsTransit.setAuditStatus(1);//默认已过审
 		tbGoodsTransit.setGoodsStatus(1);//默认已上架
+		tbGoodsTransit.setIsOrders(0);//默认未被下单
+		tbGoodsTransit.setEnterpriseConfirm(0);//商铺确认情况[0=待确认,1=已确认,2=拒绝]
 		//设置基本信息
 		tbGoodsTransit.setCreateTime(new Date());
 		tbGoodsTransit.setCreateBy(appLoginInfo.getLoginId() + "");

+ 70 - 25
sp-service/level-one-server/src/main/java/com/pj/tb_goods_transit/param/TransactionGoodsParam.java

@@ -16,25 +16,6 @@ import javax.validation.constraints.NotNull;
 @NoArgsConstructor
 public class TransactionGoodsParam {
 
-    /** 海关申报单号 */
-    private String declareOdd;
-
-    /** 互市区ID */
-    @NotNull
-    private Long tradeAreaId;
-
-    /** 价格 */
-    private Double price;
-
-    /** 净重 */
-    private Double netWeight;
-
-    /** 毛重 */
-    private Double grossWeight;
-
-    /** 数量 */
-    private Integer stock;
-
     /** 监管商品的ID */
     @NotBlank(message = "监管商品ID不能为空")
     private Long id;
@@ -45,12 +26,6 @@ public class TransactionGoodsParam {
     /** 当前添加商品的商户名称 */
     private String merchantName;
 
-    /** 商品描述 */
-    private String description;
-
-    /** 商品图片 */
-    private String goodsImg;
-
     /** 商铺id */
     @NotBlank(message = "商铺ID不能为空")
     private Long shopId;
@@ -58,4 +33,74 @@ public class TransactionGoodsParam {
     /** 商铺名称 */
     private String shopName;
 
+    /** 互市区名称 */
+    private String tradeAreaName;
+
+    /** 互市区ID */
+    private Long tradeAreaId;
+
+    /**
+     * 海关申报单号
+     */
+    private String declareOdd;
+
+    /**
+     * 商品类型
+     */
+    private String goodsType;
+    /**
+     * 商品图片
+     */
+    private String goodsImg;
+
+    /**
+     * 商品名称
+     */
+    private String goodsName;
+
+    /**
+     * 商品单位(吨、kg、个、柜)
+     */
+    private String goodsUnits;
+
+    /**
+     * 净重
+     */
+    private Double netWeight;
+
+    /**
+     * 毛重
+     */
+    private Double grossWeight;
+
+    /**
+     * 商品价格
+     */
+    private Double price;
+
+    /**
+     * 产地(国家)
+     */
+    private String placeOrigin;
+
+    /**
+     * 商品描述
+     */
+    private String description;
+
+    /**
+     * 库存数量
+     */
+    private Integer stock;
+
+    /**
+     * 商品状态(0=下架,1=在售)
+     */
+    private Integer goodsStatus;
+
+
+
+
+
+
 }