1. <if condition="empty($coupon_detail)">
    2. <div class="empty-coupon">
    3. <i class="empty-coupon-icon iconfont icon-qiaquan "></i>
    4. <p class="empty-order-mark">暂无未使用优惠券!</p>
    5. </div>
    6. <else />
    7. <!-- 无优惠券时提示 end-->
    8. <!-- 优惠券 start -->
    9. <div class="sale_paper">
    10. <!-- <i class="iconfont icon-wodeyouhuiquan"></i>暂时无未使用优惠券 -->
    11. <div class="container">
    12. <foreach name="coupon_detail" item="v">
    13. <div class="paperbox">
    14. <div class="triangle"></div>
    15. <p>{$v['coupon_name']}优惠劵</p>
    16. <em>{$v['coupon_denomination']}<span></span><sup>优惠券</sup></em>
    17. <h4>满{$v['coupon_condition']}可用</h4>
    18. <span class="coupon_shop">最终解释权{$shopData['shop_name']}</span>
    19. <strong>(&nbsp;使用时间:{$v['start_time']|date="m/d",###}-{$v['end_time']|date="m/d",###}&nbsp;)</strong>
    20. <div class="free-collecte" coupon_id="{$v['id']}">未使用</div>
    21. <div class="transform-triangle"></div>
    22. <!-- <h4>满{$v['coupon_condition']}可用</h4> -->
    23. </div>
    24. </foreach>
    25. </div>
    26. </div>
    27. <!-- 优惠券 end -->
    28. </if>
    29. //js代码
    30. // 点击li的未使用...
    31. $('.coupon-status').click(function(){
    32. $(this).addClass('color');
    33. $(this).siblings().removeClass('color');
    34. // 获取到状态码
    35. var status = $(this).attr('status');
    36. // 发起ajax在后台查询数据
    37. $.post("{:U('addon/WeiuidDeit/Mobile/couponStatus')}",{status:status},function(data){
    38. if(data.return_code == 200){
    39. var str = '';
    40. for(var i = 0; i<data.data.length;i++){
    41. str += '<div class="paperbox">';
    42. str += '<div class="triangle"></div>';
    43. str += '<p>'+data['data'][i]['coupon_name']+'优惠劵</p>';
    44. str += '<em>'+data['data'][i]['coupon_denomination']+'<span></span><sup>优惠券</sup></em>';
    45. str += '<h4>满'+data['data'][i]['coupon_condition']+'可用</h4>';
    46. str += '<span class="coupon_shop">最终解释权'+data['shopdata']+'</span>';
    47. str += '<strong>(&nbsp;使用时间:'+data['data'][i]['start_time']+'-'+data['data'][i]['end_time']+'&nbsp;)</strong>';
    48. str += '<div class="free-collecte" coupon_id="'+data['data'][i]['id']+'">未使用</div>';
    49. str += '<div class="transform-triangle"></div>';
    50. str += '</div>';
    51. }
    52. // 商品的数据
    53. $('.container').html(str);
    54. $('.empty-coupon').remove();
    55. $('.sale_paper').show();
    56. }else{
    57. $('.empty-coupon').html('');
    58. var str = '';
    59. str += '<div class="empty-coupon"><i class="empty-coupon-icon iconfont icon-qiaquan "></i><p class="empty-order-mark">暂无未使用优惠券!</p></div>'
    60. $('.paper_nav').after(str);
    61. $('.sale_paper').hide();
    62. }
    63. });
    64. });
    65. //控制器代码
    66. /*
    67. 查询领取优惠表
    68. 循环出个人用户的所有领取的优惠卷
    69. */
    70. // 个人中心优惠卷页面
    71. public function coupon()
    72. {
    73. // 显示的是未使用的优惠卷
    74. $coupon_detail = M()->table('antweb_foodcouponreceive as a')
    75. ->join('antweb_foodcoupon as b on b.id=a.foodcoupon_id')
    76. ->where([
    77. 'foodmumber_id'=>session('userinfo')['id'],
    78. 'receive_status'=>1,
    79. ])
    80. ->order('a.id desc')
    81. ->select();
    82. // 查询是否有过期的优惠卷
    83. foreach($coupon_detail as $k=>$v){
    84. if($v['receive_status'] != 3){
    85. // 当前时间跟优惠卷结束时间做判断
    86. if(time()>$v['end_time']){
    87. $coupondata = D('foodcouponreceive')->where([
    88. 'foodmumber_id'=>session('userinfo')['id']
    89. ])->setInc('receive_status',2);
    90. }
    91. }
    92. }
    93. $this->assign([
    94. 'coupon_detail'=>$coupon_detail
    95. ]);
    96. $this->display();
    97. }
    98. /*
    99. 未使用,已使用,已过期
    100. author:咔咔
    101. time:2018.6.23
    102. */
    103. // 优惠卷状态 receive_status == 3
    104. public function couponStatus()
    105. {
    106. // 获取优惠卷状态码
    107. $status = I('status');
    108. $couponData = M()->table('antweb_foodcouponreceive as a')
    109. ->join('antweb_foodcoupon as b on b.id=a.foodcoupon_id')
    110. ->where([
    111. 'foodmumber_id'=>session('userinfo')['id'],
    112. 'shop_id'=>session('business_id'),
    113. 'receive_status'=>$status,
    114. ])
    115. ->select();
    116. foreach($couponData as $k=>$v){
    117. $couponData[$k]['start_time'] = date('m-d',$v['start_time']);
    118. $couponData[$k]['end_time'] = date('m-d',$v['end_time']);
    119. }
    120. // 查询店铺信息
    121. $shopData = D('foodmanagement')->where([
    122. 'id'=>session('business_id')
    123. ])->find();
    124. // 验证是否查询成功
    125. if($couponData){
    126. $return['return_code'] = 200;
    127. $return['return_msg'] = '查询成功';
    128. $return['data'] = $couponData;
    129. $return['shopdata'] = $shopData['shop_name'];
    130. }else{
    131. $return['return_code'] = 400;
    132. $return['return_msg'] = '查询失败';
    133. }
    134. $this->ajaxReturn($return);
    135. }