| | |
| | | package com.java110.goods.api; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.dto.groupBuy.GroupBuyDto; |
| | | import com.java110.dto.groupBuyBatch.GroupBuyBatchDto; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping(value = "/groupBuy") |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyProduct/saveGroupBuyProduct |
| | | * @path /app/groupBuyProduct/saveGroupBuyProduct |
| | | * @serviceCode /groupBuy/saveGroupBuyProduct |
| | | * @path /app/groupBuy/saveGroupBuyProduct |
| | | */ |
| | | @RequestMapping(value = "/saveGroupBuyProduct", method = RequestMethod.POST) |
| | | public ResponseEntity<String> saveGroupBuyProduct(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | Assert.hasKeyAndValue(reqJson, "groupProdDesc", "请求报文中未包含groupProdDesc"); |
| | | Assert.hasKeyAndValue(reqJson, "sort", "请求报文中未包含sort"); |
| | | |
| | | Assert.hasKey(reqJson, "productSpecs", "请求报文中未包含商品规格信息"); |
| | | |
| | | JSONArray productSpecs = reqJson.getJSONArray("productSpecs"); |
| | | |
| | | if (productSpecs.size() < 1) { |
| | | throw new IllegalArgumentException("请求报文中商品规格数量为0"); |
| | | } |
| | | List<GroupBuyProductSpecPo> groupBuyProductSpecPos = new ArrayList<>(); |
| | | GroupBuyProductSpecPo groupBuyProductSpecPo = null; |
| | | for (int specIndex = 0; specIndex < productSpecs.size(); specIndex++) { |
| | | groupBuyProductSpecPo = BeanConvertUtil.covertBean(productSpecs.getJSONObject(specIndex), GroupBuyProductSpecPo.class); |
| | | groupBuyProductSpecPo.setProductId(reqJson.getString("productId")); |
| | | groupBuyProductSpecPo.setDefaultShow("F"); |
| | | groupBuyProductSpecPo.setGroupSales("1"); |
| | | groupBuyProductSpecPo.setStoreId(storeId); |
| | | groupBuyProductSpecPos.add(groupBuyProductSpecPo); |
| | | } |
| | | GroupBuyProductPo groupBuyProductPo = BeanConvertUtil.covertBean(reqJson, GroupBuyProductPo.class); |
| | | groupBuyProductPo.setStoreId(storeId); |
| | | return saveGroupBuyProductBMOImpl.save(groupBuyProductPo); |
| | | return saveGroupBuyProductBMOImpl.save(groupBuyProductPo, groupBuyProductSpecPos); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyProduct/updateGroupBuyProduct |
| | | * @path /app/groupBuyProduct/updateGroupBuyProduct |
| | | * @serviceCode /groupBuy/updateGroupBuyProduct |
| | | * @path /app/groupBuy/updateGroupBuyProduct |
| | | */ |
| | | @RequestMapping(value = "/updateGroupBuyProduct", method = RequestMethod.POST) |
| | | public ResponseEntity<String> updateGroupBuyProduct(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | Assert.hasKeyAndValue(reqJson, "sort", "请求报文中未包含sort"); |
| | | Assert.hasKeyAndValue(reqJson, "groupId", "groupId不能为空"); |
| | | |
| | | Assert.hasKey(reqJson, "productSpecs", "请求报文中未包含商品规格信息"); |
| | | |
| | | JSONArray productSpecs = reqJson.getJSONArray("productSpecs"); |
| | | |
| | | if (productSpecs.size() < 1) { |
| | | throw new IllegalArgumentException("请求报文中商品规格数量为0"); |
| | | } |
| | | List<GroupBuyProductSpecPo> groupBuyProductSpecPos = new ArrayList<>(); |
| | | GroupBuyProductSpecPo groupBuyProductSpecPo = null; |
| | | for (int specIndex = 0; specIndex < productSpecs.size(); specIndex++) { |
| | | groupBuyProductSpecPo = BeanConvertUtil.covertBean(productSpecs.getJSONObject(specIndex), GroupBuyProductSpecPo.class); |
| | | groupBuyProductSpecPo.setProductId(reqJson.getString("productId")); |
| | | groupBuyProductSpecPo.setDefaultShow("F"); |
| | | groupBuyProductSpecPo.setGroupSales("1"); |
| | | groupBuyProductSpecPo.setStoreId(storeId); |
| | | groupBuyProductSpecPos.add(groupBuyProductSpecPo); |
| | | } |
| | | GroupBuyProductPo groupBuyProductPo = BeanConvertUtil.covertBean(reqJson, GroupBuyProductPo.class); |
| | | groupBuyProductPo.setStoreId(storeId); |
| | | return updateGroupBuyProductBMOImpl.update(groupBuyProductPo); |
| | | return updateGroupBuyProductBMOImpl.update(groupBuyProductPo, groupBuyProductSpecPos); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyProduct/deleteGroupBuyProduct |
| | | * @path /app/groupBuyProduct/deleteGroupBuyProduct |
| | | * @serviceCode /groupBuy/deleteGroupBuyProduct |
| | | * @path /app/groupBuy/deleteGroupBuyProduct |
| | | */ |
| | | @RequestMapping(value = "/deleteGroupBuyProduct", method = RequestMethod.POST) |
| | | public ResponseEntity<String> deleteGroupBuyProduct(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | * |
| | | * @param storeId 商户 |
| | | * @return |
| | | * @serviceCode /groupBuyProduct/queryGroupBuyProduct |
| | | * @path /app/groupBuyProduct/queryGroupBuyProduct |
| | | * @serviceCode /groupBuy/queryGroupBuyProduct |
| | | * @path /app/groupBuy/queryGroupBuyProduct |
| | | */ |
| | | @RequestMapping(value = "/queryGroupBuyProduct", method = RequestMethod.GET) |
| | | public ResponseEntity<String> queryGroupBuyProduct(@RequestHeader(value = "store-id") String storeId, |
| | | @RequestParam(value = "page") int page, |
| | | @RequestParam(value = "row") int row) { |
| | | @RequestParam(value = "row") int row, |
| | | @RequestParam(value = "groupId", required = false) String groupId) { |
| | | GroupBuyProductDto groupBuyProductDto = new GroupBuyProductDto(); |
| | | groupBuyProductDto.setPage(page); |
| | | groupBuyProductDto.setRow(row); |
| | | groupBuyProductDto.setStoreId(storeId); |
| | | groupBuyProductDto.setGroupId(groupId); |
| | | return getGroupBuyProductBMOImpl.get(groupBuyProductDto); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuySetting/saveGroupBuySetting |
| | | * @path /app/groupBuySetting/saveGroupBuySetting |
| | | * @serviceCode /groupBuy/saveGroupBuySetting |
| | | * @path /app/groupBuy/saveGroupBuySetting |
| | | */ |
| | | @RequestMapping(value = "/saveGroupBuySetting", method = RequestMethod.POST) |
| | | public ResponseEntity<String> saveGroupBuySetting(@RequestBody JSONObject reqJson) { |
| | | public ResponseEntity<String> saveGroupBuySetting(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "groupBuyName", "请求报文中未包含groupBuyName"); |
| | | Assert.hasKeyAndValue(reqJson, "validHours", "请求报文中未包含validHours"); |
| | |
| | | |
| | | |
| | | GroupBuySettingPo groupBuySettingPo = BeanConvertUtil.covertBean(reqJson, GroupBuySettingPo.class); |
| | | groupBuySettingPo.setStoreId(storeId); |
| | | return saveGroupBuySettingBMOImpl.save(groupBuySettingPo); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuySetting/updateGroupBuySetting |
| | | * @path /app/groupBuySetting/updateGroupBuySetting |
| | | * @serviceCode /groupBuy/updateGroupBuySetting |
| | | * @path /app/groupBuy/updateGroupBuySetting |
| | | */ |
| | | @RequestMapping(value = "/updateGroupBuySetting", method = RequestMethod.POST) |
| | | public ResponseEntity<String> updateGroupBuySetting(@RequestBody JSONObject reqJson) { |
| | | public ResponseEntity<String> updateGroupBuySetting(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "groupBuyName", "请求报文中未包含groupBuyName"); |
| | | Assert.hasKeyAndValue(reqJson, "validHours", "请求报文中未包含validHours"); |
| | |
| | | |
| | | |
| | | GroupBuySettingPo groupBuySettingPo = BeanConvertUtil.covertBean(reqJson, GroupBuySettingPo.class); |
| | | groupBuySettingPo.setStoreId(storeId); |
| | | return updateGroupBuySettingBMOImpl.update(groupBuySettingPo); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuySetting/deleteGroupBuySetting |
| | | * @path /app/groupBuySetting/deleteGroupBuySetting |
| | | * @serviceCode /groupBuy/deleteGroupBuySetting |
| | | * @path /app/groupBuy/deleteGroupBuySetting |
| | | */ |
| | | @RequestMapping(value = "/deleteGroupBuySetting", method = RequestMethod.POST) |
| | | public ResponseEntity<String> deleteGroupBuySetting(@RequestBody JSONObject reqJson) { |
| | | public ResponseEntity<String> deleteGroupBuySetting(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空"); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "settingId", "settingId不能为空"); |
| | | |
| | | |
| | | GroupBuySettingPo groupBuySettingPo = BeanConvertUtil.covertBean(reqJson, GroupBuySettingPo.class); |
| | | groupBuySettingPo.setStoreId(storeId); |
| | | return deleteGroupBuySettingBMOImpl.delete(groupBuySettingPo); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param storeId 商户ID |
| | | * @return |
| | | * @serviceCode /groupBuySetting/queryGroupBuySetting |
| | | * @path /app/groupBuySetting/queryGroupBuySetting |
| | | * @serviceCode /groupBuy/queryGroupBuySetting |
| | | * @path /app/groupBuy/queryGroupBuySetting |
| | | */ |
| | | @RequestMapping(value = "/queryGroupBuySetting", method = RequestMethod.GET) |
| | | public ResponseEntity<String> queryGroupBuySetting(@RequestHeader(value = "store-id") String storeId, |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyProductSpec/saveGroupBuyProductSpec |
| | | * @path /app/groupBuyProductSpec/saveGroupBuyProductSpec |
| | | * @serviceCode /groupBuy/saveGroupBuyProductSpec |
| | | * @path /app/groupBuy/saveGroupBuyProductSpec |
| | | */ |
| | | @RequestMapping(value = "/saveGroupBuyProductSpec", method = RequestMethod.POST) |
| | | public ResponseEntity<String> saveGroupBuyProductSpec(@RequestBody JSONObject reqJson) { |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyProductSpec/updateGroupBuyProductSpec |
| | | * @path /app/groupBuyProductSpec/updateGroupBuyProductSpec |
| | | * @serviceCode /groupBuy/updateGroupBuyProductSpec |
| | | * @path /app/groupBuy/updateGroupBuyProductSpec |
| | | */ |
| | | @RequestMapping(value = "/updateGroupBuyProductSpec", method = RequestMethod.POST) |
| | | public ResponseEntity<String> updateGroupBuyProductSpec(@RequestBody JSONObject reqJson) { |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyProductSpec/deleteGroupBuyProductSpec |
| | | * @path /app/groupBuyProductSpec/deleteGroupBuyProductSpec |
| | | * @serviceCode /groupBuy/deleteGroupBuyProductSpec |
| | | * @path /app/groupBuy/deleteGroupBuyProductSpec |
| | | */ |
| | | @RequestMapping(value = "/deleteGroupBuyProductSpec", method = RequestMethod.POST) |
| | | public ResponseEntity<String> deleteGroupBuyProductSpec(@RequestBody JSONObject reqJson) { |
| | |
| | | * |
| | | * @param storeId 小区ID |
| | | * @return |
| | | * @serviceCode /groupBuyProductSpec/queryGroupBuyProductSpec |
| | | * @path /app/groupBuyProductSpec/queryGroupBuyProductSpec |
| | | * @serviceCode /groupBuy/queryGroupBuyProductSpec |
| | | * @path /app/groupBuy/queryGroupBuyProductSpec |
| | | */ |
| | | @RequestMapping(value = "/queryGroupBuyProductSpec", method = RequestMethod.GET) |
| | | public ResponseEntity<String> queryGroupBuyProductSpec(@RequestHeader(value = "store-id") String storeId, |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyBatch/saveGroupBuyBatch |
| | | * @path /app/groupBuyBatch/saveGroupBuyBatch |
| | | * @serviceCode /groupBuy/saveGroupBuyBatch |
| | | * @path /app/groupBuy/saveGroupBuyBatch |
| | | */ |
| | | @RequestMapping(value = "/saveGroupBuyBatch", method = RequestMethod.POST) |
| | | public ResponseEntity<String> saveGroupBuyBatch(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyBatch/updateGroupBuyBatch |
| | | * @path /app/groupBuyBatch/updateGroupBuyBatch |
| | | * @serviceCode /groupBuy/updateGroupBuyBatch |
| | | * @path /app/groupBuy/updateGroupBuyBatch |
| | | */ |
| | | @RequestMapping(value = "/updateGroupBuyBatch", method = RequestMethod.POST) |
| | | public ResponseEntity<String> updateGroupBuyBatch(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /groupBuyBatch/deleteGroupBuyBatch |
| | | * @path /app/groupBuyBatch/deleteGroupBuyBatch |
| | | * @serviceCode /groupBuy/deleteGroupBuyBatch |
| | | * @path /app/groupBuy/deleteGroupBuyBatch |
| | | */ |
| | | @RequestMapping(value = "/deleteGroupBuyBatch", method = RequestMethod.POST) |
| | | public ResponseEntity<String> deleteGroupBuyBatch(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | * |
| | | * @param storeId 小区ID |
| | | * @return |
| | | * @serviceCode /groupBuyBatch/queryGroupBuyBatch |
| | | * @path /app/groupBuyBatch/queryGroupBuyBatch |
| | | * @serviceCode /groupBuy/queryGroupBuyBatch |
| | | * @path /app/groupBuy/queryGroupBuyBatch |
| | | */ |
| | | @RequestMapping(value = "/queryGroupBuyBatch", method = RequestMethod.GET) |
| | | public ResponseEntity<String> queryGroupBuyBatch(@RequestHeader(value = "store-id") String storeId, |
| | | @RequestParam(value = "batchId",required = false) String batchId, |
| | | @RequestParam(value = "page") int page, |
| | | @RequestParam(value = "row") int row) { |
| | | GroupBuyBatchDto groupBuyBatchDto = new GroupBuyBatchDto(); |
| | | groupBuyBatchDto.setPage(page); |
| | | groupBuyBatchDto.setRow(row); |
| | | groupBuyBatchDto.setStoreId(storeId); |
| | | groupBuyBatchDto.setBatchId(batchId); |
| | | return getGroupBuyBatchBMOImpl.get(groupBuyBatchDto); |
| | | } |
| | | } |